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

Change default logging.yml to use RichHandler 2: fancy tracebacks #1513

Closed
Tracked by #1461
antonymilne opened this issue May 6, 2022 · 3 comments · Fixed by #1603
Closed
Tracked by #1461

Change default logging.yml to use RichHandler 2: fancy tracebacks #1513

antonymilne opened this issue May 6, 2022 · 3 comments · Fixed by #1603
Assignees

Comments

@antonymilne
Copy link
Contributor

antonymilne commented May 6, 2022

🥳 FUN TICKET 🥳 Prerequisites: #1512. Based off point 4 of #1464

  • Understand what exactly is the difference between setting rich_tracebacks: True on our rich logging handler vs. rich.traceback.install - it would probably be neatest if we can achieve everything we want to just by altering the log handler and not running rich.traceback.install
  • Play around with the options available for logging handler or options for rich.traceback.install depending on which we are using
    • probably the defaults are good for our use, but feel free to change any if there are better values for our use
    • in particular, suppress for click and/or kedro looks like the most powerful option to add
    • overall we want exceptions to be clear to the user exactly what the problem is so that they can debug things easily without having to wade through long tracebacks of unrelated framework errors
  • Assuming we're going for the log handler route, add the right options to all the places where rich logging handler is defined (framework logging.yml + project-side logging.yml + starters + e2e test)
  • Test thoroughly to check that kedro run works nicely when there are exceptions coming from different places (e.g. in a node function, in some external libary, in the kedro framework, a KedroCLIError)
  • Test similarly to see what happens if you do session.run in ipython and jupyter
@merelcht
Copy link
Member

Look at how this works in PyCharm and other IDEs. @noklam mentioned this might potentially break links in PyCharm.

@noklam
Copy link
Contributor

noklam commented May 16, 2022

For the record, this is the breaking thing I mentioned. The path is usually a clickable path that will jump to the line of code which raises the Error.

With these 2 lines, the path becomes not clickable. It will be a good idea to test on VS code as well.

from rich.traceback import install
install(show_locals=True)

image

@antonymilne
Copy link
Contributor Author

@noklam I think this might actually be a more general problem with PyCharm rendering Rich output, not just the traceback feature.

From a quick read, it seems that enabling "emulate terminal" in PyCharm should make this work, but that setting does not work with PyCharm debug mode.

We should check this and add to our docs since doing a kedro run using Run Configurations in PyCharm is a common workflow and we already discuss it: https://kedro.readthedocs.io/en/stable/development/set_up_pycharm.html#set-up-run-configurations

References:
Textualize/rich#206
https://youtrack.jetbrains.com/issue/PY-43860/Python-package-rich-print-text-in-color-bold-etc-does-not-print-
Advice from Rich's docs:

PyCharm users will need to enable “emulate terminal” in output console option in run/debug configuration to see styled output.

@SajidAlamQB SajidAlamQB self-assigned this Jun 7, 2022
@antonymilne antonymilne linked a pull request Jun 9, 2022 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants