Skip to content

Commit

Permalink
some support for groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Oct 16, 2024
1 parent 05d3616 commit 24ce06c
Show file tree
Hide file tree
Showing 26 changed files with 1,663 additions and 168 deletions.
132 changes: 79 additions & 53 deletions src/hdmf_zarr/backend.py

Large diffs are not rendered by default.

1,503 changes: 1,503 additions & 0 deletions src/hdmf_zarr/backend2.py

Large diffs are not rendered by default.

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": "9b13a8b3-2851-451f-baf9-873182f8a674"
"object_id": "27d9b554-421a-4cb7-8c24-66b5747b86df"
}
15 changes: 3 additions & 12 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": "9b13a8b3-2851-451f-baf9-873182f8a674"
"object_id": "27d9b554-421a-4cb7-8c24-66b5747b86df"
},
".zgroup": {
"zarr_format": 2
Expand All @@ -14,7 +14,7 @@
"buckets/bucket1/.zattrs": {
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "67435668-7f5b-4c98-9200-65840eca9958"
"object_id": "464e00d7-11dd-4466-afda-def0b44bb2c9"
},
"buckets/bucket1/.zgroup": {
"zarr_format": 2
Expand All @@ -27,7 +27,7 @@
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "a6d08cb5-1eee-437f-bdac-99dffb93ceea"
"object_id": "4ad02d31-07cf-4b31-ab8b-eecca3ffb26d"
},
"buckets/bucket1/foo_holder/foo1/.zgroup": {
"zarr_format": 2
Expand Down Expand Up @@ -56,15 +56,6 @@
"attr2": 17,
"zarr_dtype": "int64"
},
"links/.zattrs": {
"zarr_link": [
{
"name": "foo_link",
"path": "/buckets/bucket1/foo_holder/foo1",
"source": "test_io0.zarr"
}
]
},
"links/.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": "67435668-7f5b-4c98-9200-65840eca9958"
"object_id": "464e00d7-11dd-4466-afda-def0b44bb2c9"
}
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": "a6d08cb5-1eee-437f-bdac-99dffb93ceea"
"object_id": "4ad02d31-07cf-4b31-ab8b-eecca3ffb26d"
}
9 changes: 0 additions & 9 deletions test_io0.zarr/links/.zattrs

This file was deleted.

