NeurodataWithoutBorders / lindi

Linked Data Interface (LINDI) - cloud-friendly access to NWB data
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

LindiH5pyFile - implement close() properly #22

Open magland opened 5 months ago

magland commented 5 months ago

__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.

https://github.com/NeurodataWithoutBorders/lindi/blob/fe51dbc3aafe7c2a35b392fc93059387e96319a6/lindi/LindiH5pyFile/LindiH5pyFile.py#L52-L59

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 https://github.com/NeurodataWithoutBorders/lindi/pull/21#discussion_r1533084286_