From 00c67ac9df61b6beaae4cca2d5e816648ac6b642 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Sun, 11 Feb 2024 15:47:04 +0900 Subject: [PATCH 1/2] Revert the http patch --- .../py/stlite-server/stlite_server/bootstrap.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/kernel/py/stlite-server/stlite_server/bootstrap.py b/packages/kernel/py/stlite-server/stlite_server/bootstrap.py index 636da4d6a..857eb9987 100644 --- a/packages/kernel/py/stlite-server/stlite_server/bootstrap.py +++ b/packages/kernel/py/stlite-server/stlite_server/bootstrap.py @@ -144,6 +144,16 @@ def _import_pyarrow_interchange(): logger.error("Failed to fix Altair", exc_info=e) +def _fix_requests(): + try: + import pyodide_http # type: ignore[import] + + pyodide_http.patch_all() # Patch all libraries + except ImportError: + # pyodide_http is not installed. No need to do anything. + pass + + def prepare( main_script_path: str, args: List[str], @@ -156,6 +166,7 @@ def prepare( _fix_sys_path(main_script_path) _fix_matplotlib_crash() _fix_altair() + _fix_requests() _fix_sys_argv(main_script_path, args) _fix_pydeck_mapbox_api_warning() _install_pages_watcher(main_script_path) From 6967ab9e820cc52e417cefca1adfa7c5efb26cc1 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Sun, 11 Feb 2024 16:30:21 +0900 Subject: [PATCH 2/2] Revert packages/sharing-editor/public/samples/010_streamlit_hello/pages/2_Mapping_Demo.py to the original code using `pd.read_csv()` without `pyodide.http` --- .../samples/010_streamlit_hello/pages/2_Mapping_Demo.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/sharing-editor/public/samples/010_streamlit_hello/pages/2_Mapping_Demo.py b/packages/sharing-editor/public/samples/010_streamlit_hello/pages/2_Mapping_Demo.py index efc4758c8..d04e6e35e 100644 --- a/packages/sharing-editor/public/samples/010_streamlit_hello/pages/2_Mapping_Demo.py +++ b/packages/sharing-editor/public/samples/010_streamlit_hello/pages/2_Mapping_Demo.py @@ -21,8 +21,6 @@ import streamlit as st from streamlit.hello.utils import show_code -import pyodide.http # We need to use `pyodide.http` in the Pyodide environment for network communications. See https://pyodide.org/en/stable/usage/faq.html#how-can-i-load-external-files-in-pyodide - def mapping_demo(): @st.cache_data @@ -31,8 +29,7 @@ def from_data_file(filename): "https://raw.githubusercontent.com/streamlit/" "example-data/master/hello/v1/%s" % filename ) - # return pd.read_json(url) - return pd.read_json(pyodide.http.open_url(url)) + return pd.read_json(url) try: ALL_LAYERS = {