Import the pysge package (and anything else you need in your submission function)
import pysge
import time
Define the submission function. This can use imported modules or functions defined elsewhere (dill will hopefully find these)
def my_sum(a, b):
return a + b
def sub_func(a, b, sleep=1):
time.sleep(sleep)
return my_sum(a, b)
List of tasks to submit
tasks = [
{"task": sub_func, "args": (1, 2), "kwargs": {"sleep": 10}},
{"task": sub_func, "args": (3, 4), "kwargs": {"sleep": 10}},
{"task": sub_func, "args": (5, 6), "kwargs": {"sleep": 10}},
]
tasks
help(pysge.sge_submit)
results = pysge.sge_submit(tasks, "myjobs", "tmp_path", options="-q hep.q -l h_rt=3:0:0")
results
The equivalent running locally is
[task["task"](*task["args"], **task["kwargs"]) for task in tasks]