-
Notifications
You must be signed in to change notification settings - Fork 1
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
implement lindi.File, drop-in replacement for h5py.File that supports .lindi.json files based on extension (4) #60
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## write-json #60 +/- ##
==============================================
+ Coverage 79.95% 81.47% +1.52%
==============================================
Files 29 30 +1
Lines 2155 2208 +53
==============================================
+ Hits 1723 1799 +76
+ Misses 432 409 -23 ☔ View full report in Codecov by Sentry. |
Here we make a lindi.File that can be a drop-in replacement for h5py.File, where it smartly decides whether to use h5py or lindi based on the file extension of the file name. This PR corrects a few small issues/mistakes from previous PRs. |
@@ -52,6 +52,9 @@ def from_lindi_file(url_or_path: str, *, mode: LindiFileMode = "r", staging_area | |||
|
|||
For a description of parameters, see from_reference_file_system(). | |||
""" | |||
if local_file_path is None: | |||
if not url_or_path.startswith("http://") and not url_or_path.startswith("https://"): | |||
local_file_path = url_or_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the local file path (the one that can get edited) to be equal to the url_or_path in the case that it is not provided and is not a url
@@ -166,7 +169,7 @@ def from_reference_file_system(rfs: Union[dict, str, None], *, mode: LindiFileMo | |||
store = LindiReferenceFileSystemStore(rfs, local_cache=local_cache) | |||
if staging_area: | |||
store = LindiStagingStore(base_store=store, staging_area=staging_area) | |||
return LindiH5pyFile.from_zarr_store(store, mode=mode, local_file_path=local_file_path) | |||
return LindiH5pyFile.from_zarr_store(store, mode=mode, local_file_path=local_file_path, local_cache=local_cache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was accidentally omitted.
def create(*, base_dir: Union[str, None] = None, dir: Union[str, None] = None) -> 'StagingArea': | ||
""" | ||
Create a new staging area. | ||
Create a new staging area. Provide either `base_dir` or `dir`, but not | ||
both. | ||
|
||
Parameters | ||
---------- | ||
base_dir : str | ||
The base directory where the staging area will be created. The | ||
staging directory will be a subdirectory of this directory. | ||
base_dir : str or None | ||
If provided, the base directory where the staging area will be | ||
created. The staging directory will be a subdirectory of this | ||
directory. | ||
dir : str or None | ||
If provided, the exact directory where the staging area will be | ||
created. It is okay if this directory already exists. | ||
""" | ||
dir = os.path.join(base_dir, _create_random_id()) | ||
if base_dir is not None and dir is not None: | ||
raise ValueError("Provide either base_dir or dir, but not both") | ||
if base_dir is not None: | ||
dir = os.path.join(base_dir, _create_random_id()) | ||
if dir is None: | ||
raise ValueError("Provide either base_dir or dir") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either supply a dir or a base_dir
…range-error catch chunk byte range error (5)
Add generation metadata to .lindi.json file writing (6)
No description provided.