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

LindiH5pyFile - implement close() properly #22

Open
magland opened this issue Mar 21, 2024 · 0 comments
Open

LindiH5pyFile - implement close() properly #22

magland opened this issue Mar 21, 2024 · 0 comments

Comments

@magland
Copy link
Collaborator

magland commented Mar 21, 2024

__init__ states that users should use the from_* factory methods instead. Who is responsible for closing objects that are being opened there? E.g., in from_zarr_store the factory methods opens the zarr store, but other than the returned LindiH5pyFile object, no-one else has access/owns the file.

@staticmethod
def from_zarr_store(zarr_store: Union[ZarrStore, FSMap]):
"""
Create a LindiH5pyFile from a zarr store.
"""
zarr_group = zarr.open(store=zarr_store, mode="r")
assert isinstance(zarr_group, zarr.Group)
return LindiH5pyFile.from_zarr_group(zarr_group)

For factory methods that require an already opened file to be handed in, I agree, that LINIDI should not just close it. But for cases where LINDI functions open the file (and in particular when the opened file/store is not being exposed to the caller), I think it should be the role of LINDI to close.

Originally posted by @oruebel in #21 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant