Remove cached model directories recursively
This commit is contained in:
parent
4f603817b2
commit
6c4b33a418
1 changed files with 27 additions and 2 deletions
|
|
@ -27,3 +27,21 @@ def test_unrelated_cache_entries_are_ignored() -> None:
|
|||
(LargeFileLocal.cache_path / "model-unrelated").write_text("unrelated")
|
||||
(LargeFileLocal.cache_path / "model-0").write_text("weights")
|
||||
assert LargeFileLocal("model").get().read_text() == "weights"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("operation", ["delete", "prune"])
|
||||
def test_cached_directories_can_be_removed(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, operation: str
|
||||
) -> None:
|
||||
source = tmp_path / "source"
|
||||
source.mkdir()
|
||||
(source / "weights").write_text("weights")
|
||||
LargeFileLocal("model", "w").push(source)
|
||||
reader = LargeFileLocal("model")
|
||||
cached = reader.get()
|
||||
if operation == "delete":
|
||||
reader.delete()
|
||||
else:
|
||||
monkeypatch.setattr(LargeFileLocal, "max_cache_size", "0")
|
||||
reader.clean_up()
|
||||
assert not cached.exists()
|
||||
|
|
|
|||
Loading…
Reference in a new issue