← 输入框|github.com|刷新
Skip to content

folium.features.Circle not pickable #796

Closed

Description

@raphaelauv

hi:
i try to parallelise a code , but apparently Circle is not pickable
do you have any solution ?
in any case thank you for all your work

from concurrent import futures
import multiprocessing

def emptyListFuturs(listOfFuturs,map_osm):
	for fut in futures.as_completed(listOfFuturs):
		putToMapOSM(fut.result(),map_osm)

def map_all_sensor():
	dic =  modeDict()
	nbThreads = multiprocessing.cpu_count()
	
	listOfFuturs=[]
	map_osm = make_map_paris()
	arrayOfItems=[]
	cmp=0
	cmpJ=0
	executor = futures.ProcessPoolExecutor(max_workers=nbThreads)
	for id,item in tqdm(dic.items()):
		if(not np.isnan(item).any()):
			if(len(item)==2):
				#lat=item[0]
				#lon=item[1]
				arrayOfItems.append(item)
				cmp+=1
				
				#folium.Circle(radius=10,location=item,popup='The Waterfront',color='crimson',fill=False).add_to(map_osm)
		if(cmp==10):
			listOfFuturs.append(executor.submit(createOSMObjectArray,arrayOfItems))
			arrayOfItems=[]
			cmpJ+=1
			cmp=0
		if(cmpJ>10):
			emptyListFuturs(listOfFuturs,map_osm)
			listOfFuturs=[]

	emptyListFuturs(listOfFuturs,map_osm)
	executor.shutdown()
	if(cmp>1):
		putToMapOSM(createOSMObjectArray(arrayOfItems),map_osm)
	map_osm.save('sensors_map.html')

def putToMapOSM(arrayOfItems,map_osm):
	for i in arrayOfItems:
		i.add_to(map_osm)

Activity

  1. Conengmo commented on Dec 10, 2017

    @Conengmo
    Member

    I didn't try you example, it's not a minimal working example. But since you mentioned that Circle is not pickable, I tried that. And indeed it seems you cannot pickle Folium objects:

    _pickle.PicklingError: Can't pickle <function do_first at 0x0000000001234567>: 
    it's not the same object as jinja2.filters.do_first
    

    I guess you can produce your data using concurrency, but not create Folium objects concurrently. I don't know what to do about this.

  2. Conengmo commented on Apr 21, 2018

    @Conengmo
    Member

    Here is another resource on this topic:
    https://stackoverflow.com/questions/8804830/python-multiprocessing-pickling-error

    I think for now this is not something that needs to be fixed, if it's reasonably possible at all.

  3. added
    enhancementFeature request or idea about how to make folium better
    wontfixThis problem or request is outside the scope of folium
    on Apr 21, 2018
  4. HADDADENICAR commented on Jun 1, 2018

    @HADDADENICAR

    Hey @Conengmo i have the same problem but with spark what should i do ?

  5. Conengmo commented on Oct 12, 2018

    @Conengmo
    Member

    I'm closing this old issue since we are not going to fix this. If new information comes up feel free to add it, we can reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature request or idea about how to make folium betterwontfixThis problem or request is outside the scope of folium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions