Skip to content

Commit

Permalink
implemented builder-based fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Dec 4, 2024
1 parent 9fb42ee commit 5298401
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import pynwb
import zarr
from hdmf import Container
from hdmf.build.builders import (
DatasetBuilder,
GroupBuilder,
)
from hdmf.utils import get_data_shape
from pydantic import (
BaseModel,
Expand Down Expand Up @@ -262,16 +266,14 @@ def from_neurodata_object(cls, neurodata_object: Container, dataset_name: Litera
candidate_dataset = getattr(neurodata_object, dataset_name)

manager = pynwb.get_manager()
namespace_catalog = manager.type_map.namespace_catalog
for namespace in namespace_catalog.namespaces:
try:
spec = namespace_catalog.get_spec(namespace, neurodata_object.parent.neurodata_type)
break
except ValueError:
continue
spec = spec.get_dataset(neurodata_object.name)
spec = spec if spec is not None else {}
dtype = spec.get("dtype", None)
builder = manager.build(neurodata_object)
if isinstance(builder, GroupBuilder):
dtype = builder.datasets[dataset_name].dtype
elif isinstance(builder, DatasetBuilder):
dtype = builder.dtype
else:
raise NotImplementedError(f"Builder Type {type(builder)} not supported!")

if isinstance(dtype, list): # compound dtype
full_shape = (len(candidate_dataset),)
else:
Expand Down

0 comments on commit 5298401

Please sign in to comment.