Refresh available model versions after uploads
This commit is contained in:
parent
29ea9bbc78
commit
002a4aaaba
2 changed files with 18 additions and 0 deletions
|
|
@ -239,6 +239,7 @@ class LargeFileBase(ABC):
|
||||||
raise FileExistsError(f"Version already exists: {destination}")
|
raise FileExistsError(f"Version already exists: {destination}")
|
||||||
shutil.move(str(staged), str(destination))
|
shutil.move(str(staged), str(destination))
|
||||||
|
|
||||||
|
self._find_instances()
|
||||||
self.clean_up()
|
self.clean_up()
|
||||||
|
|
||||||
def delete(self) -> None:
|
def delete(self) -> None:
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,23 @@ def test_evicted_remote_model_is_downloaded_again() -> None:
|
||||||
assert downloads == ["model/0", "model/0"]
|
assert downloads == ["model/0", "model/0"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_upload_refreshes_available_versions() -> None:
|
||||||
|
writer = LargeFileLocal("model", "w")
|
||||||
|
with writer as file:
|
||||||
|
file.write("weights")
|
||||||
|
assert writer.versions_pretty == "0"
|
||||||
|
assert writer.get().read_text() == "weights"
|
||||||
|
|
||||||
|
|
||||||
|
def test_retention_counts_the_new_version() -> None:
|
||||||
|
for version in range(3):
|
||||||
|
with LargeFileLocal("model", "w", keep_last_n=1) as file:
|
||||||
|
file.write(str(version))
|
||||||
|
reader = LargeFileLocal("model")
|
||||||
|
assert reader.versions_pretty == "2"
|
||||||
|
assert reader.get().read_text() == "2"
|
||||||
|
|
||||||
|
|
||||||
def test_uploading_cached_directory_preserves_source(tmp_path: Path) -> None:
|
def test_uploading_cached_directory_preserves_source(tmp_path: Path) -> None:
|
||||||
source = tmp_path / "source"
|
source = tmp_path / "source"
|
||||||
source.mkdir()
|
source.mkdir()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue