Skip to content

Commit

Permalink
Fix soft link for datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed Oct 14, 2024
1 parent 65491bf commit b3e4a8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lindi/LindiH5pyFile/LindiH5pyGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ def __getitem__(self, name):
"Accessing a group is done with bytes or str, "
"not {}".format(type(name))
)
if isinstance(x, zarr.Group):
# follow the link if this is a soft link
# check for soft link
if isinstance(x, zarr.Group) or isinstance(x, zarr.Array):
soft_link = x.attrs.get('_SOFT_LINK', None)
if soft_link is not None:
# follow the link if this is a soft link
link_path = soft_link['path']
target_item = self._file.get(link_path)
if not isinstance(target_item, (LindiH5pyGroup, LindiH5pyDataset)):
raise Exception(
f"Expected a group or dataset at {link_path} but got {type(target_item)}"
)
return target_item

if isinstance(x, zarr.Group):
return LindiH5pyGroup(x, self._file)
elif isinstance(x, zarr.Array):
return LindiH5pyDataset(x, self._file)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lindi"
version = "0.4.2"
version = "0.4.3"
description = ""
authors = [
"Jeremy Magland <[email protected]>",
Expand Down

0 comments on commit b3e4a8e

Please sign in to comment.