-
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
Post init option for class generator #1089
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #1089 +/- ##
==========================================
+ Coverage 88.70% 88.71% +0.01%
==========================================
Files 45 45
Lines 9745 9760 +15
Branches 2767 2771 +4
==========================================
+ Hits 8644 8659 +15
Misses 779 779
Partials 322 322 ☔ View full report in Codecov by Sentry. |
The concept looks good to me |
The approach looks good to me too |
Note that you will have to be careful with methods vs functions here. It seems like the |
@rly I still need to add the post init to the MCIClassGenerator, but I have a new proof of concept and a test that works. |
@rly I was wrapping this up with test on the MCIClassGenerator, adding post_init to the init method defined in set_init. What's weird is my test I see that MCIClassGenerator inherits from CustomClassGenerator, but the set_init function in MCIClassGenerator should override. It does (see above) but not in a way I expect. Thoughts? |
In https://github.com/hdmf-dev/hdmf/blob/dev/src/hdmf/build/classgenerator.py old line 334, the |
I actually think its from old line 440. With MCIGenerator caling the init within CustomGenerator, do we only want to run the post init for MCIGenerator after the outer init (the init in MCI) and not the inner init? |
You're right - I was looking at the wrong class there. I would say after the outer init. |
@rly take a look when you can. I need figure out a way to solve the duplication problem in docval. I believe what is happening is that if we generate class A and class B (which inherits from A), it uses the same docval in the set_init method. This duplicates the post_init_bool because |
I see. The approach feels a bit hacky but I cannot think of a better approach. One idea is that when getting the parent class' docval args, you can remove |
Yeah that makes sense. I'm going to push this idea forward and make update tests. |
I will shoot to wrap this up tomorrow since it is very close and we have an agreed idea@rly |
@rly This should be good to go. I am going to do another pass before I request review. However, I wanted to note that the tutorial on this functionality makes more sense to me to be in the extension template, rather than here. What do you think? |
Let's document this in the NWB extensions tutorial rather than here https://nwb-overview.readthedocs.io/en/latest/extensions_tutorial/extensions_tutorial_home.html. We could do it in the template, but I would consider this more of an advanced feature. |
Let's talk about some details:
|
This reverts commit 201b8c4.
Looks good to me. Thanks! |
@h-mayorquin |
Thanks, yes, I saw that you added, I will give it a test in the following weeks : ) |
Motivation
What was the reasoning behind this change? Please explain the changes briefly.
Fix #1072
Add optional post init method for get_class (class generation for extensions)
How to test the behavior?
Checklist
CHANGELOG.md
with your changes?