Skip to content
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

FList can't be pickled #88

Closed
ismael-mendoza opened this issue Mar 6, 2022 · 5 comments
Closed

FList can't be pickled #88

ismael-mendoza opened this issue Mar 6, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@ismael-mendoza
Copy link
Contributor

ismael-mendoza commented Mar 6, 2022

As I'm trying to replace the survey functionality of BTK with galcheat, I realized that I can't pickle the galcheat.survey.Survey class due to it containing a dynamically generated dataclass FList. See here and here.

Would it be possible to replace it with just a dictionary? Or why is the FList necessary? Thanks you! The reason I need to pickle it is to run multiprocessing which internally pickles objects.

One workaround that was suggested was to do FList.__module__ = __name__ (where it is created). But it seems a bit hacky and perhaps easier to replace with a dictionary if possible

@aboucaud

_pickle.PicklingError: Can't pickle <class 'types.LSSTFilterList'>: attribute lookup LSSTFilterList on types failed
@aboucaud
Copy link
Collaborator

aboucaud commented Mar 8, 2022

The reason I created these dynamical lists was to enable the possibility of writing

LSST.filters.u.effective_wavelength

and having autocompletion in ipython or any IDE, instead of writing

LSST.get_filter('u').effective_wavelength

where you actually need to check first which filters are available.

@aboucaud
Copy link
Collaborator

aboucaud commented Mar 8, 2022

It cannot be solved through the trick of writing FList.__module__ = __name__ because FList is just a placeholder for the dataclass created specifically for each survey given its filters : LSSTFilterList for LSST, DESFilterList for DES, etc.

The only option seems to abandon that functionality for a dictionary, but sadly that was one of the coolest features I had created for galcheat 😢

@aboucaud aboucaud added the bug Something isn't working label Mar 9, 2022
@thuiop
Copy link

thuiop commented Mar 9, 2022

I spoke about a way to potentially solve this at the meeting today (by replacing multiprocessing by pathos.multiprocessing) ; however I tried it and it does not seem to work :(

@ismael-mendoza
Copy link
Contributor Author

ismael-mendoza commented Mar 17, 2022

Thanks @aboucaud and @thuiop for looking into this. And thanks @aboucaud for explaining your reasoning on doing this. It is indeed unfortunate that we need to abandon the FList due to multiprocessing solely and that other workarounds don't seem to work.

I'll think more about this today and let you know if I can come up with a workaround in BTK.

@aboucaud
Copy link
Collaborator

Closed by #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants