-
Notifications
You must be signed in to change notification settings - Fork 64
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
added lazy loading option for nwb loading function #313
Conversation
Reading your questions makes me thinks there should be a |
Alternatively, the |
I would vote for the second option ("mmap_mode") so that people do not have to remember two different commands for loading. I think it looks cleaner. |
@BalzaniEdoardo I do not know your current preferred usage of the package (for I don't mind particularly, happy to evolve this PR in either direction, but from a design POV what @gviejo proposed (split and deprecate) feels definitively cleaner |
I think best decision here is to give us minimal work. I would choose to keep a single |
Ok! what about default of lazy mode then? |
Ok so default is None and you go by default for lazy loading for NWB and not for NPZ. Changing this to True or False forces the behavior. |
Ok! Everything can be very streamlined if we move the constructors from the file to be class methods of each relative object. I think this makes lot of sense as it binds more tightly together the |
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.
This is a good idea, but I think having a class method for each object is too much. I think we should have a single method for all the time-series, implemented in Base
.
I added the code in the comments but it should look something like this
@classmethod
def _from_npz_reader(cls, file)
kwargs = {key: val for key, val in file.items() if key not in ["start", "end", "type"]}
iset = nap.IntervalSet(start=file["start"], end=file["end"])
return cls(time_support=iset, **kwargs)
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 think you should add tests to the npz loader to check that npz could be memmapped for real. my worry is that the memmap
parameter of load will be ignored for npz
, but this needs to be tested.
Independently, I still think the classmethod
for loading the time series is quite elegant, and can simplify the io.interface_npz.py
.
All the interface has to do is figure out the type, and call the class method.
This should be done! Alas, no lazy mode for The interface looks cleaner now, so, it was not for nothing :) A note: I am not sure to which degree there should be support for |
Co-authored-by: Guillaume Viejo <[email protected]>
Co-authored-by: Guillaume Viejo <[email protected]>
Ok, everything should be good now! Let me know about that point on the deprecation, if you want I can add the warning in this PR. Otherwise should be ready for merging |
Thanks Luigi |
I think you are right about that, the type parameters should be deprecated
and removed.
…On Wed, Jul 17, 2024, 5:15 PM Luigi Petrucco ***@***.***> wrote:
Ok, everything should be good now!
Let me know about that point on the deprecation, if you want I can add the
warning in this PR. Otherwise should be ready for merging
—
Reply to this email directly, view it on GitHub
<#313 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG2MOS37RZAYLO4UQCDSVILZM3NFZAVCNFSM6AAAAABK35R7LGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZUGMZDKMBZGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I was missing the option of changing the lazy loading behavior of NWB files when going through the function. This PR is a very minimal parameter piping from the function to the underlying
NWBFile
object instantiation.More general question about this function, for which I lack the broader context of where the package is going: it sounds funny to have the same function for such different constructs: on the one side, nwb files which are equivalent to whole collections of Tsds/TsdFrames/TsdTensors, on the other, npc files which from what I understand contain individually one of those items and as a consequence lacks a
lazy_loading
behavior (even though that could be implemented by returning the object and not the object.load() output; but this would either change the current default forload_file()
on the NWB, by default true, and for the npz file, by default false).Let me know what do you think about this!