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

Make Element class pickleable #99

Merged
merged 3 commits into from
Nov 5, 2022
Merged

Make Element class pickleable #99

merged 3 commits into from
Nov 5, 2022

Conversation

bwest2397
Copy link
Contributor

@bwest2397 bwest2397 commented Oct 20, 2021

Make Element class (branca.element.Element) pickleable by stripping its ._env attribute when pickling and re-adding it when unpickling. This should address two related issues in folium: python-visualization/folium#878 and python-visualization/folium#796 and has the added implication of being able to create elements concurrently, e.g. using multiprocessing.Pool.

Make Element class pickleable by stripping the ._env attribute when pickling and re-adding it when unpickling
@Conengmo Conengmo self-requested a review October 21, 2021 08:00
Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

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

Lovely, this works.

I do want to add that not every folium object is pickable, I found Map raises an error:

_pickle.PicklingError: Can't pickle <function root at 0x000002C2924F8310>: attribute lookup root on __main__ failed

But that won't stop this PR, since this is branca-specific. Would be nice though to get it to work for any branca/folium class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants