-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sbatch
call does not escape quotes in exec_job
#29
Comments
looking into it. Can you provide a minimal example? |
Just stumbled upon this too. Here's a MWE:
# default/config.yaml
# works on the NERSC supercomputer
executor: slurm
default-resources:
- slurm_account=m2676
- constraint=cpu
- slurm_extra="--qos regular"
jobs: unlimited
cores: all
group-components:
- foo=2 execute with
|
fixed in release 8.4.3 of the snakemake core - however, the odd propagation of function values instead of string flags is just fixed. A release is forthcoming. Stay tuned. |
Unfortunately I still get the same error using See the
for now I worked around this by removing the quotes around the If nothing else, it may be an idea to just put an error message here like: if exec_job.contains('"'):
raise ValueError("SLURM submission command contains illegal character \"") |
What a command line! Currently, I am unable to test - no cluster (maintenance). Can you indicate the malicious line of your Snakemake command line or your resource yaml, please? |
The MWE I posted earlier keeps failing with Snakemake 8.4.3, for the record. |
@cmeesters The error stems from the Anyway, a (minimal) reproducible example (requires singularity/apptainer + SLURM):
|
Hi everyone, It seems that the same issue occurs when a workflow-profile configuration file contains a Snakefile:
profile/config.yaml that contains some configuration variables:
Calling snakemake with
Note that the config keyword was translated to As a workaround, I moved my config parameters to a config.yaml file:
Running snakemake as Tested with:
HTH, best, |
Please update to the current version of the executor and Snakemake itself and try again. My own test is working, now. Note, that you ought to write: |
@cmeesters Still the same exception.
|
Sorry, I could not get back to this issue any sooner. @ebete With
I could get your testcase to work. Before that, I think we went into Dante's fourth hell of quotation nesting. |
@ebete is it working? Or do these issues persist? |
@cmeesters diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py
index a97f4aa..a214983 100644
--- a/snakemake_executor_plugin_slurm/__init__.py
+++ b/snakemake_executor_plugin_slurm/__init__.py
@@ -6,6 +6,7 @@ __license__ = "MIT"
import csv
from io import StringIO
import os
+import re
import subprocess
import time
from datetime import datetime, timedelta
@@ -141,6 +142,8 @@ class Executor(RemoteExecutor):
# (see https://github.com/snakemake/snakemake/issues/2014)
call += f" -D {self.workflow.workdir_init}"
# and finally the job to execute with all the snakemake parameters
+ # escape any unescaped double quotes to prevent the --wrap="..." to be prematurely closed
+ exec_job = re.sub(r'(?<!\\)"', r"\"", exec_job)
call += f' --wrap="{exec_job}"'
self.logger.debug(f"sbatch call: {call}") |
Looks nice! Out of curiosity: Did it fail the same way as before using the workflow-profile? Anyway, I do not want to leave you hanging. Yet, I just got a new student, a workshop for Wednesday to prepare and will take a few days off, because our school is closed. With other words: little time for testing. Will do so a.s.a.p. |
I reckon that the profile would work. But in my case I'm generating the And no worries, enjoy the break :) |
The
sbatch
command constructed insnakemake_executor_plugin_slurm.Executor().run_job()
does not seem to escape quotes in theexec_job
variable, causing issues at the following line:snakemake-executor-plugin-slurm/snakemake_executor_plugin_slurm/__init__.py
Line 133 in cf0560c
When
exec_job
contains a double quote ("
), it will generate a not-so-helpful error message:Extra info
The text was updated successfully, but these errors were encountered: