【问题标题】:Snakemake 'run' directive produces no error messageSnakemake \'run\' 指令不产生错误信息
【发布时间】:2022-07-28 11:45:18
【问题描述】:

当我在 snakemake 中使用 run 指令(使用 python 代码)时,它不会产生任何类型的错误消息以进行故障排除。 这是期望的行为吗?我错过了什么吗?

这是一个使用snakemake 7.8.3 和python 3.9.13 的最小示例。 我使用-p 选项调用了snakemake,该选项在shell 指令中输出传递给shell 的确切代码(但我猜对run 指令没有做任何事情)。

蛇文件:

def useless_function():
    return[thisVariableAlsoDoesntExist]

rule all:
    input: \"final.txt\"

rule test:
    output: \"final.txt\"
    run:
        print(thisVariableDoesNotExist)
        useless_function()

标准输出:

Building DAG of jobs...
Using shell: /usr/bin/bash
Provided cores: 1 (use --cores to define parallelism)
Rules claiming more threads will be scaled down.
Job stats:
job      count    min threads    max threads
-----  -------  -------------  -------------
all          1              1              1
test         1              1              1
total        2              1              1

Select jobs to execute...

[Mon Jul 25 18:59:13 2022]
rule test:
    output: final.txt
    jobid: 1
    reason: Missing output files: final.txt
    resources: tmpdir=/tmp

Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Complete log: .snakemake/log/2022-07-25T185913.188760.snakemake.log

预期的错误消息(当函数和打印命令直接在 python 控制台上执行时):

>>> print(thisVariableDoesNotExist)
Traceback (most recent call last):                       
  File \"<stdin>\", line 1, in <module>                    
NameError: name \'thisVariableDoesNotExist\' is not defined


>>> useless_function()
Traceback (most recent call last):
  File \"<stdin>\", line 1, in <module>
  File \"<stdin>\", line 2, in useless_function
NameError: name \'thisVariableAlsoDoesntExist\' is not defined

    标签: python python-3.x error-handling snakemake


    【解决方案1】:

    我怀疑你遇到了这个最近的错误https://github.com/snakemake/snakemake/issues/1698

    如果是这种情况,您可以降级到 v7.6.2 或解决它,即忍受它或将 run 中的代码包装在您通过 shell 执行的独立脚本中。无论如何,后者并不是一个糟糕的解决方案,因为它可以很好地隔离代码。

    【讨论】:

    • 啊,我害怕。好的,包裹在 shell 中似乎不是最糟糕的解决方法。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 2012-01-15
    • 1970-01-01
    • 2021-09-18
    • 2022-12-05
    • 2022-01-14
    • 2018-10-30
    相关资源
    最近更新 更多