Ignore unrelated files during model version discovery
This commit is contained in:
parent
98efb8cb78
commit
4f603817b2
2 changed files with 12 additions and 11 deletions
|
|
@ -273,21 +273,15 @@ class LargeFileBase(ABC):
|
|||
def _find_instances_from_cache(self) -> List[DataInstance]:
|
||||
logger.info(f"Fetching cached versions of {self._name}")
|
||||
|
||||
candidates = [
|
||||
prefix = f"{self._name}{CACHE_NAME_VERSION_SEPARATOR}"
|
||||
return [
|
||||
DataInstance(
|
||||
name=CACHE_NAME_VERSION_SEPARATOR.join(
|
||||
f.name.split(CACHE_NAME_VERSION_SEPARATOR)[:-1]
|
||||
),
|
||||
version=int(f.name.split(CACHE_NAME_VERSION_SEPARATOR)[-1]),
|
||||
remote_path=f,
|
||||
)
|
||||
for f in self.cache_path.glob(
|
||||
f"{self._name}{CACHE_NAME_VERSION_SEPARATOR}*"
|
||||
name=self._name, version=int(f.name[len(prefix) :]), remote_path=f
|
||||
)
|
||||
for f in self.cache_path.glob(f"{prefix}*")
|
||||
if f.name[len(prefix) :].isdigit()
|
||||
]
|
||||
|
||||
return [c for c in candidates if c.name == self._name]
|
||||
|
||||
def _check_mode_and_set_version(self) -> None:
|
||||
if "+" in self._mode:
|
||||
raise ValueError(
|
||||
|
|
|
|||
|
|
@ -20,3 +20,10 @@ def test_configured_cache_directory_is_created(
|
|||
with LargeFileLocal("model", "w") as file:
|
||||
file.write("weights")
|
||||
assert LargeFileLocal("model").get().read_text() == "weights"
|
||||
|
||||
|
||||
def test_unrelated_cache_entries_are_ignored() -> None:
|
||||
LargeFileLocal.cache_path.mkdir(parents=True)
|
||||
(LargeFileLocal.cache_path / "model-unrelated").write_text("unrelated")
|
||||
(LargeFileLocal.cache_path / "model-0").write_text("weights")
|
||||
assert LargeFileLocal("model").get().read_text() == "weights"
|
||||
|
|
|
|||
Loading…
Reference in a new issue