From 11059211bde1ad25e20c806e41c7a401c7616f56 Mon Sep 17 00:00:00 2001 From: Jeremy Magland Date: Thu, 9 May 2024 05:44:08 -0400 Subject: [PATCH 1/2] use frozen=True for LindiH5ZarrStoreOpts Co-authored-by: Ryan Ly --- lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py b/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py index 07a3ea8..a99341a 100644 --- a/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py +++ b/lindi/LindiH5ZarrStore/LindiH5ZarrStoreOpts.py @@ -2,7 +2,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(frozen=True) class LindiH5ZarrStoreOpts: """ Options for the LindiH5ZarrStore class. From 833b3f325a6dc44e9737feb252eaaed979d967eb Mon Sep 17 00:00:00 2001 From: Jeremy Magland Date: Thu, 9 May 2024 05:46:43 -0400 Subject: [PATCH 2/2] Use None for default zarr store opts --- lindi/LindiH5ZarrStore/LindiH5ZarrStore.py | 6 ++++-- lindi/LindiH5pyFile/LindiH5pyFile.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py b/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py index 82373eb..47f9168 100644 --- a/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py +++ b/lindi/LindiH5ZarrStore/LindiH5ZarrStore.py @@ -69,7 +69,7 @@ def __init__( def from_file( hdf5_file_name_or_url: str, *, - opts: LindiH5ZarrStoreOpts = LindiH5ZarrStoreOpts(), + opts: Union[LindiH5ZarrStoreOpts, None] = None, url: Union[str, None] = None, local_cache: Union[LocalCache, None] = None ): @@ -80,7 +80,7 @@ def from_file( ---------- hdf5_file_name_or_url : str The name of the HDF5 file or a URL to the HDF5 file. - opts : LindiH5ZarrStoreOpts + opts : LindiH5ZarrStoreOpts or None Options for the store. url : str or None If hdf5_file_name_or_url is a local file name, then this can @@ -93,6 +93,8 @@ def from_file( A local cache to use when reading chunks from a remote file. If None, then no local cache is used. """ + if opts is None: + opts = LindiH5ZarrStoreOpts() # default options if hdf5_file_name_or_url.startswith( "http://" ) or hdf5_file_name_or_url.startswith("https://"): diff --git a/lindi/LindiH5pyFile/LindiH5pyFile.py b/lindi/LindiH5pyFile/LindiH5pyFile.py index ecfc502..0d8272f 100644 --- a/lindi/LindiH5pyFile/LindiH5pyFile.py +++ b/lindi/LindiH5pyFile/LindiH5pyFile.py @@ -46,7 +46,7 @@ def from_lindi_file(url_or_path: str, *, mode: Literal["r", "r+"] = "r", staging return LindiH5pyFile.from_reference_file_system(url_or_path, mode=mode, staging_area=staging_area, local_cache=local_cache) @staticmethod - def from_hdf5_file(url_or_path: str, *, mode: Literal["r", "r+"] = "r", local_cache: Union[LocalCache, None] = None, zarr_store_opts: LindiH5ZarrStoreOpts = LindiH5ZarrStoreOpts()): + def from_hdf5_file(url_or_path: str, *, mode: Literal["r", "r+"] = "r", local_cache: Union[LocalCache, None] = None, zarr_store_opts: Union[LindiH5ZarrStoreOpts, None] = None): """ Create a LindiH5pyFile from a URL or path to an HDF5 file. @@ -59,6 +59,8 @@ def from_hdf5_file(url_or_path: str, *, mode: Literal["r", "r+"] = "r", local_ca supported, by default "r". local_cache : Union[LocalCache, None], optional 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. """ from ..LindiH5ZarrStore.LindiH5ZarrStore import LindiH5ZarrStore # avoid circular import if mode == 'r+':