Skip to content

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.

2 participants