Skip to content

Remove classes from extractor and preprocessing __init__ #3898

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

Merged
merged 34 commits into from
Jun 3, 2025

Conversation

zm711
Copy link
Member

@zm711 zm711 commented May 2, 2025

I went with the hard ones to start with hahah. I figured a lot of the other ones would be easier to do. Let me know what you think about this strategy.

For preprocessors this changes nothing-- it just ensures that the class and function are lined up and then only imports the functions. Example here:
image

For extractors this is much harder and makes one potentially controversial change. When we convert from class to function we were keeping the name of the class (in the python sense not in a class attribute sense, but to make this work we need to change the class name to be the read_function name. Since we want our users to only see the function I think this should be fine, but maybe someone is super against this. Or maybe we make the wrapper function a bit more complex like for the dict example that @chrishalcrow did? I think keeping the name is probably better for provenance actually.

Small example here:
image

@zm711
Copy link
Member Author

zm711 commented May 2, 2025

I'll fix the other imports :) I should have know we were using classes internally rather than the functions.... I just tested locally with importing extractors and preprocessors. But let me know if people are okay with this before I make a million more tweaks :)

Copy link
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many things that I don't remember about the importing system so my comments are questions more than requests.

Suggestions:
I think if we want to make change easier for people that relied on the class names we can create something like the extractor_list but with a more explicit names

extractor_classees?

So instead of:

from spikeinterface.extractors import AnExtractror`

they do:

from spikeinterface.extractors.extractor_classes import AnExtractor

Seems like an easy change to make that would also allow us to keep the privilege naming that you guys want (the read_extractor functions) as the unique access at spikeinterface.extractors.


# NWB sorting/recording/event
from .nwbextractors import (
NwbRecordingExtractor,
NwbSortingExtractor,
NwbTimeSeriesExtractor,
NwbTimeSeriesExtractor, # @Heberto/Alessio what do we do with this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a class read_nwb_timeseries or something like that?

Or what is the question?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never use these functions so I just wasn't sure if I should make a read_nwb_timeseries so that answers that question. The other question was is that an event extractor or something else? and should I just list read_nwb for all of them or should I give each one separately?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, is a recording extractor for different type of data.

Also, do not listen read_nwb, I don't think it behaves like all those other functions and is not well maintained.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I not be using read_nwb?? It's what I use to test that our labs nwb files are working as expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good from my end. I'll expose read_nwb but won't preference. :) Best of luck Chris :)

@zm711
Copy link
Member Author

zm711 commented May 3, 2025

There are many things that I don't remember about the importing system so my comments are questions more than requests.

Suggestions: I think if we want to make change easier for people that relied on the class names we can create something like the extractor_list but with a more explicit names

extractor_classees?

So instead of:

from spikeinterface.extractors import AnExtractror`

they do:

from spikeinterface.extractors.extractor_classes import AnExtractor

Seems like an easy change to make that would also allow us to keep the privilege naming that you guys want (the read_extractor functions) as the unique access at spikeinterface.extractors.

I like this. I would be happy to change the file name and switch to extractor classes to make this clear as long as @alejoe91 and @samuelgarcia are okay with that :)

@alejoe91 alejoe91 added refactor Refactor of code, with no change to functionality packaging Related to packaging/style labels May 3, 2025
* Heberto discussion for nwb_timeseries
* Alessio for how the full_dict should work
hopefully I fixed all the files, but the CI will tell me.
Copy link
Member Author

@zm711 zm711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing extractor class change

Copy link
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the tests suite on neuroconv and it is working. Let me know when it is ready so I can run them again.

# the warning and then returns the "function" version which will look the same
# to the end-user
# to be removed after version 0.105.0
def __getattr__(extractor_name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, you are doing very sophisticated stuff. Maybe too much for me but I really admire.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a pain to get working. But Heberto makes a great point that we don't want to pull the rug out from under our devs who build off of spikeinterface. So we warn them for a couple versions then wee can clean this all up.

@samuelgarcia
Copy link
Member

Vous êtes tous incroyables!
Merci beaucoup pour ce grand nettoyage.
I totaly trust all of you on this.
You can merge when you want.

@chrishalcrow
Copy link
Member

Been using the preprocessing imports from this PR when developing #3438 and they work a treat. So all good from me :)

@zm711
Copy link
Member Author

zm711 commented Jun 3, 2025

Last thing we need is for @h-mayorquin to run neuroconv testing suite one more time to make sure I didn't make a mistake when converting the nested dict. Then once testing is fixed I think I'm done with this!

@alejoe91
Copy link
Member

alejoe91 commented Jun 3, 2025

LGTM! You can merge when you want @h-mayorquin @zm711

@h-mayorquin
Copy link
Collaborator

OK, for me.

Copy link
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@h-mayorquin h-mayorquin merged commit 604c049 into SpikeInterface:main Jun 3, 2025
15 checks passed
@zm711 zm711 deleted the remove-class branch June 3, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packaging Related to packaging/style refactor Refactor of code, with no change to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants