Non-error early exit.

Create issue
Issue #1194 new
Ted Toal created an issue

I’d like to be able to print a message to the pipeline user and then exit snakemake. When I do this now, by calling quit(0) after printing the message, snakemake terminates with an exception-like stack dump:

SystemExit in line 40 of /share/carvajal-archive/SEQ_DATA/PANELS/MSEQ_GC_Panel_03_28_2017/pipeline:


File "/share/carvajal-archive/SEQ_DATA/PANELS/MSEQ_GC_Panel_03_28_2017/pipeline", line 279, in <module>

File "/share/carvajal-archive/SEQ_DATA/PANELS/MSEQ_GC_Panel_03_28_2017/PIPELINE/include/", line 143, in <module>

File "/share/carvajal-archive/SEQ_DATA/PANELS/MSEQ_GC_Panel_03_28_2017/pipeline", line 42, in pipelineAction

File "/share/carvajal-archive/SEQ_DATA/PANELS/MSEQ_GC_Panel_03_28_2017/pipeline", line 40, in stopPipeline

File "/share/carvajal-archive/PACKAGES/local/miniconda/miniconda3_perl/envs/python3/lib/python3.6/", line 26, in __call__

I really don’t want this to appear, as the message I print out tells the user what he needs to do, and it is not really an error, just a note to the user that more work is needed on his part in order to run the pipeline. There should be a way to exit without invoking the stack dump.

Comments (2)

  1. Christian Arnold

    Hi Ted, you should do it differently: Raise Python errors when something is encountered that you want termination after. For example, I am doing this for cases like this:

    raise WorkflowError(“The list of TFs is empty.”). There are more types of errors like this, choose one that fits most, but the logic is the same I think… Snakemake will then exit gracefully.

    You can also check, in addition, the onerror: handler, that prints something in the very end.

  2. Ted Toal reporter

    Great, that sounds like the way to go. I found the existing snakemake exception definitions in the snakemake source code file However, looking through it, I don’t see any good way to raise an exception that does not perform a traceback. A few exception types don’t do tracebacks, but print_exception specifically looks for these kinds of exceptions, and none of them are appropriate for my use. It seems like the wrong way to do it. Why not let the exception class itself define a function to print itself, and print_exception would just call that?

  3. Log in to comment