2 changes: 1 addition & 1 deletion test_io1.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": "9b13a8b3-2851-451f-baf9-873182f8a674"
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
}
47 changes: 1 addition & 46 deletions test_io1.zarr/.zmetadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,14 @@
".zattrs": {
"data_type": "FooFile",
"namespace": "test_core",
"object_id": "9b13a8b3-2851-451f-baf9-873182f8a674"
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
},
".zgroup": {
"zarr_format": 2
},
"buckets/.zgroup": {
"zarr_format": 2
},
"buckets/bucket1/.zattrs": {
"data_type": "FooBucket",
"namespace": "test_core",
"object_id": "67435668-7f5b-4c98-9200-65840eca9958"
},
"buckets/bucket1/.zgroup": {
"zarr_format": 2
},
"buckets/bucket1/foo_holder/.zgroup": {
"zarr_format": 2
},
"buckets/bucket1/foo_holder/foo1/.zattrs": {
"attr1": "I am foo1",
"attr3": 3.14,
"data_type": "Foo",
"namespace": "test_core",
"object_id": "a6d08cb5-1eee-437f-bdac-99dffb93ceea"
},
"buckets/bucket1/foo_holder/foo1/.zgroup": {
"zarr_format": 2
},
"buckets/bucket1/foo_holder/foo1/my_data/.zarray": {
"chunks": [
5
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<i8",
"fill_value": 0,
"filters": null,
"order": "C",
"shape": [
5
],
"zarr_format": 2
},
"buckets/bucket1/foo_holder/foo1/my_data/.zattrs": {
"attr2": 17,
"zarr_dtype": "int64"
},
"links/.zattrs": {
"zarr_link": [
{
Expand Down
5 changes: 0 additions & 5 deletions test_io1.zarr/buckets/bucket1/.zattrs

This file was deleted.

7 changes: 0 additions & 7 deletions test_io1.zarr/buckets/bucket1/foo_holder/foo1/.zattrs

This file was deleted.

3 changes: 0 additions & 3 deletions test_io1.zarr/buckets/bucket1/foo_holder/foo1/.zgroup

This file was deleted.

20 changes: 0 additions & 20 deletions test_io1.zarr/buckets/bucket1/foo_holder/foo1/my_data/.zarray

This file was deleted.

4 changes: 0 additions & 4 deletions test_io1.zarr/buckets/bucket1/foo_holder/foo1/my_data/.zattrs

This file was deleted.

Binary file not shown.
File renamed without changes.
30 changes: 30 additions & 0 deletions test_io1.zarr/specifications/test_core/0.1.0/namespace/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"chunks": [
1
],
"compressor": null,
"dtype": "|O",
"fill_value": 0,
"filters": [
{
"allow_nan": true,
"check_circular": true,
"encoding": "utf-8",
"ensure_ascii": true,
"id": "json2",
"indent": null,
"separators": [
",",
":"
],
"skipkeys": false,
"sort_keys": true,
"strict": true
}
],
"order": "C",
"shape": [
1
],
"zarr_format": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_dtype": "scalar"
}
1 change: 1 addition & 0 deletions test_io1.zarr/specifications/test_core/0.1.0/namespace/0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["{\"namespaces\":[{\"doc\":\"a test namespace\",\"schema\":[{\"source\":\"test\"}],\"name\":\"test_core\",\"version\":\"0.1.0\"}]}","|O",[1]]
30 changes: 30 additions & 0 deletions test_io1.zarr/specifications/test_core/0.1.0/test/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"chunks": [
1
],
"compressor": null,
"dtype": "|O",
"fill_value": 0,
"filters": [
{
"allow_nan": true,
"check_circular": true,
"encoding": "utf-8",
"ensure_ascii": true,
"id": "json2",
"indent": null,
"separators": [
",",
":"
],
"skipkeys": false,
"sort_keys": true,
"strict": true
}
],
"order": "C",
"shape": [
1
],
"zarr_format": 2
}
3 changes: 3 additions & 0 deletions test_io1.zarr/specifications/test_core/0.1.0/test/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_dtype": "scalar"
}
1 change: 1 addition & 0 deletions test_io1.zarr/specifications/test_core/0.1.0/test/0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["{\"groups\":[{\"datasets\":[{\"dtype\":\"int\",\"doc\":\"an example dataset\",\"name\":\"my_data\",\"attributes\":[{\"doc\":\"an example integer attribute\",\"name\":\"attr2\",\"dtype\":\"int\"}]}],\"doc\":\"A test group specification with a data type\",\"data_type_def\":\"Foo\",\"attributes\":[{\"doc\":\"an example string attribute\",\"name\":\"attr1\",\"dtype\":\"text\"},{\"doc\":\"an example float attribute\",\"name\":\"attr3\",\"dtype\":\"float\"}]},{\"groups\":[{\"groups\":[{\"doc\":\"the Foos in this bucket\",\"quantity\":\"*\",\"data_type_inc\":\"Foo\"}],\"doc\":\"A subgroup for Foos\",\"name\":\"foo_holder\"}],\"doc\":\"A test group specification for a data type containing data type\",\"data_type_def\":\"FooBucket\"},{\"groups\":[{\"groups\":[{\"doc\":\"One or more FooBuckets\",\"quantity\":\"*\",\"data_type_inc\":\"FooBucket\"}],\"doc\":\"Holds the FooBuckets\",\"name\":\"buckets\"},{\"links\":[{\"doc\":\"Foo link\",\"name\":\"foo_link\",\"target_type\":\"Foo\",\"quantity\":\"?\"}],\"doc\":\"Foo link group\",\"name\":\"links\"}],\"datasets\":[{\"dtype\":\"int\",\"doc\":\"Foo data\",\"name\":\"foofile_data\",\"quantity\":\"?\"}],\"doc\":\"A file of Foos contained in FooBuckets\",\"data_type_def\":\"FooFile\",\"attributes\":[{\"doc\":\"Foo ref attr\",\"name\":\"foo_ref_attr\",\"required\":false,\"dtype\":{\"target_type\":\"Foo\",\"reftype\":\"object\"}}]}]}","|O",[1]]
2 changes: 1 addition & 1 deletion test_io2.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": "6442cffd-1d1b-4015-b515-8069153279f8"
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
}
2 changes: 1 addition & 1 deletion test_io2.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": "6442cffd-1d1b-4015-b515-8069153279f8"
"object_id": "ac0cd188-78cd-4eeb-a437-52d5ba7062e3"
},
".zgroup": {
"zarr_format": 2
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/base_tests_zarrio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,10 +1125,10 @@ def test_soft_link_group(self):

with ZarrIO("test_io0.zarr", manager=get_foo_buildmanager(), mode='r') as read_io:
with ZarrIO("test_io1.zarr", mode='w') as export_io:
export_io.export(src_io=read_io,
write_args=dict(link_data=False))
export_io.export(src_io=read_io)
with ZarrIO("test_io1.zarr", manager=get_foo_buildmanager(), mode='r') as read_io:
read_foofile2 = read_io.read()
# breakpoint()
# make sure the linked group is within the same file
self.assertEqual(read_foofile2.foo_link.container_source, "test_io1.zarr")
# zarr_linkspec1 = zarr.open(self.store_path[0])['links'].attrs.asdict()['zarr_link'][0]
Expand Down Expand Up @@ -1164,7 +1164,7 @@ def test_external_link_group(self):
with ZarrIO("test_io2.zarr", manager=get_foo_buildmanager(), mode='r') as read_io:
read_foofile2 = read_io.read()
# make sure the linked group is read from the first file
self.assertEqual(read_foofile2.foo_link.container_source, '/Users/mavaylon/Research/NWB/hdmf-zarr/test_io0.zarr')
self.assertEqual(read_foofile2.foo_link.container_source, 'test_io0.zarr')


def test_external_link_dataset(self):
Expand Down

0 comments on commit 24ce06c

Please sign in to comment.