Skip to content

Instantly share code, notes, and snippets.

@bsmithyman
Created January 29, 2015 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsmithyman/fd292b7f400ecbc50a73 to your computer and use it in GitHub Desktop.
Save bsmithyman/fd292b7f400ecbc50a73 to your computer and use it in GitHub Desktop.
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