2

My snakemake pipeline asserts that my code raises a non-zero exit code whenever I run any rule, even though my code returns an error code of 0 if I manually run the same exact code, and it works perfectly normally when ran in Snakemake.

As per the advice of this question, I tried appending || true to the shell command in the snakemake rule, changing my rule from looking like

rule rulename:
    input:
        "input/file"
    output:
        "output/file"
    shell:
        "python3.7 scripts/script.py {input} {output}"

to

rule rulename:
    input:
        "input/file"
    output:
        "output/file"
    shell:
        "python3.7 scripts/script.py {input} {output} || true"

However, when I re-run the pipeline, snakemake still errors and says, (exited with non-zero exit code), even though the || true at the end will ensure that this command always returns an exit code of 0.

What is snakemake doing to cause that? For reference, I am using snakemake 5.5.0 with python 3.7.0, and the server I'm using has Ubuntu 16.04.5, if that's relevant.

Jarred Allen
  • 320
  • 3
  • 24
  • I'm unable to reproduce this. This is what I tried: 1. Created a new dir and `cd`'d into it. 2. Copy-pasted your rule into a `Snakefile`. 3. `mkdir input output` to create the directories. 4. `touch input/file`, 5. Ran `snakemake`. Instead of the "(exited with non-zero exit code)" you get, I get a `python3.7: can't open file 'scripts/script.py' [...]" followed by a "MissingOutputException" as expected. Can you please try the same thing and see if it still happens? Make sure to try in a clean directory using info from your post exactly as described. Don't re-use your existing project files – that other guy Jun 21 '19 at 04:16
  • I'm having the same issue. Apart from `|| true`, I've also tried adding `set +e` and `exit 0` to the shell command - still the same problem. Did you ever find a solution? – soungalo Sep 09 '20 at 14:28
  • soungalo Sorry, but we were unable to resolve this inconsistency while I was working on that project (I left about a year ago). – Jarred Allen Sep 10 '20 at 19:34

1 Answers1

0

I had this problem when running docker in Snakemake without propagating my userid to the container. The script can run but if Snakemake can't touch the output as your user it will return this cryptic error.

rule helloworld:
    output: "output_10/test"
    shell:
        """
        docker  run -v $PWD:/work -w /work someimage somecommand > output_10/test'
        """

(exited with non-zero exit code)

rule helloworld:
    output: "output_10/test"
    shell:
        """
        docker  run --user $(id -u):$(id -g) -v $PWD:/work -w /work someimage somecommand > output_10/test'
        """

works

tripleee
  • 175,061
  • 34
  • 275
  • 318
Jeremy Leipzig
  • 1,914
  • 3
  • 21
  • 26