-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make NWBFile
groups optional :)
#592
Comments
Just to avoid confusion, I believe the parameters indicated here only mean that a user does not need to specify any contents to be stored in the groups. As far as I know, PyNWB still treats these groups as required and will generate empty groups if the user does not specify any contents. I.e., as far as I know, PyNWB (and MatNWB) indeed treat these groups as required.
In general, I think it is reasonable to make groups that have no required contents optional. @rly @bendichter thoughts? |
I don't think you are missing anything here. I thought some fields in
Since the top-level groups do not have their own type, they are represented in the API by
If the
I'd like to hear from others what their thoughts are on making the top-level groups optional. I'm not opposed to the change, but I'm not sure right now whether this may open a hornets nest of downstream issues. I think the main complicating factor is probably the flexibility this adds, e.g., I'm not sure if/which tools may be relying on the fact that these groups exist (even if they are empty). @bendichter, @rly what do you think? |
right right, just an API implementation detail like how pynwb does it. i think the file object is the only place where this needs special handling, so i'll just document that. I'd be curious too - wonder how many downstream impls directly interact with the HDF5 file rather than through pynwb |
I'd be in favor of with making top-level groups like aquisition and processing optional. I don't like having empty groups. It seems like it should be a simple change, but it may be trickier than it seems. |
I agree with @bendichter . Having empty groups is confusing and inelegant, particularly when browsing |
Currently, many of the top-level items in
NWBFile
are explicitly optional (quantity
is either*
or?
), and several can be interpreted as being optional, but there is a little bit of inconsistency that is awkward here:Here's the current status of
quantity
forNWBFile.groups
:(where
null == 1
by default).Some of these can be interpreted as being optional, eg. groups like
processing
consist of only*
-quantitied groups, so I am treating those asOptional[Dict[str, ProcessingModule]]
: https://github.com/p2p-ld/nwb-linkml/blob/77a852913c0ae036ca7285a3e5e5dc04fa3e8954/nwb_models/src/nwb_models/models/pydantic/core/v2_7_0/core_nwb_file.py#L258But others, in particular
general
andstimulus
would be much harder to make that inference for, and it's enough of a special case that i'd prefer not to do it. For both of those, all of their (recursive) child groups are optional, so it makes sense to also make them optional.This is already how
pynwb
behaves for thenull
-aka-1
-quantitied groups:acquisition
is explicitly optional: https://github.com/NeurodataWithoutBorders/pynwb/blob/e938202b257e44c5536dc35476d55aa98e57d18d/src/pynwb/file.py#L354analysis
is explicitly optional: https://github.com/NeurodataWithoutBorders/pynwb/blob/e938202b257e44c5536dc35476d55aa98e57d18d/src/pynwb/file.py#L356pynwb
currently does not representgeneral
as a separate object and has all of its groups and subgroups unpacked in thedocval
signature and maps them back intogeneral
in theNWBFileMap
, soNWBFile.general
is technically optional because it doesn't exist as a discrete type.processing
is explicitly optional: https://github.com/NeurodataWithoutBorders/pynwb/blob/e938202b257e44c5536dc35476d55aa98e57d18d/src/pynwb/file.py#L373stimulus
is explicitly optional: https://github.com/NeurodataWithoutBorders/pynwb/blob/e938202b257e44c5536dc35476d55aa98e57d18d/src/pynwb/file.py#L359So it would be nice to make the rest of the groups quantity
?
to make that behavior~schema official~
, because at the moment requiringgeneral
andstimulus
is technically correct behavior, even if all of their params are optional (and i don't think there's a syntactic construct in nwb schema language for "the default value is an empty instance of this class").The text was updated successfully, but these errors were encountered: