Skip to content

Commit

Permalink
🐛 Fix cache paths (#874)
Browse files Browse the repository at this point in the history
* Upgrade upath

* fix

* fix

* fix
  • Loading branch information
Koncopd authored Sep 30, 2024
1 parent d4e6f38 commit 5e6939d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/hub-prod/test-cloud-sync.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@
"source": [
"time.sleep(1)\n",
"cloud_file = dir_sync / \"file1\"\n",
"# update cloud timestamp, exist_ok=False needed due to truncate=not exist_ok in upath\n",
"cloud_file.touch(exist_ok=False) \n",
"# update cloud timestamp\n",
"cloud_file.fs.touch(cloud_file.as_posix(), truncate=True) \n",
"\n",
"assert cloud_file.modified.timestamp() > local_file_new.stat().st_mtime"
]
Expand Down
2 changes: 1 addition & 1 deletion lamindb_setup/_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def delete_cache(isettings: InstanceSettings):
# avoid init of root
root = isettings.storage._root_init
if not isinstance(root, LocalPathClasses):
cache_dir = isettings.storage.cache_dir / root
cache_dir = isettings.storage.cache_dir / root.path
if cache_dir.exists():
shutil.rmtree(cache_dir)

Expand Down
7 changes: 3 additions & 4 deletions lamindb_setup/core/_settings_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def is_on_hub(self) -> bool:
return True

def cloud_to_local(
self, filepath: UPathStr, cache_key: UPathStr | None = None, **kwargs
self, filepath: UPathStr, cache_key: str | None = None, **kwargs
) -> UPath:
"""Local (or local cache) filepath from filepath."""
# cache_key is ignored in cloud_to_local_no_update if filepath is local
Expand All @@ -391,13 +391,12 @@ def cloud_to_local(
return local_filepath

def cloud_to_local_no_update(
self, filepath: UPathStr, cache_key: UPathStr | None = None
self, filepath: UPathStr, cache_key: str | None = None
) -> UPath:
# cache_key is ignored if filepath is local
if isinstance(filepath, UPath) and not isinstance(filepath, LocalPathClasses):
# Path / UPath discards protocol from UPath if present
local_filepath = self.cache_dir / (
filepath if cache_key is None else cache_key
filepath.path if cache_key is None else cache_key
)
else:
local_filepath = filepath
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"pydantic-settings",
"appdirs<2.0.0",
"requests",
"universal_pathlib==0.2.2", # is still experimental, need pinning
"universal_pathlib==0.2.5", # is still experimental, need pinning
"botocore<2.0.0",
"gotrue>=2.1.0,<2.9.0", # lower - for options in auth.sign_out, upper - 2.9.0 fails
"supabase==2.2.1",
Expand Down

0 comments on commit 5e6939d

Please sign in to comment.