Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain virtual folder structure #859

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lamindb_setup/core/_settings_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,16 @@ def cloud_to_local(self, filepath: Path | UPath, **kwargs) -> UPath:
# in pure write operations that update the cloud, we don't want this
# hence, we manually construct the local file path
# using the `.parts` attribute in the following line
def cloud_to_local_no_update(self, filepath: UPath) -> UPath:
def cloud_to_local_no_update(self, filepath: UPath, virtual_path: str | None = None) -> UPath:
# virtual_path = lamin-us-east-1/298jfOijf0/mydatasets/adata1.h5ad
# if filepath is a cloud path, create a cache_path
if isinstance(filepath, UPath) and not isinstance(filepath, LocalPathClasses):
return self.cache_dir.joinpath(filepath._url.netloc, *filepath.parts[1:]) # type: ignore
if virtual_path is None:
cache_path = self.cache_dir.joinpath(filepath._url.netloc, *filepath.parts[1:]) # type: ignore
else:
cache_path = self.cache_dir.joinpath(relative_path)
return cache_path
# if filepath is a local path, it returns the filepath
return filepath

def local_filepath(self, filekey: Path | UPath | str) -> UPath:
Expand Down
Loading