Skip to content

Instantly share code, notes, and snippets.

@bsmithyman
Created Jan 29, 2015
Embed
What would you like to do?
Change all IPython parallel workers to a common directory under $HOME
def cdSame(profile=None):
import os
from IPython.parallel import Client
if profile:
rc = Client(profile=profile)
else:
rc = Client()
dview = rc[:]
home = os.getenv('HOME')
cwd = os.getcwd()
def cdrel(relpath):
import os
home = os.getenv('HOME')
fullpath = os.path.join(home, relpath)
try:
os.chdir(fullpath)
except OSError:
return False
else:
return True
if cwd.find(home) == 0:
relpath = cwd[len(home)+1:]
return all(rc[:].apply_sync(cdrel, relpath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment