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

Use 100%cpu! work with plotly-extension and 'create a new view of output' of a chart that output by plotly. #165

Open
lumberbot-app bot opened this issue Oct 17, 2018 · 9 comments

Comments

@lumberbot-app
Copy link

lumberbot-app bot commented Oct 17, 2018

Use 100% CPU

Use 100%cpu! Work with plotly-extension. Right click an output cell -> 'create a new view of output' of a chart that output by plotly.

Steps to reproduce the behavior:

you can use this code :

import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls

trace = go.Bar(
    x = list(range(1, 5)),
    y = list(range(6, 10))
)
data = [trace]
layout = go.Layout(
    title='My Bar',
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)
  1. copy the above code to a cell
  2. ctrl + enter to run this cell
  3. right click on the output(a chart) -> click 'create a new view of output'.
  4. Then you will find it difficult to scroll the page. And chrome helper process use 100+% cpu(Same in safari).

Screenshots

2018-10-16 22 10 26

2018-10-16 22 09 44

Desktop

OS: macOS Mojave 10.14
Browser: Chrome, Safari
JupyterLab: 0.35.1


Originally opened as jupyterlab/jupyterlab#5500 by @kondongx, migration requested by @blink1073

@lumberbot-app
Copy link
Author

lumberbot-app bot commented Oct 17, 2018

@kondongx commented: I had solve this problem by using plotlywidget and uninstall plotly-extension.

Here is my solution:

  • Read this guide: Plotly migration guide. You will know what is ploylywidget doing and what is the different between plotly offline.
  • Go to ployly.py-github, find "JupyterLab Support (Python 3.5+)" section. You can follow this section and install necessary packages except install plotly-extension.

My way is a little different from the installation guide. plotly3.3.0 work fine with jupyterlab0.35.1 on my machine. I did't install jupyterlab0.34 that recommended by the installation guide. And ipywidgets, jupyter-widgets/jupyterlab-manager, plotlywidget are all lasted.

The command that I used as follows:

jupyter labextension uninstall @jupyterlab/plotly-extension

pip install ipywidgets

# (OS X/Linux :) My machine is mac)
export NODE_OPTIONS=--max-old-space-size=4096
# (Windows)
set NODE_OPTIONS=--max-old-space-size=4096

# Jupyter widgets extension
jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build

# FigureWidget support
jupyter labextension install plotlywidget --no-build

# Build extensions (must be done to activate extensions since --no-build is used above)
jupyter lab build

# Unset NODE_OPTIONS environment variable
# (OS X/Linux)
unset NODE_OPTIONS
# (Windows)
set NODE_OPTIONS=

Done.

@lumberbot-app
Copy link
Author

lumberbot-app bot commented Oct 17, 2018

@blink1073 commented: Thanks for the recap, glad you got sorted!

@lumberbot-app
Copy link
Author

lumberbot-app bot commented Oct 17, 2018

@blink1073 commented: cc @gnestor, should we deprecate plotly-extension in favor of the upstream soln?

@lumberbot-app
Copy link
Author

lumberbot-app bot commented Oct 17, 2018

@dhirschfeld commented: I asked that over at plotly/plotly.py#1054 (comment)

My current understanding is that plotly-extension is not obsolete because it provides the mime-type support needed by plotly.offline.iplot, and the support for opening .plotly.json files as plots.

plotlywidget on the other hand provides only the JupyterWidget corresponding to the new FigureWidget class.

@lumberbot-app
Copy link
Author

lumberbot-app bot commented Oct 17, 2018

@blink1073 commented: Thanks for the background, @dhirschfeld! @meeseeksdev migrate to @jupyterlab/jupyter-renderers

@lumberbot-app
Copy link
Author

lumberbot-app bot commented Oct 17, 2018

@meeseeksdev[bot] commented: I'm afraid I can't do that. Maybe I need to be installed on target repository ?
Click here to do that.

@gnestor
Copy link
Collaborator

gnestor commented Oct 17, 2018

I can't reproduce the CPU issue when running this code.

It's worth mentioning that py.init_notebook_mode(connected=True) is unnecessary with plotly-extension installed and I'm 99% certain it doesn't do anything in JupyterLab (because plotly-extension renders the application/vnd.plotly.v1 output vs. the text/html output that inserts plotly.js scripts into the document). See https://github.com/plotly/plotly.py/blob/master/plotly/offline/offline.py#L111-L147 for reference.

@LukaPitamic
Copy link

LukaPitamic commented Feb 10, 2019

same problem here!
sys: macOS Mojave 10.14.3
browser: Chrome, Safari

@LukaPitamic
Copy link

LukaPitamic commented Feb 10, 2019

solved it by migrating to v3:

  1. check compatibility list on: https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md#jupyterlab-versions

  2. Reinstall packages and extensions accordingly.
    As of Feb 10 2019:

Python Packages:

  • plotly==3.4.0
  • ipywidgets>=7.2
  • notebook>=5.3
  • jupyterlab==0.35
  • JupyterLab Extensions

JupyterLab Extensions:

  • plotlywidget@0.5.0
  • @jupyter-widgets/jupyterlab-manager@0.38
  • @jupyterlab/plotly-extension@0.18
  1. change code from:
trace = go.Bar(
    x = list(range(1, 5)),
    y = list(range(6, 10))
)
data = [trace]
layout = go.Layout(
    title='My Bar',
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)

to:

f = go.FigureWidget()
f.add_traces([
    go.Bar(
    x = list(range(1, 5)),
    y = list(range(6, 10))
)])
f.layout.title = 'My Bar'

f  # printing the widget will display it

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

No branches or pull requests

2 participants