如何记录从snakemake中脚本到达的错误消息
我正在尝试使用自定义的Python脚本构建一条Snakemake管道。 我的一些脚本陷入了错误,导致管道关闭。 但是,尽管在Shell输出中,我几乎看不到导致关闭的Python错误消息的末尾,但此错误不会在任何地方记录。它没有在自动创建的snakemake.log中记录(仅说明哪个脚本在不给出错误消息的情况下失败),并添加一个“ log:”,然后将文件夹带到失败的规则中,只能创建一个空的日志。
有没有办法访问错误消息,因此我可以解决基本问题?
编辑: 我当前的Snakemake规则看起来像这样:
rule do_X:
input: "{Wildcard}_a"
output: "{wildcard}_b"
log: out = "{Wildcard}_stdout.log"
err = "{Wildcardd}_stderr.err"
shell: python script x.py {input}{output}
如果脚本失败,我会恢复空的日志,
I am trying to build a snakemake pipeline with custom python scripts.
Some of my scripts run into errors, leading to a shutdown of the pipeline.
However, while in the shell output I can barely see the end of the python error message that leads to the shutdown, this error is not logged anywhere. It is not logged in the snakemake.log that gets automatically created (only stating which script failed without giving the error message), and adding a "log: " with a folder to the rule that fails only creates an empty log.
Is there a way to access the error message, so I can solve the underlying issue?
Edit:
my current snakemake rule looks like this:
rule do_X:
input: "{Wildcard}_a"
output: "{wildcard}_b"
log: out = "{Wildcard}_stdout.log"
err = "{Wildcardd}_stderr.err"
shell: python script x.py {input}{output}
If the script fails, I recive empty logs,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
link”由KeyboardCat的评论提供似乎效果很好。
演示从您的代码和建议的解决方案进行了调整:
将其保存为
script_x.py
:然后您的
snakefile
is>是:execute snakemake,因此它使用
snakefile
。它会引起问题,因为script_x.py
有错误并且失败。在
test_stderr.err
中,您会从script_x.py
错误的中看到追溯,因为sys
未导入 strong>在编写脚本时:如果您删除文件
test_a
,然后从import incort ofimport
中删除#
script_x.py
(行#3),它应该立即运行,并在文本中导致中的std.err
在文件test_stderr中显示。 .err
。test_stdout.log
将始终以在脚本中
制作的测试输出,因为它在脚本中包含错误的行之前创建。
您说您在由KeyboardCat的评论提供的链接;但是,您实际尝试了什么?始终最好包括您在评论中尝试的变化或在OP中添加更新部分。
The link provided by KeyboardCat's comment seems to work well.
Demonstration adapted from your code and the suggested solution:
Save this as
script_x.py
:Then your
Snakefile
is:Execute snakemake so it uses the
Snakefile
. It will cause an issue becausescript_x.py
has an error in it and fails.In
test_stderr.err
, you'll see the traceback from when thescript_x.py
errored becausesys
wasn't imported as the script was written:If you delete the files
test_a
and remove the#
from in front of theimport sys
line insidescript_x.py
(line #3), it should run without error now and result in the textThis was made from std.err
showing up in the filetest_stderr.err
.test_stdout.log
will always end up withtest output in stdout made by script
in it because it gets created before the line containing the error in the script.You say you tried the solution suggested at the link provided by KeyboardCat's comment; however, what did you actually try? Always best to include the variation you tried in the comment or add an update section to your OP.