-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Compatibility with ipywidgets v8 #3930
Conversation
fb538e8
to
229491f
Compare
Could you please suggest how one can test this. I thus did a import plotly.graph_objects as go
f = go.FigureWidget()
f However, I do not think it could plot a FigureWidget with some scatter in it I think I would also somehow need to install the changes that you made in javascript right? |
This is what I did when building/installing the JupyterLab extension:
I would recommend doing your tests in a virtual environment. |
Thanks very much for this PR! I'll test it and try to do a release next week. Question: is this PR intended to be compatible with v8 and also backwards-compatible with v7.6? |
Thanks Nicolas.
Correct. Should work for both. |
@abdelq Besides the I also did the git clone https://github.com/abdelq/plotly.py.git
git checkout ipywidgets-8
cd plotly.py/packages/javascript/jupyterlab-plotly/
npm install
npm run build:dev
jupyter labextension install . After that I followed this: If I just wanted to display the I am no expert in JS/TS but there were no errors on the console either
Maybe I am just setting them up wrongly... |
I set up everything from scratch and ran the example notebook. |
I suppose the issue is about |
Hi. I would appreciate if this could be merged. |
Just need to do review and QA :) |
Question re JupyterLab 2.x ... At the moment 2.x is supported with ipywidgets 7.x. Does this PR in principle change that? Have you been able to test it? It's a bit of a pain as you have to build the Javascript extension and then install it separately. I will try to do this on my end but I wanted to flag this as a concern in case you know ahead of time that it's not supported with this PR. |
It looks like it works? However console errors are present, namely: I think this is worth looking at on your end too, as the former error might be an actual issue. |
Thanks! I need to do a release today but I will really try to get this PR merged and released next week. |
@abdelq it looks like your modifications correctly allow a FigureWidget display but it doesn't seem like the widget redraws when the data changes. Here's a simple example to try In one cell in jupyter lab run this: import plotly.graph_objects as go f = go.FigureWidget() and then in another cell run this: The command in the second cell doesn't update the output of the first cell. I believe in earlier versions of ipywidgets it did. (update : I just checked it on ipywidgets 7.7.1 and the second cell updated the output of the first cell) |
Using an existing function in renderers that fixes issues in classic notebooks
See jupyter-widgets/ipywidgets/pull/3124 for resize change rationale
After some debugging, Actually, I don't even think This is getting tricky. After more digging, the way mime rendering is done is quite different from the application plugin. Also, there is an issue that is related to mime rendering and updates (see #3053) Right now, doing something like this will update the original plot:
For the short term, I think getting it to use the application plugin like before is probably the way to go. |
Sorry to ask, but is there any progress going to be made soon? ;) |
Just checking in here. I would be very excited to be able to use ipywidgets v8. Is this branch functional/going to be merged in? I think this would also solve #3686 |
I've been using this at work as it is and it's working fine. |
Hi, checking in here also, would be great to see this fix released. Thanks! |
OK, I'm going to try to get this PR into the 5.12 release next week! Thanks for the contributions and the patience here :) If anyone wants to help me QA this and kick the tires, you can install the pre-release build artifacts from CircleCI and report back here if there are any problems. I'm specifically concerned about backwards-compatibility with older versions of ipywidgets and Jupyter Lab/Notebook and other notebook-like environments that support widgets. Our documentation today recommends ipywidgets 7.6 or higher so I'm not that concerned about older versions than that at this time. Thanks in advance! |
I tried this in notebook 6.4.8 and lab 3.2.9 with ipywidgets 7.7.2 to make sure it's backward compatible, and I see no issues! |
var that = this; | ||
if (msg.type === "before-attach") { | ||
window.addEventListener("resize", function () { | ||
that.autosizeFigure(); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var that = this; | |
if (msg.type === "before-attach") { | |
window.addEventListener("resize", function () { | |
that.autosizeFigure(); | |
}); | |
} | |
var that = this; | |
if (msg.type === "before-attach") { | |
window.addEventListener("resize", function () { | |
that.autosizeFigure(); | |
}); | |
} |
I guess we can remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been awhile so unsure, but if we want compatibility, probably not? This is not done in processLuminoMessage
, just in processPhosphorMessage
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the same code in _processLuminoMessage
right? (Modulo the code changes due to #3805)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this was from @nicolaskruchten's merge. Should perhaps be removed from _processLuminoMessage
... I remember there were changes to resizing events and whatnot in newer ipywidgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to ask, but is this also related to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to jupyter-widgets/ipywidgets#3124, but I think with this current PR shrinking actually works fine (worth double checking).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's please remove those lines, as they are indeed already executed in the this._processLuminoMessage
call immediately above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise we get two event listeners, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shrinking works fine for me too ;)
But inside an ipywidgets container it stilll does not really resizes correctly. Maybe what @maartenbreddels suggested, applying the [bqplot/bqplot#1531] strategy would solve the issues.
I don't wanna drag this PR too long, but for the future, using a strategy that @mariobuikhuizen used in bqplot/bqplot#1531 we can get rid of the lumini/phosphor 'callbacks'. |
OK, thanks everyone, especially @abdelq ! This'll get into the next release later this week :) |
Attempt at fixing #3686 while being compatible with the previous version.
Code PR
plotly.graph_objects
, my modifications concern thecodegen
files and not generated files.