-
Notifications
You must be signed in to change notification settings - Fork 363
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
ipywidgets 8.0 support #968
Conversation
@jasongrout I'm going to rebase this. I didn't mean to make a merge commit. |
UI tests are failing, I can also reproduce locally. But the weird thing is that when trying ipyleaflet outside of playwright's test it works just fine. |
Here is the error: Can we not just update the screenshots? |
Actually the actual output doesn't look right. It's missing the Zoom control and the layer "attribution" at the bottom right. If you look at the videos recorded by playwright show that the Zoom control is visible ~0.5 seconds then disappear. What's really weird is that @davidbrochart also sees this with xarray-leaflet, but it's using ipywidgets 7. So I'm not sure it's really ipywidgets 8 related. |
It's probably a race-condition that gets triggered more easily with ipywidgets 8 than 7 |
Note that I get this error in the console:
|
What version of ipywidgets and ipyleaflet do you have installed? base version 1.2.0 is pretty old, but so is 2.0, so this is surprising. |
ipywidgets==7.7.1 |
This should be providing
This should be good with My guess is that the message is coming from some other widget? |
Ah, I see in the video what you are saying. |
I've been trying to understand the cause of this, I found that there is an error occurring in the JavaScript console: But I'm not able to get the full traceback (I'm a Playwright newbie) |
I was able to inspect the chrome debug log with these changes: diff --git a/ui-tests/package.json b/ui-tests/package.json
index bf8aa8d..01d8ca3 100644
--- a/ui-tests/package.json
+++ b/ui-tests/package.json
@@ -8,7 +8,7 @@
"start:detached": "yarn run start&",
"clean": "rimraf tests/notebooks/.ipynb_checkpoints && rimraf test-output",
"test": "yarn run clean && playwright test",
- "test:debug": "yarn run clean && PWDEBUG=1 playwright test",
+ "test:debug": "yarn run clean && PWDEBUG=console playwright test",
"test:update": "playwright test --update-snapshots"
},
"author": "ipyleaflet",
diff --git a/ui-tests/tests/ipyleaflet.test.ts b/ui-tests/tests/ipyleaflet.test.ts
index 47c706b..0a9b465 100644
--- a/ui-tests/tests/ipyleaflet.test.ts
+++ b/ui-tests/tests/ipyleaflet.test.ts
@@ -9,6 +9,7 @@ async function renderMap(fileName: string, page: IJupyterLabPageFixture) {
await page.notebook.waitForRun();
const maps = await page.$("div.leaflet-container");
await new Promise((_) => setTimeout(_, 1000));
+ await page.pause();
expect(await maps.screenshot()).toMatchSnapshot({
name: `${fileName}.png`,
}); I got a short traceback for one of those errors, that points to this line where it seems that Looking at where state_change is defined, I see it is defined in the initialize method: https://github.com/jupyter-widgets/ipywidgets/blob/3e6e99d1a92928fe5fc8692666b2cbe5ce7a2c36/packages/base/src/widget.ts#L129 Perhaps we should set the default value of state_change inline (so it is set in the constructor) rather than waiting around until the initialize method is called. On the other hand, I'm not sure why this model is being used before its initialize method is being called. It seems to be called eventually, in that stepping through the test by hand works great. |
By the way, it looks like leaflet-heat.js and leaflet-magnifyingglass.js both use the outdated backbone extend method rather than es6 classes. |
Is there a way to use slowMo mode to see if that resolves any race condition? https://playwright.dev/docs/debug#headed-mode |
jupyter-widgets/ipywidgets#1498 changed things to set the values in |
Debugging tip: I got a good live stack trace for the error by doing |
…s used. This is causing at least one problem in the ipyleaflet 8.0 upgrade tests, as seen in jupyter-widgets/ipyleaflet#968
jupyter-widgets/ipywidgets#3549 should fix the instance of this bug that I saw. |
Based on jupyter-widgets/ipywidgets#3549, I think this is a race condition. Here's what I think is happening:
We don't see this race condition when we are interacting at human speeds because the kernel state request is answered before code is run and widgets are created (i.e., at human speeds, steps 2 and 3 are reversed, so we don't go down the problematic code path) @martinRenou - can you review jupyter-widgets/ipywidgets#3549? |
Thanks a lot for investigating this! |
I created a widget from widget-ts-cookiecutter with |
With ipyspin I also have this error:
|
Actually, even an
|
Pinning |
I think jupyter-widgets/ipywidgets#3551 then fixes this. |
I've released jupyterlab_widgets 3.0.2 with this fix. |
Testing against the ipywidgets 8 bugfix, most of the screenshots now look okay (the main change being that the attribution font seems to be larger now) except for:
I'm not sure if there are errors in those cases, but can I turn the investigation back over to you, @martinRenou? |
@davidbrochart - I just released ipywidgets 7.7.2 that contains jupyter-widgets/ipywidgets#3551 - can you see if that fixes things for you? Basically, it pulls in jupyterlab_widgets 1 instead of jupyterlab_widgets 3. I saw that if you were using conda-forge, it was already pulling in the correct dependencies, so we were really only fixing the pypi package with the change above. Also, if you pinned the version of jupyterlab_widgets explicitly, it hopefully would have fixed things for you. |
Yes, I checked that it works in a fresh environment by removing |
Thanks for checking our fix! |
Looks like in the magnifying case, the zoom level should have made the map blank, but for some reason the expected image actually showed a zoom level as if it was set to something like 1. I've reset the zoom level in the source to see if the new image made more sense. Also, we show the magnifying glass in the expected, but not actual - perhaps the mouse pointer is moved somewhere else in actual? For the tile layer, for some reason again the actual is a blank map (which I think is correct from doing it manually, it seems to be zoomed into blank ocean), while the expected shows a zoomed in plot I think of England. I've also reset the zoom in this case to show more of the world. |
I've set the zoom level to be quite high (in the sea) because the image providers tend to change slightly from time to time: moving street names around, changing font size slightly etc. Making our tests very flaky. The sea color not changing much it was more reliable to test against it. |
Sure! Thanks a lot for investigating the issues. I'll make sure to make the UI-tests pass and release ipyleaflet. |
Please update galata references |
Ah, that makes a lot of sense. Feel free to change the zoom level back if you like. When I see a blank map, I'm never sure if it is just zoomed in to sea, or if the tile layer didn't load or something. |
The only test update that still looks odd is ui-tests/tests/ipyleaflet.test.ts-snapshots/MagnifyingGlass-linux.png, where the magnifying glass used to be visible, but now it is not. I tried using playwright to move the mouse onto the map to see if it made the glass visible, but it didn't seem to work. It does seem that the magnifying glass is visible when trying an example by hand, though. |
Thanks! We should probably remove the magnifying glass test then... Probably something changed upstream that makes it not appear anymore. If we can't move the mouse programmatically let's not fight too much. |
FYI, this is the change I tried. I didn't investigate too much past making this change and looking at the test result, though, so it's possible the change is wrong and it actually isn't moving the mouse like I intended: diff --git a/ui-tests/tests/ipyleaflet.test.ts b/ui-tests/tests/ipyleaflet.test.ts
index 47c706b..3ac2b7c 100644
--- a/ui-tests/tests/ipyleaflet.test.ts
+++ b/ui-tests/tests/ipyleaflet.test.ts
@@ -9,7 +9,9 @@ async function renderMap(fileName: string, page: IJupyterLabPageFixture) {
await page.notebook.waitForRun();
const maps = await page.$("div.leaflet-container");
await new Promise((_) => setTimeout(_, 1000));
- expect(await maps.screenshot()).toMatchSnapshot({
+ const bb = (maps as any).getClientBoundingBox();
+ await page.mouse.move(bb.top + bb.height / 2, bb.left + bb.width / 2);
+ expect(await maps!.screenshot()).toMatchSnapshot({
name: `${fileName}.png`,
});
} |
Thanks! It looks like you switched the x and y coordinates? I will try with: const bb = (maps as any).getClientBoundingBox();
await page.mouse.move(bb.left + bb.width / 2, bb.top + bb.height / 2);
expect(await maps!.screenshot()).toMatchSnapshot({
... |
Please update galata references |
Oops, I think you're right. I also wasn't for sure if I was using the right origin/orientation for the coordinates. |
Please update galata references |
Let's gooo! Thank you @jasongrout ! |
I bumped the version of ipywidgets packages to the 8.0rc0 releases, and things seem to just work.
I also dropped python 3.6 support.