Skip to content

writing to MultiContainerInterface extension results in orphaned container #556

Open
@bendichter

Description

@bendichter

Am I doing this wrong? I may be doing this wrong. Here's the minimal example:

from pynwb.spec import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec
from pynwb import load_namespaces, NWBFile, NWBHDF5IO, get_class


ext_name = 'test_ext'
ns_path = ext_name + ".namespace.yaml"
ext_source = ext_name + ".extensions.yaml"

elem = NWBGroupSpec(neurodata_type_inc='NWBDataInterface',
                    neurodata_type_def='Elem',
                    quantity='+',
                    doc='doc',
                    attributes=[NWBAttributeSpec(name='data', doc='data',
                                                 dtype='double', required=True)])

grouper = NWBGroupSpec(neurodata_type_inc='NWBDataInterface',
                       neurodata_type_def='Grouper',
                       quantity='?',
                       doc='doc',
                       groups=[elem])

ns_builder = NWBNamespaceBuilder(ext_name + ' extensions', ext_name)

ns_builder.add_spec(ext_source, grouper)
ns_builder.export(ns_path)
load_namespaces(ns_path)

Grouper = get_class('Grouper', ext_name)
Elem = get_class('Elem', ext_name)

elem = Elem(data=2.0, name='elem', source='source')
group = Grouper(elems=elem, name='group', source='source')

nwbfile = NWBFile("source", "a file with header data", "NB123A", '2018-06-01T00:00:00')
mod = nwbfile.create_processing_module(name='module', source='source', 
                                       description='description')

mod.add_container(group)

with NWBHDF5IO('test_group.nwb', 'w') as io:
    io.write(nwbfile)

Using HDFView, there is no elem, and no elem.data. Same issue if I write the Grouper class myself.

Metadata

Metadata

Labels

topic: extensionissues related to extensions or dynamic class generation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions