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
feat(pydeck): support v9 in bindings #8577
Conversation
I'm working on testing this PR locally, but currently hitting the same errors ( I'll share updates when I resolve that, but just wanted to post the update here in case it's something you'd seen already.
|
Updates on issues with local builds: |
@@ -26,4 +31,4 @@ | |||
view_state = pdk.ViewState(latitude=0, longitude=0, zoom=1) | |||
|
|||
r = pdk.Deck(layer, map_style=pdk.map_styles.ROAD, initial_view_state=view_state) | |||
r.to_html("carto_layer_geo_query.html", open_browser=True) | |||
r.to_html(join(dirname(__file__), "carto_layer_geo_query.html")) |
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.
Changed this line — in all example scripts — to ensure example output is written to the same folder as the example itself. This makes it easier to run all the example scripts together ...
make test-scripts
... and verify the output ...
npx serve examples/scripts
black==22.3.0 | ||
carto-auth>=0.2.0 | ||
flake8==4.0.1 | ||
ipython>=7.8.0 | ||
tokenize-rt>=3.2.0 | ||
twine==4.0.0 | ||
pytest-cov==3.0.0 | ||
pytest-mock==3.8.2 | ||
pytest==7.1.2 | ||
requests-mock==1.9.3 | ||
pytest-mock==3.8.2 | ||
pytest-cov==3.0.0 | ||
tokenize-rt>=3.2.0 | ||
twine==4.0.0 | ||
typing-extensions>=4.0.0 | ||
wheel==0.37.1 |
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.
Changes:
- Add
carto-auth
- Add
typing-extensions
- Sort dependencies
@@ -20,7 +20,8 @@ | |||
python_requires=">=3.7", | |||
install_requires=[ | |||
"pydeck>=0.8.0", | |||
"carto-auth>=0.1.0", | |||
"carto-auth>=0.2.0", | |||
"typing-extensions>=4.0.0", |
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.
typing-extensions
is here to support type checking in Python versions < 3.10. Currently Pydeck supports Python 3.7+. As an alternative to the dependency, we could raise the minimum version, or do without the types.
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.
This is a good time to bump the version requirements. 3.8 is a no-brainer as 3.7 is end-of-life: https://devguide.python.org/versions/
Dumb question: Do we need to support type checking in 3.8 and 3.9? Or could we just not offer that feature in those versions and document the limitation?
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 looked more into which features of typing-extensions
landed in which versions of Python, it turned out that while some typing features landed in 3.10, features we're using here landed in 3.11 and 3.12. Here are the versions for each, and what they do in pydeck:
- typing.NotRequired: Python 3.11+, allows us to mark specific options required vs. optional easily. Without this we would give up the ability for the type hints to catch missing required dependencies.
- typing.Unpack: Python 3.12+, Allows
**kwargs
to be typed, see PEP 692. Without this we would either give up the type hints, or need to explicitly duplicate all options for each of thefoo_bar_source()
functions. - typing.assert_type: Python 3.11+, convenient, but not that important to the PR.
It's too early to require Python 3.12+. I'm not sure that it's possible to support type checking in newer versions of Python in a backward-compatible way, without either publishing separate packages (non-starter) or including typing-extensions
to polyfill support, as I've done here. I'm new to type-checking in Python though, there may be options I've overlooked.
But I agree it makes sense to bump the minimum version from 3.7 → 3.8 at least, regardless of any of the above — I'll open a separate PR for that.
- EDIT: Opened chore(pydeck): Require Python 3.8+ #8811.
modules/carto/bundle.ts
Outdated
|
||
// Export CARTO library for pydeck integration. | ||
// More info: https://github.com/ajduberstein/pydeck_custom_layer | ||
globalThis.CartoLibrary = CartoUtils; |
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.
This line is also included in #8799. I've filed the separate PR because the deck.gl v9.0.x patch release could potentially happen before the pydeck changes land.
@Jesus89 @felixpalmer ready for review! If this PR will require more time, it would be helpful if we could go ahead and land #8799 to get the missing export into the next |
Published beta releases to pydeck |
0a083b6
to
eb85da3
Compare
It seems that the latest versions of jupyter + ipywidgets are not compatible with pydeck (even older versions). Also, deck.gl does not use webpack anymore to build the jupyter-widget package, so setting up jupyter-widget support will require and extra effort.
In the past, we fallback the function show() into to_html() for Google Colab because ipywidgets can not work in that environment. I would consider dropping support for ipywidgets in pydeck 0.9.0, fallback always show() into to_html() and simplify the code/docs regarding nbextension and @deck.gl/jupyter-widget. |
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.
@donmccurdy great job. LGTM ✔️
Further tests for Deck v9 in Google Colab and Streamlit environments have been working well, so merging the PR to
... my preference is also to disable the current Jupyter-specific features, publish Pydeck v0.9 without them, and regroup with pydeck community input on what could be done — both technically, and in terms of maintainer availability — to support two-way bindings moving forward. |
Implements the new @deck.gl/carto interface in pydeck-carto.
Notes on `globalThis.CartoLibrary` fix
There is a limitation to publishing pydeck 0.8.1, which relies on the following change introduced in deck.gl v8.9: https://github.com/visgl/deck.gl/pull/7546/files#diff-06477719d4b3355d7e49ba5a2a05b02da47047163a0f0cdce08df83a8dc42d38L12
This PR includes the fix, but it's likely to land in separate PRs first: