fix(streamlit): don't require tornado on streamlit >= 1.57 - #744
Open
MohammadHijjawi97 wants to merge 1 commit into
Open
MohammadHijjawi97 wants to merge 1 commit into
MohammadHijjawi97 wants to merge 1 commit into
Conversation
Streamlit 1.57 moved its server to Starlette/uvicorn and dropped the Tornado dependency. streamlit_comm imported tornado unconditionally, so `from pygwalker.api.streamlit import StreamlitRenderer` still failed on recent Streamlit (ModuleNotFoundError: tornado) even after the make_url_path_regex fallback. Import tornado optionally and skip the Tornado handler registration when it is unavailable, so the existing Starlette route registration is used instead. Fixes Kanaries#743
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #743
Streamlit 1.57 moved its server to Starlette/uvicorn and dropped its Tornado dependency. Main already handles part of #743: it has a fallback for
make_url_path_regexand registers a Starlette route. Butpygwalker/communications/streamlit_comm.pystill importstornadounconditionally. With a current Streamlit (e.g. 1.64) and no tornado installed,from pygwalker.api.streamlit import StreamlitRendererstill fails withModuleNotFoundError: No module named 'tornado'.Changes:
PygwalkerHandleronly when tornado is available._register_tornado_handler()returnsFalse, so_hack_streamlit_server_implfalls through to the existing Starlette route registration.streamlit_commandpygwalker.api.streamlitimport cleanly and the route regex helper produces the expected pattern.Testing:
pytest tests/test_integration_apis.py: 30 passed with streamlit 1.56.0 (tornado installed) and with streamlit 1.64.0 (no tornado). The new test fails without the fix.streamlit runwithStreamlitRenderer(df).explorer()on 1.56 and on 1.64. The explorer loads andPOST /_stcore/_pygwalker/comm/<gid>returns a successful response in both.ruff checkandruff format --checkare clean on the changed files.