Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception tracebacks in run: blocks are sent to /dev/null, making rules hard to debug #1698

Closed
grahamgower opened this issue Jun 3, 2022 · 12 comments · Fixed by #1883
Closed
Labels
bug Something isn't working

Comments

@grahamgower
Copy link

Snakemake version

7.8.1

Describe the bug

When calling python code in a run: block, an uncaught exception will cause the job to fail. As it should. However, the stack trace isn't captured so its not possible to track down the cause of the exception!

Minimal example

$ cat Snakefile
rule all:
    input:
        "test-output"

rule test:
    output:
        "test-output"
    run:
        raise Exception("Hello? Is anybody out there?")
$ snakemake -c1
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...

[Fri Jun  3 15:40:47 2022]
rule test:
    output: test-output
    jobid: 1
    reason: Missing output files: test-output
    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-06-03T154046.915828.snakemake.log
$ cat .snakemake/log/2022-06-03T154046.915828.snakemake.log
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...

[Fri Jun  3 15:40:47 2022]
rule test:
    output: test-output
    jobid: 1
    reason: Missing output files: test-output
    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-06-03T154046.915828.snakemake.log
@grahamgower grahamgower added the bug Something isn't working label Jun 3, 2022
@achennu
Copy link

achennu commented Jun 8, 2022

Thanks for reporting this. I've also been bitten by this bug, and can confirm that it also affects v7.7.

When I installed with snakemake-minimal <7.6 using the bioconda channel, I got v7.3.8 installed. This version behaved as expected and displayed the traceback.

@dweindl
Copy link

dweindl commented Jul 23, 2022

The problem is the all here

return f"{super().get_job_args(job, **kwargs)} --quiet all"

in combination with the early return in
if self.is_quiet_about("all"):
# do not log anything
return

This was introduced in c8d81d0#diff-438f3317205fd7130727d0589d2fc1a6c2e1f6fc48c2c04d354a8a09b91ba2f4

Last unaffected version is v7.6.2.

@sverchkov
Copy link

in combination with the early return in

if self.is_quiet_about("all"):
# do not log anything
return

Am I missing something or would simply removing the early return fix this?

@grzanka
Copy link

grzanka commented Aug 29, 2022

I suffer the same issue, is there any hope for a fix?

@cademirch
Copy link
Contributor

Still an issue on 7.12.

@VukanJ
Copy link

VukanJ commented Sep 19, 2022

Still an issue with 7.14.0

@cclienti
Copy link
Contributor

cclienti commented Sep 27, 2022

Hello,

The regression is due to the commit:

feat: new directive "retries" for annotating the number of times a job shall be restarted after a failure (#1649)
c8d81d0

If I revert the following in snakemake/executors/__init__.py, the exceptions are correctly printed:

     def get_job_args(self, job, **kwargs):
-        return f"{super().get_job_args(job, **kwargs)} --quiet"
+        return f"{super().get_job_args(job, **kwargs)} --quiet all"

I think that the "quiet" behavior has changed, and the executor subprocess does not have the correct command line option. IMO, the solution would be to correctly configure the "quiet" option in the subprocess.

I agree with @dweindl

@SilasK
Copy link
Contributor

SilasK commented Sep 30, 2022

Is there a way to transfer the error and trace back to a log file? One can do that by mounting a whole logging structure but this is probably too much for a simple run directive.

Ideally, errors should go directly to a log if one is provided.

@sverchkov
Copy link

Is there a way to transfer the error and trace back to a log file? One can do that by mounting a whole logging structure but this is probably too much for a simple run directive.

Ideally, errors should go directly to a log if one is provided.

All error printing and logging (both to standard output/error and snakemake's default log files) is already being done with a logging structure. The problem here is that the subprocess for the run block is being run with --quiet all which configures the logger to log nothing.

johanneskoester pushed a commit that referenced this issue Oct 4, 2022
### Description

Fix #1698 exception tracebacks in run: blocks are sent to /dev/null,
making rules hard to debug

<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [ ] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).


I have created a text based on #1881 but I don't see how I can test that
the error message is printed out correctly to a log.
@SilasK
Copy link
Contributor

SilasK commented Oct 5, 2022

The new version snakemake 7.15.1 fixes this issue. However now all the snakemake log from the executor is printed out. I wonder if there would be a better solution.

@SilasK
Copy link
Contributor

SilasK commented Oct 5, 2022

In addition the log is printed to the stdout but not in the main snakemake logfile

@SilasK
Copy link
Contributor

SilasK commented Jan 27, 2023

In addition the log is printed to the stdout but not in the main snakemake logfile

Can we reopen this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants