question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

automain not compatible with PDB / PUDB debuggers

See original GitHub issue

Phenomenon

When I write the script with automain and run it with $ python -m pdb script.py,the debugger does not open the post-mortem analyzer even if there is an error.

Why this may be an issue

Without using automain, the use of python <scriptname.py> with ‘param=“value”’ seems to be restricted.

MnWE (minimal not-working example)

from sacred import Experiment
ex = Experiment()
@ex.automain
def main():
    raise Exception()

Run this with $ python -m pdb <scriptname.py> and you can observe that the PDB does not start.

MWE (minimal working example)

from sacred import Experiment
ex = Experiment()
@ex.main
def main():
    raise Exception()

if __name__ == '__main__':    
    ex.run()

Run this with $ python -m pdb <scriptname.py> and you can observe that the PDB starts.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Qwlousecommented, Sep 10, 2018

Hi @diadochos, This questions seems to pop up rather regularly. It is due to the default stacktrace filtering sacred does to remove the internal clutter due to decorated functions. You can disable this with with the --debug / -d flag. FYI: you can also use the -D flag to attach a post-mortem debugger. See debugging section in the docs.

Maybe the documentation about debugging should be more prominent / extensive. What do you think? Would a top-level debugging section have helped you?

0reactions
yulonglincommented, Jun 12, 2022

For the sake of clarity, to disable Sacred stacktrace filtering you run this: python -m pdb <scriptname.py> -d or python -m pdb <scriptname.py> --debug

And to add a post-mortem debugger you run this: python -m pdb <scriptname.py> -D or python -m pdb <scriptname.py> --pdb

As specified in the CLI guide in the docs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual debugging in Python with PDB and Rapunzel - YouTube
https://www.buymeacoffee.com/cogsci] In this video, I show how to use PDB, the standard Python Debugger, and Rapunzel, a code editor, ...
Read more >
Debugging - DroneKit-Python
The Python Debugger - pdb can be used to debug DroneKit-Python apps. ... a IDE like debug you can use pudb - A...
Read more >
Debugger - Features | PyCharm - JetBrains
Debug Your Python Code with PyCharm. Visual Debugging. Some coders still debug using print statements, because the concept is hard and pdb ......
Read more >
Debugging Cloudify Workers
Cloudify does not use anymore celery for running executions but for sake of backward compatibility we still install it in the environment.
Read more >
Awesome Python
Debugging Tools. Libraries for debugging code. pdb-like Debugger. ipdb - IPython-enabled pdb. pdb++ - Another drop-in replacement for pdb. pudb - A ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found