diff --git a/src/hdmf_zarr/backend.py b/src/hdmf_zarr/backend.py index 10b5eaee..98b99df8 100644 --- a/src/hdmf_zarr/backend.py +++ b/src/hdmf_zarr/backend.py @@ -5,7 +5,6 @@ import numpy as np import tempfile import logging -import pathlib # Zarr imports import zarr @@ -550,14 +549,7 @@ 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]) - target_zarr_obj = target_zarr_obj[rel_obj_path] - except Exception: - raise ValueError("Found bad link to object %s in file %s" % (object_path, source_file)) + raise ValueError("Found bad link to object %s in file %s" % (object_path, source_file)) # Return the create path return target_name, target_zarr_obj diff --git a/tests/unit/base_tests_zarrio.py b/tests/unit/base_tests_zarrio.py index 199ce7aa..b0853b06 100644 --- a/tests/unit/base_tests_zarrio.py +++ b/tests/unit/base_tests_zarrio.py @@ -228,7 +228,7 @@ def test_write_compound(self, test_data=None): {'name': 'name', 'dtype': str}] self.__dataset_builder = DatasetBuilder('my_data', data, dtype=data_type) self.createGroupBuilder() - writer = ZarrIO(self.store, manager=self.manager, mode='a') + writer = ZarrIO(self.store, manager=self.manager, mode='w') writer.write_builder(self.builder) writer.close() diff --git a/tests/unit/test_io_convert.py b/tests/unit/test_io_convert.py index 2b8879d3..7de1861e 100644 --- a/tests/unit/test_io_convert.py +++ b/tests/unit/test_io_convert.py @@ -706,7 +706,7 @@ def test_export_cpd_dset_refs(self): bazs.append(b) baz_pairs.append((i, b)) baz_cpd_data = BazCpdData(name='baz_cpd_data1', data=baz_pairs) - bucket = BazBucket(name='bucket1', bazs=bazs.copy(), baz_cpd_data=baz_cpd_data) + bucket = BazBucket(name='root', bazs=bazs.copy(), baz_cpd_data=baz_cpd_data) with HDF5IO(self.path[0], manager=get_baz_buildmanager(), mode='w') as write_io: write_io.write(bucket) @@ -751,7 +751,7 @@ def test_export_cpd_dset_refs(self): bazs.append(b) baz_pairs.append((i, b)) baz_cpd_data = BazCpdData(name='baz_cpd_data1', data=baz_pairs) - bucket = BazBucket(name='bucket1', bazs=bazs.copy(), baz_cpd_data=baz_cpd_data) + bucket = BazBucket(name='root', bazs=bazs.copy(), baz_cpd_data=baz_cpd_data) with ZarrIO(self.path[0], manager=get_baz_buildmanager(), mode='w') as write_io: write_io.write(bucket) @@ -797,12 +797,13 @@ def test_export_cpd_dset_refs(self): bazs.append(b) baz_pairs.append((i, b)) baz_cpd_data = BazCpdData(name='baz_cpd_data1', data=baz_pairs) - bucket = BazBucket(name='bucket1', bazs=bazs.copy(), baz_cpd_data=baz_cpd_data) + bucket = BazBucket(name='root', bazs=bazs.copy(), baz_cpd_data=baz_cpd_data) with ZarrIO(self.path[0], manager=get_baz_buildmanager(), mode='w') as write_io: write_io.write(bucket) with ZarrIO(self.path[0], manager=get_baz_buildmanager(), mode='r') as read_io: read_bucket1 = read_io.read() + read_bucket1.baz_cpd_data.data[0][0] # NOTE: reference IDs might be the same between two identical files # adding a Baz with a smaller name should change the reference IDs on export new_baz = Baz(name='baz000')