Skip to content

Commit

Permalink
Merge branch 'dev' into append_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 authored Jul 22, 2024
2 parents ff6e435 + 626341c commit 5e6a617
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.9.0 (Upcoming)
### Enhancements
* Added support for appending a dataset of references. @mavaylon1 [#203]([https://github.com/hdmf-dev/hdmf-zarr/pull/172](https://github.com/hdmf-dev/hdmf-zarr/pull/203))
* NWBZarrIO load_namespaces=True by default. @mavaylon1 [#204](https://github.com/hdmf-dev/hdmf-zarr/pull/204)

## 0.8.0 (June 4, 2024)
### Bug Fixes
Expand Down
10 changes: 7 additions & 3 deletions src/hdmf_zarr/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,17 @@ def is_remote(self):
{'name': 'path',
'type': (str, *SUPPORTED_ZARR_STORES),
'doc': 'the path to the Zarr file or a supported Zarr store'},
{'name': 'namespaces', 'type': list, 'doc': 'the namespaces to load', 'default': None})
def load_namespaces(cls, namespace_catalog, path, namespaces=None):
{'name': 'storage_options', 'type': dict,
'doc': 'Zarr storage options to read remote folders',
'default': None},
{'name': 'namespaces', 'type': list, 'doc': 'the namespaces to load', 'default': None}
)
def load_namespaces(cls, namespace_catalog, path, storage_options, namespaces=None):
'''
Load cached namespaces from a file.
'''
# TODO: how to use storage_options here?
f = zarr.open(path, mode='r')
f = zarr.open(path, mode='r', storage_options=storage_options)
if SPEC_LOC_ATTR not in f.attrs:
msg = "No cached namespaces found in %s" % path
warnings.warn(msg)
Expand Down
17 changes: 7 additions & 10 deletions src/hdmf_zarr/nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,22 @@ class NWBZarrIO(ZarrIO):
@docval(*get_docval(ZarrIO.__init__),
{'name': 'load_namespaces', 'type': bool,
'doc': 'whether or not to load cached namespaces from given path - not applicable in write mode',
'default': False},
'default': True},
{'name': 'extensions', 'type': (str, TypeMap, list),
'doc': 'a path to a namespace, a TypeMap, or a list consisting paths to namespaces and TypeMaps',
'default': None})
def __init__(self, **kwargs):
path, mode, manager, extensions, load_namespaces, synchronizer, storage_options = \
popargs('path', 'mode', 'manager', 'extensions',
'load_namespaces', 'synchronizer', 'storage_options', kwargs)
if load_namespaces:
if manager is not None:
warn("loading namespaces from file - ignoring 'manager'")
if extensions is not None:
warn("loading namespaces from file - ignoring 'extensions' argument")
# namespaces are not loaded when creating an NWBZarrIO object in write mode
if 'w' in mode or mode == 'x':
raise ValueError("cannot load namespaces from file when writing to it")

io_modes_that_create_file = ['w', 'w-', 'x']
if mode in io_modes_that_create_file or manager is not None or extensions is not None:
load_namespaces = False

if load_namespaces:
tm = get_type_map()
super(NWBZarrIO, self).load_namespaces(tm, path)
super(NWBZarrIO, self).load_namespaces(tm, path, storage_options)
manager = BuildManager(tm)
else:
if manager is not None and extensions is not None:
Expand Down

0 comments on commit 5e6a617

Please sign in to comment.