与默认的 Python 行为不同,Snakemake 在 numpy 抛出 RuntimeWarnings 时停止执行。
/a-path/site-packages/numpy/lib/function_base.py:3250: RuntimeWarning: All-NaN slice encountered
Exiting because a job execution failed. Look above for error message
使用下面的代码配置 numpy.seterr 没有帮助。
import numpy as np
np.seterr(all='print')
我怎样才能简单地告诉snakemake不要终止警告规则?
注意:我在 Snakemake 中使用 run:
选项作为抛出 RuntimeWarning
的规则。
最佳答案
也许您在其他地方遇到了实际错误。在 5.4.2 上,警告看起来没问题:
rule all:
input:
'foo.txt',
rule one:
output:
touch('foo.txt'),
run:
import numpy as np
np.nanmax([np.nan, np.nan])
执行:
蛇形
Building DAG of jobs...
Using shell: /bin/bash
Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
count jobs
1 all
1 one
2
[Tue Jun 11 21:09:47 2019]
rule one:
output: foo.txt
jobid: 1
Job counts:
count jobs
1 one
1
/home/dario/miniconda3/lib/python3.6/site-packages/snakemake/workflow.py:19: RuntimeWarning: All-NaN axis encountered
from snakemake.logging import logger, format_resources, format_resource_names
Touching output file foo.txt.
[Tue Jun 11 21:09:47 2019]
Finished job 1.
1 of 2 steps (50%) done
[Tue Jun 11 21:09:47 2019]
localrule all:
input: foo.txt
jobid: 0
[Tue Jun 11 21:09:47 2019]
Finished job 0.
2 of 2 steps (100%) done
Complete log: /home/dario/Tritume/.snakemake/log/2019-06-11T210947.007675.snakemake.log
在任何情况下,您都可以使用以下方法消除错误
import warnings
warnings.filterwarnings('ignore')
关于python - Snakemake如何忽略RuntimeWarning?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56548927/