Skip to content
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

[Feature]: Raise warning when a container is not written because it does not map to a spec #1090

Open
rly opened this issue Apr 2, 2024 · 1 comment
Assignees
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)

Comments

@rly
Copy link
Contributor

rly commented Apr 2, 2024

What would you like to see added to HDMF?

When writing extension data, it is easy to create an NWBFile or other container hierarchy with containers that the user thinks maps to a particular part of the extension schema but it doesn't because it is named something else or placed somewhere else. If the container is required according to the spec, then an error is raised. However, sometimes the container is optional. In that case, an error is not raised and the container is silently not written.

Example. The schema says:

groups:
- neurodata_type_def: MyContainer
  neurodata_type_inc: NWBDataInterface
  doc: ...
  datasets:
  - name: units
    neurodata_type_inc: DynamicTableRegion
    dims:
    - number_of_units
    shape:
    - null
    doc: A reference to the Units table region that contains the units of the data.
    quantity: '?' 

The PyNWB code involves creating a container of class MyContainer but putting a DynamicTableRegion named units_region in it. The name does not match the fixed name units in the spec that would allow HDMF to map the DynamicTableRegion object to the units spec. No error is raised and the user is confused as to why their DynamicTableRegion was not written.

What solution would you like?

When writing containers, we currently go through the spec and pull out the attributes in the container that correspond to the spec. We should also go the other way. Iterate through the children of the container and maybe also all the public attributes and make sure that they all map to something in the spec or are written. Warn if not.

cc @h-mayorquin

Do you have any interest in helping implement the feature?

Yes.

@rly rly added category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s) labels Apr 2, 2024
@h-mayorquin
Copy link
Contributor

Thanks, @rly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)
Projects
None yet
Development

No branches or pull requests

2 participants