Skip to content

Commit

Permalink
some tests are working
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Oct 17, 2024
1 parent 24ce06c commit 417672f
Show file tree
Hide file tree
Showing 22 changed files with 163 additions and 105 deletions.
43 changes: 2 additions & 41 deletions src/hdmf_zarr/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,15 +744,14 @@ def resolve_ref(self, zarr_ref):
target_name = os.path.basename(object_path)
else:
target_name = ROOT_NAME
breakpoint()

target_zarr_obj = self.__open_file_consolidated(store=source_file,
mode='r',
storage_options=self.__storage_options)
if object_path is not None:
try:
target_zarr_obj = target_zarr_obj[object_path]
except Exception:
breakpoint()
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
Expand Down Expand Up @@ -848,45 +847,7 @@ def write_link(self, **kwargs):

self.__add_link__(parent, zarr_ref.source, zarr_ref.path, name)
self._written_builders.set_written(builder) # record that the builder has been written
# @docval({'name': 'parent', 'type': Group, 'doc': 'the parent HDF5 object'},
# {'name': 'builder', 'type': LinkBuilder, 'doc': 'the LinkBuilder to write'},
# {'name': 'export_source', 'type': str,
# 'doc': 'The source of the builders when exporting', 'default': None},
# returns='the Link that was created', rtype=(SoftLink, ExternalLink))
# def write_link(self, **kwargs):
# parent, builder, export_source = getargs('parent', 'builder', 'export_source', kwargs)
# self.logger.debug("Writing LinkBuilder '%s' to parent group '%s'" % (builder.name, parent.name))
# if self.get_written(builder):
# self.logger.debug(" LinkBuilder '%s' is already written" % builder.name)
# return None
# name = builder.name
# target_builder = builder.builder
# path = self.__get_path(target_builder)
# # source will indicate target_builder's location
# if export_source is None:
# write_source = builder.source
# else:
# write_source = export_source
#
# parent_filename = os.path.abspath(parent.file.filename)
# if target_builder.source in (write_source, parent_filename):
# link_obj = SoftLink(path)
# self.logger.debug(" Creating SoftLink '%s/%s' to '%s'"
# % (parent.name, name, link_obj.path))
# elif target_builder.source is not None:
# target_filename = os.path.abspath(target_builder.source)
# relative_path = os.path.relpath(target_filename, os.path.dirname(parent_filename))
# if target_builder.location is not None:
# path = target_builder.location + "/" + target_builder.name
# link_obj = ExternalLink(relative_path, path)
# self.logger.debug(" Creating ExternalLink '%s/%s' to '%s://%s'"
# % (parent.name, name, link_obj.filename, link_obj.path))
# else:
# msg = 'cannot create external link to %s' % path
# raise ValueError(msg)
# parent[name] = link_obj
# self.__set_written(builder)
# return link_obj

@classmethod
def __setup_chunked_dataset__(cls, parent, name, data, options=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion test_io0.zarr/.zattrs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
".specloc": "specifications",
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "27d9b554-421a-4cb7-8c24-66b5747b86df"
"object_id": "20283a8a-00e6-414a-8dd4-4125364c03a5"
}
6 changes: 3 additions & 3 deletions test_io0.zarr/.zmetadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
".zattrs": {
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "27d9b554-421a-4cb7-8c24-66b5747b86df"
"object_id": "20283a8a-00e6-414a-8dd4-4125364c03a5"
},
".zgroup": {
"zarr_format": 2
Expand All @@ -14,7 +14,7 @@
"buckets/bucket1/.zattrs": {
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "464e00d7-11dd-4466-afda-def0b44bb2c9"
"object_id": "732346eb-b4a1-4eb6-aee1-2d64cfe8c165"
},
"buckets/bucket1/.zgroup": {
"zarr_format": 2
Expand All @@ -27,7 +27,7 @@
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "4ad02d31-07cf-4b31-ab8b-eecca3ffb26d"
"object_id": "7d47b7b1-ab86-462d-a8fc-0ae0fbf37315"
},
"buckets/bucket1/foo_holder/foo1/.zgroup": {
"zarr_format": 2
Expand Down
2 changes: 1 addition & 1 deletion test_io0.zarr/buckets/bucket1/.zattrs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "464e00d7-11dd-4466-afda-def0b44bb2c9"
"object_id": "732346eb-b4a1-4eb6-aee1-2d64cfe8c165"
}
2 changes: 1 addition & 1 deletion test_io0.zarr/buckets/bucket1/foo_holder/foo1/.zattrs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "4ad02d31-07cf-4b31-ab8b-eecca3ffb26d"
"object_id": "7d47b7b1-ab86-462d-a8fc-0ae0fbf37315"
}
9 changes: 8 additions & 1 deletion test_io1.zarr/.zattrs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
".specloc": "specifications",
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
"object_id": "2ad0d2b0-dd51-4c5e-84d3-e561330a4f6f",
"zarr_link": [
{
"name": "foofile_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
}
36 changes: 31 additions & 5 deletions test_io1.zarr/.zmetadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,49 @@
".zattrs": {
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
"object_id": "2ad0d2b0-dd51-4c5e-84d3-e561330a4f6f",
"zarr_link": [
{
"name": "foofile_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
},
".zgroup": {
"zarr_format": 2
},
"buckets/.zgroup": {
"zarr_format": 2
},
"links/.zattrs": {
"buckets/bucket2/.zattrs": {
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "9fd11ffb-4d93-40bf-9a0e-12c1686a1a79"
},
"buckets/bucket2/.zgroup": {
"zarr_format": 2
},
"buckets/bucket2/foo_holder/.zgroup": {
"zarr_format": 2
},
"buckets/bucket2/foo_holder/foo2/.zattrs": {
"attr1": "I am foo2",
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "432c2318-91c6-437e-81c1-e97ceecb0e18",
"zarr_link": [
{
"name": "foo_link",
"path": "/buckets/bucket1/foo_holder/foo1",
"source": "test_io0.zarr"
"name": "my_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
},
"buckets/bucket2/foo_holder/foo2/.zgroup": {
"zarr_format": 2
},
"links/.zgroup": {
"zarr_format": 2
}
Expand Down
5 changes: 5 additions & 0 deletions test_io1.zarr/buckets/bucket2/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "9fd11ffb-4d93-40bf-9a0e-12c1686a1a79"
}
3 changes: 3 additions & 0 deletions test_io1.zarr/buckets/bucket2/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
3 changes: 3 additions & 0 deletions test_io1.zarr/buckets/bucket2/foo_holder/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
14 changes: 14 additions & 0 deletions test_io1.zarr/buckets/bucket2/foo_holder/foo2/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"attr1": "I am foo2",
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "432c2318-91c6-437e-81c1-e97ceecb0e18",
"zarr_link": [
{
"name": "my_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
}
3 changes: 3 additions & 0 deletions test_io1.zarr/buckets/bucket2/foo_holder/foo2/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
9 changes: 0 additions & 9 deletions test_io1.zarr/links/.zattrs

This file was deleted.

9 changes: 8 additions & 1 deletion test_io2.zarr/.zattrs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
".specloc": "specifications",
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
"object_id": "2ad0d2b0-dd51-4c5e-84d3-e561330a4f6f",
"zarr_link": [
{
"name": "foofile_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
}
36 changes: 31 additions & 5 deletions test_io2.zarr/.zmetadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,49 @@
".zattrs": {
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
"object_id": "2ad0d2b0-dd51-4c5e-84d3-e561330a4f6f",
"zarr_link": [
{
"name": "foofile_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
},
".zgroup": {
"zarr_format": 2
},
"buckets/.zgroup": {
"zarr_format": 2
},
"links/.zattrs": {
"buckets/bucket2/.zattrs": {
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "7f8154fa-8bdb-407d-9173-3653cbb3229e"
},
"buckets/bucket2/.zgroup": {
"zarr_format": 2
},
"buckets/bucket2/foo_holder/.zgroup": {
"zarr_format": 2
},
"buckets/bucket2/foo_holder/foo2/.zattrs": {
"attr1": "I am foo2",
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "4bf361c1-b731-4f2c-8b53-22aab97d5276",
"zarr_link": [
{
"name": "foo_link",
"path": "/buckets/bucket1/foo_holder/foo1",
"source": "test_io0.zarr"
"name": "my_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
},
"buckets/bucket2/foo_holder/foo2/.zgroup": {
"zarr_format": 2
},
"links/.zgroup": {
"zarr_format": 2
}
Expand Down
5 changes: 5 additions & 0 deletions test_io2.zarr/buckets/bucket2/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "7f8154fa-8bdb-407d-9173-3653cbb3229e"
}
3 changes: 3 additions & 0 deletions test_io2.zarr/buckets/bucket2/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
3 changes: 3 additions & 0 deletions test_io2.zarr/buckets/bucket2/foo_holder/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
14 changes: 14 additions & 0 deletions test_io2.zarr/buckets/bucket2/foo_holder/foo2/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"attr1": "I am foo2",
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "4bf361c1-b731-4f2c-8b53-22aab97d5276",
"zarr_link": [
{
"name": "my_data",
"path": "/buckets/bucket1/foo_holder/foo1/my_data",
"source": "/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr"
}
]
}
3 changes: 3 additions & 0 deletions test_io2.zarr/buckets/bucket2/foo_holder/foo2/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
9 changes: 0 additions & 9 deletions test_io2.zarr/links/.zattrs

This file was deleted.

Loading

0 comments on commit 417672f

Please sign in to comment.