Snakemake run指令无报错信息,是否为预期行为?
Snakemake run指令执行Python代码无控制台报错的问题
问题描述
使用Snakemake的run指令执行Python代码时,控制台未输出任何故障排查用的报错信息,这是预期行为吗?是否存在遗漏的配置?
环境说明:基于Snakemake 7.8.3和Python 3.9.13,调用Snakemake时已使用-p选项(该选项仅对shell指令生效,对run指令无作用)。
复现用Snakefile
def useless_function(): return[thisVariableAlsoDoesntExist] rule all: input: "final.txt" rule test: output: "final.txt" run: print(thisVariableDoesNotExist) useless_function()
控制台标准输出(Stdout)
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
问题解答
- 这不是预期的“无报错”行为,报错信息并未丢失,而是被写入了Snakemake的专用日志文件,而非控制台标准输出。
- 控制台输出末尾已经明确给出了日志文件路径(示例中为
.snakemake/log/2022-07-25T185913.188760.snakemake.log),打开该文件即可查看完整的Python Traceback报错信息,与你在Python控制台直接执行时的预期内容一致。 - 若想让报错信息直接显示在控制台,可使用
--verbose(或简写-v)选项启动Snakemake,该选项会将包括Python报错在内的更多日志信息输出到标准输出。
内容的提问来源于stack exchange,提问作者Trillian Astra
相关产品推荐
相关产品推荐

