-
Notifications
You must be signed in to change notification settings - Fork 923
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
Jupyter nb output in PyCharm IDE breaks with Kedro 0.18.2 #1719
Comments
Thanks for raising this issue! Unfortunately I think this is going to be difficult (maybe impossible) to fix fully. The behaviour of rich in notebooks is out of our control. I would recommend raising an issue on their repo. Note they have had issues with PyCharm in the past (and also separately with Jupyter), so worth searching to see if anyone mentioned this before. The behaviour of Jupyter notebooks in PyCharm may also be out of their control though. In that case the issue will need to be fixed on the PyCharm side, which I think is unlikely to happen any time soon sadly. For now, I would recommend just disabling rich logging in your kedro project: If you like having rich logging on the CLI but it can't be fixed for one particular notebooks environment then there should be a way of disabling rich logging just in that environment. Something involving I'd be curious to hear if any other notebook environments have a problem here, e.g. VS Code. From my experience of PyCharm, I think it's likely to just be acting weird in their particular implementation. |
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 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. |
Thanks for letting us know @CraftingLevi. Just to check: if you comment out these lines:
and still have 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! |
P.S. you can also completely uninstall rich tracebacks by adding these lines to your settings.py:
I'm not sure whether something similar is possible to revert Edit: looks like |
@AntonyMilneQB I did the following steps as per your description:
Result Anything outside of the scope of kedro (e.g. Tracebacks, Pandas DataFrame outputs) is now not affected by I ran my test and several run configurations after this change, both working as expected. Therefore I am unsure if the Suggested next steps In the current state, not only kedro logging, but also traceback and other console output is affected. In the suggested state, after removing these lines, only kedro logging is affected by This is a response to the following:
|
Thanks very much for checking this @CraftingLevi, and sorry for the slow response - I was off on holiday for a few days. I agree we probably need a better way of enabling/disabling and more generally configuring these two Ideally though, there would be some way of a user leaving these settings enabled and having rich work nicely in PyCharm Jupyter notebooks. This way you get all the benefits of the rich features and don't need to tinker with any settings depending on the IDE you're using. So I think we should see if that's possible first of all. Did you find anything about this specific issue on the rich repo? From my experience of PyCharm bug reports, I think this is much more likely to be fixed (or at least some workaround developed) on rich rather than on PyCharm, even if the problem is on the PyCharm side. If there's nothing on the rich repo about it then I think we should open one there to see if they can figure out how to render things nicely in PyCharm Jupyter notebooks. |
It's been a while, and aside from commenting out the install lines for rich logging as suggested earlier, this might be a, albeit suboptimal, more sophisticated solution. Inspired by how we handle rich logging and Databricks for now, we can do the same for jupyter notebooks in pycharm. However, there is only one environment variable (in my version of pycharm 2022.2) that only shows up in notebooks, PYDEVD_USE_FRAME_EVAL. I've checked and this is a flag related to debugging in pycharm. So for now, I replace lines 217-220 in kedro/framework/project/init.py with: if "DATABRICKS_RUNTIME_VERSION" not in os.environ \
and "PYDEVD_USE_FRAME_EVAL" not in os.environ:
rich.traceback.install(suppress=[click, str(Path(sys.executable).parent)])
if "PYDEVD_USE_FRAME_EVAL" not in os.environ:
rich.pretty.install() Maybe this helps bump this minor issue forward. I still agree with you that a proper solution with the interaction between PyCharms jupyter notebook integration and rich logging should be done in the rich repo, but in the meanwhile, this can bridge that gap. |
Hi @CraftingLevi, thanks for the update on this, much appreciated. I've just had a look at different environment variables that are present in my PyCharm in different run configurations (debug, emulate in terminal, emulate in Python console, Jupyter notebook), etc. and did not have If we can get another person to check that your environment variable seems to work for them then I'd happily accept your change in the kedro source. As you say, it's a hacky fix, but we do something similar for Databricks already so I'm not averse to it. I'd suggest that you open a PR for it and we get some others to review it to see if it works for them too (or I upgrade my PyCharm...). I'm also currently considering how to make the whole kedro framework-side project logging configuration accessible to users so that any future modifications to the |
In the latest release of Pycharm 2022.3.3 and as of Kedro 0.18.12, jupyter nb output is displayed as expected within the PyCharm IDE (i.e. interactive dataframe tables). Not having Rich as a core dependency can still help older PyCharm distributions, but for the latest releases for both PyCharm and Kedro, this issue is resolved. |
Thanks a lot for the update @CraftingLevi 🙏🏽 Let's follow up on making |
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](https://user-images.githubusercontent.com/19408835/180187302-219ed84d-0997-4b73-b5a2-311b41dc8122.png)
![output0182_outputtypes](https://user-images.githubusercontent.com/19408835/180187303-6c79029b-7af9-4553-8364-da4c8191a8ea.png)
![output01801](https://user-images.githubusercontent.com/19408835/180187299-75e46ac9-4279-4a6c-a266-9fde38afc8f1.png)
![output01801_outputtypes](https://user-images.githubusercontent.com/19408835/180187305-a5d96ca3-a330-4450-b9ae-3765d262e056.png)
*Output types types as of 0.18.2
*Outputs in 0.18.1
*Output Types in 0.18.1
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
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:
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
The text was updated successfully, but these errors were encountered: