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.

Jupyter nb output in PyCharm IDE breaks with Kedro 0.18.2

See original GitHub issue

Description

Jupyter notebook cell output related to the logging package and pandas package in the IDE Pycharm >= 2022.1.2 renders as a web file instead of an interactive ‘Table’ after upgrading from kedro 0.18.1 to 0.18.2. My hypothesis is that this is caused by the native integration of the Rich package as of kedro 0.18.2. Current resolution is to remain at kedro 0.18.1 for time being, hoping this issues is fixed in a future release.

Code run prior to the outputs in the image below: import numpy as np import pandas as pd from kedro.framework.cli import catalog %load_ext kedro.extras.extensions.ipython %reload_kedro D:\Work\vz-ona-kedro df = catalog.load("node_dataset").head(5) df.columns = ['Example'+str(idx) for idx, _ in enumerate(df.columns) ]

*Outputs as of 0.18.2 output0182 *Output types types as of 0.18.2 output0182_outputtypes *Outputs in 0.18.1 output01801 *Output Types in 0.18.1 output01801_outputtypes

Context

Pycharm version >= 2022.1.2 Upgrade from Kedro 0.18.1 to 0.18.2 caused issue. Downgrade resolves issue. Jupyter cell outputs as a result of the logging package and pandas package render as ‘Web’ instead of Text / Table. After outputting, cells might become unresponsive to editing for +/- 15 seconds.

Works fine in the browser version of Jupyter, however this does not have the functionality of an IDE, impacting productivity.

Steps to Reproduce

  1. Upgrade to Kedro 0.18.2 from 0.18.1
  2. Run notebook cell that outputs a pandas dataframe, stacktrace or logs

Expected Result

Output of cell is of type ‘Table’ and renders as an interactive table

Actual Result

Output of cell is of type Web, and is non-interactive

Your Environment

Include as many relevant details about the environment in which you experienced the bug:

  • Kedro version: 0.18.2
  • Python version: 3.8.13
  • Operating system and version: Windows 10 Home 21H2
  • Pycharm version >= 2022.1.2

Project Dependencies installed:

networkx~=2.5 plotly==5.9.0 pandas~=1.3.0 numpy~=1.22.3 holidays==0.11.3.1 tqdm~=4.56.0 python_dateutil==2.8.2 python-pptx==0.6.21 kaleido==0.2.1 scipy==1.7.3 Pillow~=8.4.0 python-dateutil~=2.8.1 kedro~=0.18.1 sphinx~=5.0.1 pyarrow~=6.0.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AntonyMilneQBcommented, Jul 22, 2022

Thanks for letting us know @CraftingLevi. Just to check: if you comment out these lines:

        rich.traceback.install(
            show_locals=True, suppress=[click, str(Path(sys.executable).parent)]
        )
        rich.pretty.install()

and still have rich configured as the logging handler (easiest way to ensure this is just to delete your conf/base/logging.yml file), then things work ok in PyCharm Jupyter?

I wouldn’t raise a PR for this just yet since we’re going to need to have think about the right solution. There could be a few different ways to approach this I think, and we’ll need to take a bit of time to figure out what the best way is. But thank you for the offer!

1reaction
CraftingLevicommented, Jul 21, 2022

Thanks for the quick response! I looked further into it, and it seems that rich and PyCharm just don’t go hand in hand and found related issues on the JetBrains end.

I did some digging and found the root cause for the issues in PyCharm This issue specifically is a result of calling rich.traceback.install and rich.pretty.install in kedro/kedro/framework/project/init.py. Commenting these out resolves all jupyter notebooks issues in PyCharm, and does not cause further issues in Kedro.

A resolution would be to rollback the decision on default_logging and continue use of the logging.yml file in conf/base, whilst setting the default to rich regardless, but providing end-users the option to use a different type of logging opposed to rich, in situations where rich might skrew with the dev environment.

For now, I’ll rollback to 0.18.1. I’m new to contributing, so let me know what a good approach would be to get the suggestion above reviewed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set up PyCharm — Kedro 0.18.4 documentation
Emulate terminal in output console enables PyCharm to show rich terminal output. To execute the Run configuration, select it from the Run /...
Read more >
[BUG] Coloring does not work in PyCharm · Issue #206 - GitHub
It works in the PyCharm terminal (command line), but not inside the stdout ... Jupyter nb output in PyCharm IDE breaks with Kedro...
Read more >
PyCharm - Run and debug Jupyter notebook code cells
PyCharm provides the full-functional Jupyter Notebook Debugger for both local and remote Jupyter server kernels.
Read more >
conda-forge
astpretty, 2.1.0, MIT, Pretty print the output of python stdlib `ast.parse`. ... Flask-Celery-Helper doesn't break PyCharm autocomplete/inspections.
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