-
Notifications
You must be signed in to change notification settings - Fork 21
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
[Backend Configuration IVa] Add backend control to context tool #800
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest a possible and small improvement to the error function but this looks OK.
Side comment:
Every time that I look at the make_or_load_nwbfile
I feel that it could be simplified. Even on the name is doing too many things and the control flow at the end looks very complicated. Maybe there is no better way here if we want a context manager.
I don't know if auto merge is set. I will first figure that one out.
Yeah, we wanted a context manager, and we wanted to reduce duplicated code since all the complexity of that function was previously sharded across the entire library The most I could reduce it now is perhaps to split the 'make' and 'load' parts to separate contexts |
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #800 +/- ##
==========================================
- Coverage 91.38% 91.37% -0.01%
==========================================
Files 121 121
Lines 6300 6308 +8
==========================================
+ Hits 5757 5764 +7
- Misses 543 544 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this.
The most I could reduce it now is perhaps to split the 'make' and 'load' parts to separate contexts
Yes, I think the make part does not really require a context manager, right? I feel the main responsability of this -and its most common use- is to write. But I think that mos of the complexity comes from the loading to append part.
Relevant to the discussion in #801
The context is to trigger write after making or loading; so they would still be |
or passing a in-memory nwbfile, right? the commontality is still writing I feel. I just opened the function to confirm that we have the I copied the code to illustrate this, I thought about it another half a minute and I can't figure out which branch do I go when I passed an nwbfile. I think is the first yield? Oh, no, the path is optional, which means that it does not neceesarily write. OK, forget about it. I am confused.
|
Yes, perhaps a third function |
Creation of an nwbfile does not require a context manager unless it is opened for append mode, right? Writing on the other hand does always benefit for it so the Maybe the open and append is one of the valid use case for nested context managers: https://discuss.codecademy.com/t/faq-context-managers-nested-context-managers/601741/2 But that could end up looking worse. No idea. |
Hence why I'd have A double context could be used in |
Makes sense to me. But would it make more sense for the first to be |
Sure, though that could also be interpreted as 'read from source and write to destination' (mode="r") instead of 'read from source and rewrite to same source' (mode="a"/"r+", explicit name being 'append') |
To be honest, I kind of though that we could do the first but that does not work because we only have one path argument anyway. |
Breaking up the integration into the core classes into smaller pieces
This is the first step - adding
backend
keyword and functionality into the context tool used to write the majority of NWB files through NeuroConv