Open t-b opened 4 years ago
thanks @t-b. Unfortunately, I think this is a fundamental limitation of our current implementation of get_class
. Would be interesting to discuss a solution to this for get_class
, but for now you'll have to specify the API manually in these cases.
BTW, eliminating nested definitions in the schema should not change it in an incompatible way as it typically just means placing the type definitions at the top level and then using neurodata_type_inc
to include them in the proper places.
@bendichter I'm not sure I'll find time to write custom code for that.
@oruebel This is not the usual nested spec problem.
From the posted link above
stimset_referenced_folder = NWBGroupSpec(doc='Folder',
neurodata_type_def='StimulusSetReferencedFolder',
datasets=[...],
groups=[NWBGroupSpec(doc='Nested Folder',
neurodata_type_inc='StimulusSetReferencedFolder',
quantity='*')
],
)
which means that the group spec contains itself recursively. And get_class
chokes on that. I don't see a way to rewrite that.
If this were a simple recursion where type A can contain one instance of type A, then I have a solution that involves some changes in HDMF. However, this is more complicated in that type A can contain multiple instances of type A, which results in the automatic generation of a MultiContainerInterface
subclass. I have tried a couple different approaches and it looks like changing get_class
to handle this use case will be pretty involved. I will have to get back to this in a few days.
This also reveals another bug where it is not possible to generate classes that are MultiContainerInterface
where the base class is a class that has fields beyond just a name.
@rly Is it possible to write a custom class for StimulusSetReferencedFolder?
I'm trying to add some get_class defaults for ndx-MIES as requested by @rly in https://github.com/nwb-extensions/staged-extensions/pull/15.
But it fails on the recursive type definition:
https://github.com/t-b/ndx-MIES/blob/5e91258312b835aab87942d336081cec37192f86/src/spec/create_extension_spec.py#L55-L67
Versions: pynwb 1.4.0 hdmf 2.2.0
Reproducable example:
Output:
Just to be clear, there is data released with this extension already, so I can not change the extension schema in an incompatible way.