首页 > 解决方案 > Snakemake 声明规则以非零退出代码退出,即使使用“|| true”?

问题描述

我的 snakemake 管道断言,每当我运行任何规则时,我的代码都会引发非零退出代码,即使如果我手动运行相同的确切代码,我的代码会返回错误代码 0,并且在 Snakemake 中运行时它可以正常工作。

根据this question的建议,我尝试|| true在snakemake规则中附加到shell命令,将我的规则从看起来像

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

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

但是,当我重新运行管道时,snakemake 仍然出错并说,,(exited with non-zero exit code)即使|| true最后会确保此命令始终返回退出代码 0。

是什么蛇制造导致这种情况?作为参考,我在 python 3.7.0 中使用了snakemake 5.5.0,如果相关的话,我使用的服务器有 Ubuntu 16.04.5。

标签: pythonbashsnakemake

解决方案


在 Snakemake 中运行 docker 而不将我的用户 ID 传播到容器时,我遇到了这个问题。该脚本可以运行,但如果 Snakemake 无法以您的用户身份触摸输出,它将返回此神秘错误。

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'
        """

作品


推荐阅读