Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
python2 fix and add a copy_script argument (#48)
Browse files Browse the repository at this point in the history
In #47 a work around for a SGE-related issue was introduced,
where the worker script was copied to the current working
directory. The copy_script argument allows toggling
this behavior (defaulted to True so that SGE users do not
need to explicitly specify the fix).

Also fixed a minor python2 backwards-compatibility issue,
where shutil.copy() returns None.
  • Loading branch information
azjps authored and jakirkham committed Nov 24, 2017
1 parent 86aeb1e commit 5c2a93f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dask_drmaa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def make_job_script(executable, name, preexec=()):

class DRMAACluster(object):
def __init__(self, template=None, cleanup_interval=1000, hostname=None,
script=None, preexec_commands=(), **kwargs):
script=None, preexec_commands=(), copy_script=True,
**kwargs):
"""
Dask workers launched by a DRMAA-compatible cluster
Expand All @@ -75,6 +76,9 @@ def __init__(self, template=None, cleanup_interval=1000, hostname=None,
script: string (optional)
Path to the dask-worker executable script.
A temporary file will be made if none is provided (recommended)
copy_script: bool
Whether should copy the passed script to the current working
directory. This is primarily to work around an issue with SGE.
args: list
Extra string arguments to pass to dask-worker
outputPath: string
Expand Down Expand Up @@ -123,9 +127,11 @@ def remove_script():

else:
self._should_cleanup_script = False
with ignoring(EnvironmentError): # may be in the same path
script = shutil.copy(script, os.path.curdir)
self._should_cleanup_script = True
if copy_script:
with ignoring(EnvironmentError): # may be in the same path
shutil.copy(script, os.path.curdir) # python 2.x returns None
script = os.path.join(os.path.curdir, os.path.basename(script))
self._should_cleanup_script = True
self.script = script
assert not preexec_commands, "Cannot specify both script and preexec_commands"

Expand Down

0 comments on commit 5c2a93f

Please sign in to comment.