-
Notifications
You must be signed in to change notification settings - Fork 26
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
_gather_columns agnostic search #991
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #991 +/- ##
==========================================
- Coverage 88.65% 88.65% -0.01%
==========================================
Files 45 45
Lines 9451 9458 +7
Branches 2688 2691 +3
==========================================
+ Hits 8379 8385 +6
Misses 757 757
- Partials 315 316 +1
☔ View full report in Codecov by Sentry. |
Fix #959 |
@rly Proof of concept. This passes the "test" of the extension now works. |
Co-authored-by: Ryan Ly <[email protected]>
I think the for loop should break upon finding a class that has This also raises an issue where a column in Class B might overwrite a column in Class A. We don't want to add the same column twice during the prepending. We should add logic to check for that in this block of code, but perhaps in a separate PR. |
I'll give it a gander. This was just to get our initial idea out in practice. |
Understood and sounds good. |
Co-authored-by: Ryan Ly <[email protected]>
@rly Taking a gander and wanted to confirm some thoughts. PyNWB has PlaneSegmentation and that is a subclass of DynamicTable. The extension has PlaneExtension, which extends PlaneSegmentation. When writing a NWBFile from the extension, the class defined in the extension is used. However, when running the nwbinspector, it does not see the class but just the schema (not clear how). This leads hdmf to autogenerate the class. In a testing case, Class A is PlaneSegmentation, Class B is PlaneExtension, and Class C is an extension of Class B with generated columns. You say "prepend" meaning I should use add_column to Class C and verify that it doesn't affect the columns in class A? By not defining the columns in class C, that should trigger them to be autogenerated to match B correct? But that would require a schema |
By prepend, I am referring to line 287 in the new code. I mean that the gather_columns method should add the columns in class A once not twice because those columns were also added to class B.
Yes, if class C does not add or change any columns, then the |
Do you mean add the columns "from" class A to class B? |
Gather columns should copy the columns from class A to class B, and from class B to class C, but because class B contains class A's columns, gather_columns should not additionally copy columns from class A to class C, or else class A's columns will be in class C twice. |
Class A's columns would be in Class C via Class B. |
for more information, see https://pre-commit.ci
Co-authored-by: Ryan Ly <[email protected]>
Looks good to me. Thanks! |
Motivation
What was the reasoning behind this change? Please explain the changes briefly.
Within DynamicTable is a pre-init method _gather_columns that uses the base classes in a conditional to create pre-defined columns. When autogenerating a class, the order of these classes are determined in classgenerator.py
This results in an issue for an extension that use the nwbinspector to validate the NWBFile. The best fix is to make the search in _gather_columns agnostic to the order.
How to test the behavior?
Checklist
ruff
from the source directory.