-
Notifications
You must be signed in to change notification settings - Fork 190
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
Proposal for auto import extensions module. #2571
Proposal for auto import extensions module. #2571
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
if extension_name in _builtin_extensions: | ||
module = _builtin_extensions[extension_name] | ||
if autoload: | ||
print(f"module '{module}' is imported automatically for extension '{extension_name}'") |
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.
print(f"module '{module}' is imported automatically for extension '{extension_name}'") |
should we remove the print?
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 it is good to have a message for auto loading no ?
Maybe a warning
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.
not sure
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'm torn here... If someone requests this functionality they should expect us to import what is needed to do the operation right? I guess the concern would be some sort of namespace clash? Like if we run an extractor the user expects a read operation from a file, we don't explicitly say we are creating a memmap which may lead to RAM exhaustion. On the other hand people complain about things failing silently for the job_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.
The extractors example is a very good point. If someone saves a JSON file with dump_to_json
, all the modules from extractors
, preprocessing
, etc. will be loaded.
In that case, we store the path to the class so imports are minimal.
Maybe we could do the same here? e.g.
_builtin_extensions = {
"spike_amplitudes": "spikeinterface.postprocessing.spike_amplitudes.SpikeAmplitudeExtension",
...
}
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 it should be removed. What is the user supposed to do with this information?
This sounds more like logging and when it is output by default the convention is to print to standard error as far as I am aware. So a warning. But I personally think that warnings should be actionable so not even sure about that one.
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.
As long as you're okay with autoload then this seems good to me. I can also test locally this afternoon. Otherwise, I think just the additional error messaging is much improved.
if extension_name in _builtin_extensions: | ||
module = _builtin_extensions[extension_name] | ||
if autoload: | ||
print(f"module '{module}' is imported automatically for extension '{extension_name}'") |
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'm torn here... If someone requests this functionality they should expect us to import what is needed to do the operation right? I guess the concern would be some sort of namespace clash? Like if we run an extractor the user expects a read operation from a file, we don't explicitly say we are creating a memmap which may lead to RAM exhaustion. On the other hand people complain about things failing silently for the job_kwargs.
Also I never get to the print statement we were discussing above (L1082). |
Oups. My bad I tested the compute() let me finish this correctly. |
Happy to test |
for more information, see https://pre-commit.ci
…terface into extension_auto_load
Tested both |
Co-authored-by: Zach McKenzie <[email protected]> Co-authored-by: Alessio Buccino <[email protected]>
Hi @zm711 @alejoe91.
This is proposal to auto load extensions : when extension is builin and not registered because not impotred yet : then we have an auto load mechanism. This should help the end user.
Tell me what you think.
This is hard to be tested in core tests because it auload submodules which will fail on core testing because of dependencies.
So I made local tests and it works.
This should fix partially #2560.