Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Sep 25, 2023
1 parent fb72e28 commit 82b7664
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/hdmf_zarr/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ def resolve_ref(self, zarr_ref):
try:
target_zarr_obj = target_zarr_obj[object_path]
except Exception:
# TODO: Find why the reference includes the root object.
# This is a fix to allow the target object to be found
try:
object_path = pathlib.Path(object_path)
rel_obj_path = object_path.relative_to(*object_path.parts[:2])
Expand Down Expand Up @@ -1078,6 +1080,7 @@ def __read_group(self, zarr_obj, name=None):
for sub_name, sub_group in zarr_obj.groups():
sub_builder = self.__read_group(sub_group, sub_name)
ret.set_group(sub_builder)

# read sub datasets
for sub_name, sub_array in zarr_obj.arrays():
sub_builder = self.__read_dataset(sub_array, sub_name)
Expand Down
15 changes: 10 additions & 5 deletions tests/unit/test_io_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def test_export_roundtrip(self):
self.assertEqual(exported_container.baz_data.data.__class__.__name__,
'ContainerZarrReferenceDataset')
self.assertIs(exported_container.baz_data.data[i], exported_container.bazs[baz_name])

# assert that the roundtrip worked correctly
message = "Using: write_path=%s, export_path=%s" % (str(write_path), str(export_path))
self.assertIsNotNone(str(container), message) # added as a test to make sure printing works
Expand All @@ -199,7 +200,6 @@ def test_export_roundtrip(self):
ignore_string_to_byte=self.IGNORE_STRING_TO_BYTE,
message=message)
self.close_files_and_ios()
# TODO: May need to add further asserts here


##########################################################
Expand All @@ -225,6 +225,7 @@ def get_manager(self):
def roundtripExportContainer(self, container, write_path, export_path):
with HDF5IO(write_path, manager=self.get_manager(), mode='w') as write_io:
write_io.write(container, cache_spec=True)

with HDF5IO(write_path, manager=self.get_manager(), mode='r') as read_io:
with ZarrIO(export_path, mode='w') as export_io:
export_io.export(src_io=read_io, write_args={'link_data': False})
Expand Down Expand Up @@ -255,6 +256,7 @@ def get_manager(self):
def roundtripExportContainer(self, container, write_path, export_path):
with ZarrIO(write_path, manager=self.get_manager(), mode='w') as write_io:
write_io.write(container)

with ZarrIO(write_path, manager=self.get_manager(), mode='r') as read_io:
with HDF5IO(export_path, mode='w') as export_io:
export_io.export(src_io=read_io, write_args={'link_data': False})
Expand Down Expand Up @@ -288,6 +290,7 @@ def get_manager(self):
def roundtripExportContainer(self, container, write_path, export_path):
with ZarrIO(write_path, manager=self.get_manager(), mode='w') as write_io:
write_io.write(container, cache_spec=True)

with ZarrIO(write_path, manager=self.get_manager(), mode='r') as read_io:
with ZarrIO(export_path, mode='w') as export_io:
export_io.export(src_io=read_io, write_args={'link_data': False})
Expand Down Expand Up @@ -646,8 +649,8 @@ class TestZarrToHDF5Baz1(MixinTestBaz1,
MixinTestCaseConvert,
TestCase):
"""
Test the conversion of a simple Foo container with two buckets of datasets from Zarr to HDF5
See MixinTestFoo.setUpContainer for the container spec used.
Test the conversion of a BazBucket containing a dataset of references from Zarr to HDF5
See MixinTestBaz1.setUpContainer for the container spec used.
"""
IGNORE_NAME = True
IGNORE_HDMF_ATTRS = True
Expand All @@ -660,7 +663,8 @@ class TestHDF5toZarrBaz1(MixinTestBaz1,
MixinTestCaseConvert,
TestCase):
"""
Test the conversion of a BazBucket containing a dataset of references from HDF5 to Zarr
See MixinTestBaz1.setUpContainer for the container spec used.
"""
IGNORE_NAME = True
IGNORE_HDMF_ATTRS = True
Expand All @@ -673,7 +677,8 @@ class TestZarrtoZarrBaz1(MixinTestBaz1,
MixinTestCaseConvert,
TestCase):
"""
Test the conversion of a BazBucket containing a dataset of references from Zarr to Zarr
See MixinTestBaz1.setUpContainer for the container spec used.
"""
IGNORE_NAME = True
IGNORE_HDMF_ATTRS = True
Expand Down

0 comments on commit 82b7664

Please sign in to comment.