Skip to content

Commit 2e39b18

Browse files
authored
feat: include rule name as comment (#16)
Since the jobs are named with a unique ID, it is not easy to figure out what rule is being run on a specific SLURM job. This PR adds the rule name as a comment, so that it can be displayed by `squeue` and `sacct`.
1 parent e61d0a0 commit 2e39b18

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

snakemake_executor_plugin_slurm/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def run_job(self, job: JobExecutorInterface):
6868
# with job_info being of type
6969
# snakemake_interface_executor_plugins.executors.base.SubmittedJobInfo.
7070

71-
jobid = job.jobid
72-
7371
log_folder = f"group_{job.name}" if job.is_group() else f"rule_{job.name}"
7472

7573
slurm_logfile = os.path.abspath(f".snakemake/slurm_logs/{log_folder}/%j.log")
@@ -78,7 +76,10 @@ def run_job(self, job: JobExecutorInterface):
7876
# generic part of a submission string:
7977
# we use a run_uuid as the job-name, to allow `--name`-based
8078
# filtering in the job status checks (`sacct --name` and `squeue --name`)
81-
call = f"sbatch --job-name {self.run_uuid} -o {slurm_logfile} --export=ALL"
79+
call = (
80+
f"sbatch --job-name {self.run_uuid} --output {slurm_logfile} --export=ALL "
81+
f"--comment {job.name}"
82+
)
8283

8384
call += self.get_account_arg(job)
8485
call += self.get_partition_arg(job)
@@ -149,7 +150,7 @@ def run_job(self, job: JobExecutorInterface):
149150
slurm_jobid = out.split(" ")[-1]
150151
slurm_logfile = slurm_logfile.replace("%j", slurm_jobid)
151152
self.logger.info(
152-
f"Job {jobid} has been submitted with SLURM jobid {slurm_jobid} "
153+
f"Job {job.jobid} has been submitted with SLURM jobid {slurm_jobid} "
153154
f"(log: {slurm_logfile})."
154155
)
155156
self.report_job_submission(

0 commit comments

Comments
 (0)