Coder Social home page Coder Social logo

debuglater's Introduction

debuglater: Store Python traceback for later debugging

Code style: black

Community | Newsletter | Twitter | LinkedIn | Blog | Website | YouTube

Tip

Deploy AI apps for free on Ploomber Cloud!

  • debuglater writes the traceback object so you can use it later for debugging
  • Works with pdb, pudb, ipdb and pdbpp
  • You can use it to debug on a different machine, no need to have access to the source code

For support, feature requests, and product updates: join our community, subscribe to our newsletter or follow us on Twitter/LinkedIn.

demo

Click here to tell your friends on Twitter!

Click here to tell your friends on LinkedIn!

Installation

pip install debuglater

# for better serialization support (via dill)
pip install 'debuglater[all]'

# ..or with conda
conda install debuglater -c conda-forge

Usage

import sys
import debuglater

sys.excepthook = debuglater.excepthook_factory(__file__)

For more details and alternative usage, keep reading.

Example

# get the example
curl -O https://raw.githubusercontent.com/ploomber/debuglater/master/examples/crash.py
# crash
python crash.py

Debug:

dltr crash.dump

Upon initialization, try printing the variables x and y:

Starting pdb...
> /Users/ploomber/debuglater/examples/crash.py(5)<module>()
-> x / y
(Pdb) x
1
(Pdb) y
0
(Pdb) quit

Note: you can also use: debuglater crash.py.dump

Integration with Jupyter/IPython

Note For an integration with papermill, see ploomber-engine

Add this at the top of your notebook/script:

from debuglater import patch_ipython
patch_ipython()
# get sample notebook
curl -O https://raw.githubusercontent.com/ploomber/debuglater/master/examples/crash.ipynb

# install package to run notebooks
pip install nbclient
# run the notebook
jupyter execute crash.ipynb

Debug:

dltr jupyter.dump

Upon initialization, try printing the variables x and y:

Starting pdb...
-> x / y
(Pdb) x
1
(Pdb) y
0
(Pdb) quit

Note: you can also use: debuglater jupyter.dump

Motivation

The Ploomber team develops tools for data analysis. When data analysis code executes non-interactively (example: a daily cron job that generates a report), it becomes hard to debug since logs are often insufficient, forcing data practitioners to re-run the code from scratch, which can take a lot of time.

However, debuglater is a generic tool that can be used for any use case to facilitate post-mortem debugging.

Use cases

  • Debug long-running code (e.g., crashed Machine Learning job)
  • Debug multiprocessing code (generate one dump file for each process)

Credits

This project is a fork of Eli Finer's pydump.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.