From 6ebdf4416e95d2a259a26a0394f6312f01627769 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Mon, 13 May 2024 13:11:37 -0700 Subject: [PATCH 1/3] Update LindiH5pyFile.py --- lindi/LindiH5pyFile/LindiH5pyFile.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lindi/LindiH5pyFile/LindiH5pyFile.py b/lindi/LindiH5pyFile/LindiH5pyFile.py index 568db95..5968a34 100644 --- a/lindi/LindiH5pyFile/LindiH5pyFile.py +++ b/lindi/LindiH5pyFile/LindiH5pyFile.py @@ -58,7 +58,14 @@ def from_lindi_file(url_or_path: str, *, mode: LindiFileMode = "r", staging_area return LindiH5pyFile.from_reference_file_system(url_or_path, mode=mode, staging_area=staging_area, local_cache=local_cache, local_file_path=local_file_path) @staticmethod - def from_hdf5_file(url_or_path: str, *, mode: LindiFileMode = "r", local_cache: Union[LocalCache, None] = None, zarr_store_opts: Union[LindiH5ZarrStoreOpts, None] = None): + def from_hdf5_file( + url_or_path: str, + *, + mode: LindiFileMode = "r", + local_cache: Union[LocalCache, None] = None, + zarr_store_opts: Union[LindiH5ZarrStoreOpts, None] = None, + url: Union[str, None] = None + ): """ Create a LindiH5pyFile from a URL or path to an HDF5 file. @@ -73,11 +80,18 @@ def from_hdf5_file(url_or_path: str, *, mode: LindiFileMode = "r", local_cache: The local cache to use for caching data chunks, by default None. zarr_store_opts : Union[LindiH5ZarrStoreOpts, None], optional The options to use for the zarr store, by default None. + url : str or None + If url_or_path is a local file name, then this can + optionally be set to the URL of the remote file to be used when + creating references. If None, and the url_or_path is a + local file name, then you will need to set + zarr_store_opts.num_dataset_chunks_threshold to None, and you will not be able + to use the to_reference_file_system method. """ from ..LindiH5ZarrStore.LindiH5ZarrStore import LindiH5ZarrStore # avoid circular import if mode != "r": raise Exception("Opening hdf5 file in write mode is not supported") - zarr_store = LindiH5ZarrStore.from_file(url_or_path, local_cache=local_cache, opts=zarr_store_opts, url=url_or_path) + zarr_store = LindiH5ZarrStore.from_file(url_or_path, local_cache=local_cache, opts=zarr_store_opts, url=url) return LindiH5pyFile.from_zarr_store( zarr_store=zarr_store, mode=mode, From d37cb51046bbe4229e8a394d1d89bb8ae0535372 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Tue, 14 May 2024 18:49:06 -0700 Subject: [PATCH 2/3] Correct comment in LindiH5ZarrStore.py --- lindi/LindiH5ZarrStore/LindiH5ZarrStore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py b/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py index b12f592..36ad26a 100644 --- a/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py +++ b/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py @@ -443,7 +443,7 @@ def _get_external_array_link(self, parent_key: str, h5_item: h5py.Dataset): if self._url is not None: self._external_array_links[parent_key] = { "link_type": "hdf5_dataset", - "url": self._url, # url is not going to be null based on the check in __init__ + "url": self._url, "name": parent_key, } else: From e50931b653310d10dab82f6990e18972737da6aa Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Tue, 14 May 2024 18:52:34 -0700 Subject: [PATCH 3/3] Update LindiH5ZarrStoreOpts.py --- lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py b/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py index a99341a..40fe998 100644 --- a/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py +++ b/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py @@ -11,6 +11,7 @@ class LindiH5ZarrStoreOpts: num_dataset_chunks_threshold (Union[int, None]): For each dataset in the HDF5 file, if the number of chunks is greater than this threshold, then the dataset will be represented as an external array link. If None, then - the threshold is not used. Default is 1000. + no datasets will be represented as external array links (equivalent to a + threshold of 0). Default is 1000. """ num_dataset_chunks_threshold: Union[int, None] = 1000