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

Change: Only embed specs/namespaces for types that are included in NWB file on export #615

Open
wants to merge 63 commits into
base: main
Choose a base branch
from

Conversation

ehennestad
Copy link
Collaborator

@ehennestad ehennestad commented Nov 4, 2024

Fix #607

Motivation

Ensure that only relevant namespaces/specifications are embedded in an NWB file. This issue suggests that such extra namespaces can cause errors when validating with NWBInspector.

How to test the behavior?

Export NWB file with types from a subset of available extension and check the file's `specification` group

Questions / todo

  • Are namespace names always specified in kebab-case? - Appears so
  •  Does matnwb always format namespace names as snake_case? - Appears so
  • Should the specification group be completely cleared before rewriting it if exporting to an existing file?
  • Check superclasses of each type and included namespace of superclasses as well
  • Add unit test

Checklist

  • Have you ensured the PR description clearly describes the problem and solutions?
  • Have you checked to ensure that there aren't other open or previously closed Pull Requests for the same change?
  • If this PR fixes an issue, is the first line of the PR description fix #XX where XX is the issue number?

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 97.67442% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.44%. Comparing base (30bf24d) to head (dc18c57).

Files with missing lines Patch % Lines
+io/+internal/+h5/resolveFileReference.m 87.50% 1 Missing ⚠️
+schemes/+utility/listNwbTypeHierarchy.m 87.50% 1 Missing ⚠️
NwbFile.m 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #615      +/-   ##
==========================================
+ Coverage   95.27%   95.44%   +0.17%     
==========================================
  Files         124      137      +13     
  Lines        5139     5265     +126     
==========================================
+ Hits         4896     5025     +129     
+ Misses        243      240       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ehennestad ehennestad changed the title Change: Only include namespaces for types that are included in NWB file on export Change: Only embed specs/namespaces for types that are included in NWB file on export Nov 6, 2024
Add utility function for listing the type hierarchy of an nwb type
Add schedule event for workflow to update nwbInstallExtension
@ehennestad ehennestad marked this pull request as ready for review January 16, 2025 17:05
@@ -0,0 +1,16 @@
function deleteGroup(fileReference, groupLocation)
% deleteGroup - Delete the specified group from an NWB file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a big deal that way this is used here, but note that deleting groups and datasets from an HDF5 file does not free up the space

@bendichter
Copy link
Contributor

There are lots of new functions here that lack unit tests

@ehennestad
Copy link
Collaborator Author

There are lots of new functions here that lack unit tests

@bendichter Added unit tests for those functions

@bendichter
Copy link
Contributor

This seems quite complicated. Can you describe your general strategy here? I would think we could keep track of the namespaces used as we add neurodata objects to an NWB file and then only save the file with those namespaces. It looks here like you are doing a lot of manipulation on the HDF5 level. Can you help me understand this approach before I dig in?

@ehennestad
Copy link
Collaborator Author

ehennestad commented Feb 1, 2025

This seems quite complicated. Can you describe your general strategy here? I would think we could keep track of the namespaces used as we add neurodata objects to an NWB file and then only save the file with those namespaces. It looks here like you are doing a lot of manipulation on the HDF5 level. Can you help me understand this approach before I dig in?

Please see the above comment/review.

Also see the docstring of io.spec.validateEmbeddedSpecifications for expanations of the HDF5 manipulations (i.e deleting groups)

Most of this PR is convenience functions. I added them to the io.internal.h5 namespace in anticipation of adding Zarr-functionality down the road

Added comments and a better test to test for warning with ID 'NWB:validators:MissingEmbeddedNamespace'
@ehennestad
Copy link
Collaborator Author

@bendichter I updated the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Improve embedding of namespaces on nwbExport
2 participants