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

Custom script #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dask_drmaa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ def remove_script():
if os.path.exists(fn):
os.remove(fn)

os.chmod(self.script, 0o777)
else:
self.script = os.path.abspath(script)

# TODO: check that user-provided script is executable
os.chmod(self.script, 0o777)

self.template = merge(default_template,
{'remoteCommand': self.script},
Expand Down
20 changes: 20 additions & 0 deletions dask_drmaa/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest

from dask.utils import filetext
from dask_drmaa import DRMAACluster
from distributed import Client
from distributed.utils_test import loop, inc
Expand Down Expand Up @@ -121,3 +122,22 @@ def cleanup_logs():

import atexit
atexit.register(cleanup_logs)


def test_script(loop):
from dask_drmaa.core import script_template

script_template2 = script_template.replace('--name ', '--name my-worker-')

with filetext(script_template2, extension='sh', mode='wt') as fn:
with DRMAACluster(scheduler_port=0, script=fn) as cluster:
assert cluster.script == fn
cluster.start_workers(2)

start = time()
while len(cluster.scheduler.workers) < 2:
sleep(0.1)
assert time() < start + 10

assert all(info['name'].startswith('my-worker')
for info in cluster.scheduler.worker_info.values())