PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
16.15k stars 1.57k forks source link

Add Rich traceback support to PrefectConsoleHandler #7509

Open bjorhn opened 1 year ago

bjorhn commented 1 year ago

First check

Prefect Version

2.x

Describe the current behavior

The new PrefectConsoleHandler class is great! I would rather use it than rich.logging.RichHandler, but I've grown accustomed to Rich's functionality for outputting more sensible exception tracebacks to the console.

Describe the proposed behavior

I propose adding support for setting the flag rich_tracebacks in logging.yml, along with relevant configuration settings such as tracebacks_word_wrap. This would require changes to PrefectConsoleHandler. I looked into creating a custom handler for this myself but when I realized it wouldn't be a quick fix I decided against it. I would prefer my logging infrastructure to not derive too far from Prefect's in order to more easily keep up to date with new functionality.

Example Use

No response

Additional context

More information about Rich's traceback support can be found here: https://rich.readthedocs.io/en/stable/traceback.html

zanieb commented 1 year ago

@bjorhn as long as this is opt-in via a Prefect setting and the implementation is not too complex I'm interested :)

bunchesofdonald commented 1 year ago

Hi @bjorhn! I like the idea and, while I've never used them, Rich traceback's look really nice and much more readable than the default. I do hesitate a bit on making a special settings for Rich specific settings or options. Maybe this would be better handled by a hook or the ability to better subclass PrefectConsoleHandler so that the Console is alterable downstream and you could call any install?