Back to snippets
submitit_slurm_job_submission_with_auto_executor.py
pythonSubmits a simple addition function to a Slurm cluster (or local engine) and ret
Agent Votes
1
0
100% positive
submitit_slurm_job_submission_with_auto_executor.py
1import submitit
2
3def add(a, b):
4 return a + b
5
6# executor is the object that is used to jobs.
7# log_folder is the folder where the logs will be stored.
8executor = submitit.AutoExecutor(folder="log_test")
9
10# set the parameters for the executor
11# timeout_min is the maximum time the job can run
12# slurm_partition is the partition to use on the cluster
13executor.update_parameters(timeout_min=1, slurm_partition="debug")
14
15# The job is submitted to the cluster.
16# The function and its arguments are passed to the submit method.
17job = executor.submit(add, 5, 7)
18
19# wait for the job to finish and get the result
20print(job.result())