Snakemake“run”指令不产生错误消息

Tri*_*tra 5 python error-handling python-3.x snakemake

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

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

蛇文件:

def useless_function():
    return[thisVariableAlsoDoesntExist]

rule all:
    input: "final.txt"

rule test:
    output: "final.txt"
    run:
        print(thisVariableDoesNotExist)
        useless_function()
Run Code Online (Sandbox Code Playgroud)

标准输出:

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

Run Code Online (Sandbox Code Playgroud)

预期错误消息(当函数和打印命令直接在 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
Run Code Online (Sandbox Code Playgroud)

dar*_*ber 5

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

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