Skip to content

Commit 2f9d19b

Browse files
committed
Pass a bash script to srun rather than the command directly to circumvent SLURM command-line character limit
1 parent 901c000 commit 2f9d19b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

snakemake_executor_plugin_slurm_jobstep/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def run_job(self, job: JobExecutorInterface):
5858
# snakemake_interface_executor_plugins.executors.base.SubmittedJobInfo.
5959

6060
jobsteps = dict()
61+
srun_script = None
6162
# TODO revisit special handling for group job levels via srun at a later stage
6263
# if job.is_group():
6364

@@ -118,14 +119,22 @@ def run_job(self, job: JobExecutorInterface):
118119

119120
call = "srun -n1 --cpu-bind=q "
120121
call += f" {get_cpu_setting(job, self.gpu_job)} "
121-
call += f" {self.format_job_exec(job)}"
122+
# format the job to execute with all the snakemake parameters into a bash script
123+
srun_script = self.format_job_exec(job)
124+
call += " bash -s" # will have the process read the srun bash script from stdin
122125

123126
self.logger.debug(f"This job is a group job: {job.is_group()}")
124127
self.logger.debug(f"The call for this job is: {call}")
125128
self.logger.debug(f"Job is running on host: {socket.gethostname()}")
129+
srun_script_str = '\n' + srun_script if srun_script else 'N/A'
130+
self.logger.debug(f"The script for this job is: {srun_script_str}")
126131
# this dict is to support the to be implemented feature of oversubscription in
127132
# "ordinary" group jobs.
128-
jobsteps[job] = subprocess.Popen(call, shell=True)
133+
jobsteps[job] = subprocess.Popen(call, shell=True, text=True, stdin=subprocess.PIPE)
134+
if srun_script is not None:
135+
# pass the srun bash script via stdin
136+
jobsteps[job].stdin.write(srun_script)
137+
jobsteps[job].stdin.close()
129138

130139
job_info = SubmittedJobInfo(job)
131140
self.report_job_submission(job_info)

0 commit comments

Comments
 (0)