Closed CodyCBakerPhD closed 2 months ago
I'll take a look after Dev Days
My initial concern was that the mode is changed somewhere along the line. However looking at the trace, I do not see anything where the mode changes. I checked with breakpoints and the mode stays as r+. I cloned a dev version of zarr to see if it is a zarr issue vs an issue on our end.
I do believe the issue is consolidate metadata. I am running a check.
@CodyCBakerPhD try doing this without consolidating metadata in write. It works.
with NWBZarrIO(path="./test_zarr_append.nwb.zarr", mode="w") as io:
nwbfile_out = mock_NWBFile()
io.write(nwbfile_out, consolidate_metadata=False)
Now looking at the zarr code, when we consolidate metadata, we use ConsolidatedMetadataStore
. This interface does not seem to allow for setting items at all. In the doc string, it says it is "read only".
I will document this to be explicit within our codebase and not require people to dig through zarr
@oruebel You added
if self.__mode not in ['r' ,'r+']:
# r- is only an internal mode in ZarrIO to force the use of regular open. For Zarr we need to
# use the regular mode r when r- is specified
mode_to_use = self.__mode if self.__mode != 'r-' else 'r'
self.__file = zarr.open(store=self.path,
mode=mode_to_use,
synchronizer=self.__synchronizer,
storage_options=self.__storage_options)
else:
self.__file = self.__open_file_consolidated(store=self.path,
mode=self.__mode,
synchronizer=self.__synchronizer,
storage_options=self.__storage_options)
I think we should have a condition that uses open
when the mode is "r+" and not __open_file_consolidated
. (This does work). There would also be a warning.
I think we should have a condition that uses
open
when the mode is "r+"
Agreed, I think we should just change the check to if self.__mode == 'r'
to only open with consolidated metadata when the file is in read-only mode and use the regular zarr.open
otherwise.
What happened?
Minimal example below
Basic operation that should have always worked and should have tests
Steps to Reproduce
Traceback
Operating System
Windows
Python Executable
Conda
Python Version
3.10
Package Versions
No response
Code of Conduct