microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.28k stars 287 forks source link

Plotly graphs stop loading if many are loaded in the same notebook #15549

Open amunger opened 5 months ago

amunger commented 5 months ago

From linked issue:

Keeping up with the Plotly graphs within VSCode Insiders and all the pre-releases, I did a Kaggle notebook with a lot of them (you can find it here When downloading the code, its size is only 52MB, and the same code in VSCode (with more or less the same imports) has a size of 94.1 MB. At the end of the post I attach both notebooks.

Additionally to the above, when running the entire notebook (meaning clicking "Run All") with the Plotly graphs in interactive mode (where you can hover over the data and so), the graphs do not render, although the code runs amazingly fast. It is necessary to execute cell by cell to have the graphs rendered properly (although some of them throw an error). This didn't happen on Kaggle, where I executed all the cells and the graphs rendered normally.

Also something very strange is that if I try to open the Kaggle's notebook in VSCode, I get this error:

Screenshot 2024-04-14 at 17 04 26

My apologies in advance for flooding the comments over the weekend 😅

Best

kaggle_code.ipynb.zip

vscode_code.ipynb.zip

Originally posted by @ale-dg in https://github.com/microsoft/vscode-jupyter/issues/14459#issuecomment-2054217533

amunger commented 5 months ago

other relevant comment from the same thread:

regarding the Plotly graphs, when working with a notebook and executing several times the cells (i.e. when changing colours or adjusting elements or so), the graphs begin to render REALLY slow and, sometimes, they do not render at all. Also the notebooks keep being really large. See attached, both for seeing them not rendering and the size of the file once decompressed (around 94MB).

ale-dg commented 5 months ago

HI @amunger

Quick question, has anything moved regarding this? I have made a notebook with only 11 graphs and the size of it goes up to 110 MB, and without the graphs the size of the file is just 80 kb (even though I am loading a csv of 2.5 GB).

Thanks

Best

amunger commented 4 months ago

@ale-dg We haven't made any adjustments that would affect the file size - I believe it would be similar sizes if you were to use jupyter lab. Are you still seeing graphs failing to load correctly after the other performance changes that we made? Could you post a screenshot of what it actually looks like so I can see if I can hit the same thing.

ale-dg commented 4 months ago

@amunger I have notices a better performance on the Plotly graphs. They now render better and faster. I don't know if setting this code affected, but definitely there has been an improvement even though I am working with large files (i.e. 417413 rows and 26 columns):

import plotly.io as pio
pio.renders.default = 'vscode'

I was asking that because it blew my mind that I read a csv of 2.5 GB and the notebook without graphs is very light and when plotting blows up all the way to 100 MB.

Best

ale-dg commented 4 months ago

HI @amunger

I was checking the new stable version and was able to repro the issue with the Plotly graphs not rendering. See the screenshots below. It is strange that only a few load and the next DO load, but if I hover over the bad graphs, they show info.

Hope this helps.

Best

Screenshot 2024-05-02 at 22 03 29

Screenshot 2024-05-02 at 22 04 03

ale-dg commented 4 months ago

Btw, I just ran the same cell again, and now got this:

Screenshot 2024-05-02 at 22 13 01

Best