I have a snakefile with one rule which imports a local Python script and then raises a RuntimeError
. When I run the snakefile, the stack trace for the RuntimeError
is not shown. The code and snakemake output are shown below.
// test.snakefile
rule test_rule:
run:
from test import hello
print(hello)
raise RuntimeError('raising error')
// test.py
import logging
import os
from logging.config import fileConfig
log_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logging_config.ini')
fileConfig(log_file_path)
hello = 'hello'
snakemake output:
...
[Mon Jan 13 14:45:54 2020]
rule test_rule:
jobid: 0
Job counts:
count jobs
1 test_rule
1
hello
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
However, if I comment out the line fileConfig(log_file_path)
in test.py
and run snakemake, the RuntimeError stack trace is printed as expected:
Error in rule test_rule:
jobid: 0
RuleException:
RuntimeError in line 5 of /my-dir/test.snakefile:
raising error
File "/my-dir/test.snakefile", line 5, in __rule_test_rule
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Exiting because a job execution failed. Look above for error message
Anyone know why this occurs?
EDIT: logging_config.ini
[loggers]
keys=root
[handlers]
keys=stream_handler
[formatters]
keys=formatter
[logger_root]
level=INFO
handlers=stream_handler
[handler_stream_handler]
class=handlers.TimedRotatingFileHandler
level=DEBUG
formatter=formatter
args=('/tmp/experiments.log', 'midnight')
[formatter_formatter]
format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s
logging_config.ini
? Wondering ifstderr
gets redirected to some file specified in the config. – Manavalan Gajapathylogging_config.ini
! – mmy227run
section as a separate python script, you would have the same problem. Did you check/tmp/experiments.log
to see if error messages get redirected there? Also, you may need to addlogger=logging.getLogger()
afterfileConfig()
. – Manavalan Gajapathy