4

I have a folder with a lot of .sh scripts. How can I use an already set up dask distributed cluster to run them in parallel?

Currently, I am doing the following:

import dask, distributed, os

# list with shell commands that I want to run
commands = ['./script1.sh', './script2.sh', './script3.sh']

# delayed function used to execute a command on a worker
run_func = dask.delayed(os.system)

# connect to cluster
c = distributed.Client('my_server:8786')

# submit job
futures = c.compute( [run_func(c) for c in commands])

# keep connection alive, do not exit python
import time
while True:
    time.sleep(1)

This works, however for this scenario it would be ideal if the client could disconnect without causing the scheduler to cancel the job. I am looking for a way to compute my tasks that does not require an active client connection. How could this be done?

1 Answer 1

4

Have you seen http://distributed.readthedocs.io/en/latest/api.html#distributed.client.fire_and_forget ? That would be a way to ensure that some task runs on the cluster after the client has gone.

Note also that you have functions like wait() or even gather() so you don't need sleep-forever loops.

In general, though, subprocess.Popen will launch a child process and not wait for it to finish, so you don't even need anything complex from dask, since it doesn't appear you are interested in any output from the call.

Sign up to request clarification or add additional context in comments.

1 Comment

I just figured out fire_and_forget is also nicely documented here: dask.pydata.org/en/latest/futures.html#fire-and-forget

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.