streamlit 1.47.0__py3-none-any.whl → 1.48.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/cli_util.py +1 -1
- streamlit/commands/echo.py +2 -2
- streamlit/commands/execution_control.py +1 -1
- streamlit/commands/page_config.py +16 -16
- streamlit/components/v1/component_arrow.py +4 -4
- streamlit/config.py +23 -5
- streamlit/connections/base_connection.py +2 -2
- streamlit/connections/snowflake_connection.py +2 -2
- streamlit/connections/sql_connection.py +4 -3
- streamlit/dataframe_util.py +1 -1
- streamlit/deprecation_util.py +20 -5
- streamlit/elements/arrow.py +105 -79
- streamlit/elements/deck_gl_json_chart.py +6 -6
- streamlit/elements/dialog_decorator.py +72 -17
- streamlit/elements/form.py +36 -7
- streamlit/elements/graphviz_chart.py +7 -0
- streamlit/elements/json.py +3 -3
- streamlit/elements/layouts.py +241 -75
- streamlit/elements/lib/built_in_chart_utils.py +11 -3
- streamlit/elements/lib/dialog.py +43 -0
- streamlit/elements/lib/file_uploader_utils.py +21 -2
- streamlit/elements/lib/layout_utils.py +88 -2
- streamlit/elements/lib/options_selector_utils.py +1 -1
- streamlit/elements/lib/utils.py +23 -3
- streamlit/elements/map.py +12 -11
- streamlit/elements/plotly_chart.py +21 -21
- streamlit/elements/pyplot.py +8 -4
- streamlit/elements/vega_charts.py +237 -143
- streamlit/elements/widgets/audio_input.py +2 -2
- streamlit/elements/widgets/button.py +147 -35
- streamlit/elements/widgets/button_group.py +9 -8
- streamlit/elements/widgets/camera_input.py +2 -2
- streamlit/elements/widgets/chat.py +8 -2
- streamlit/elements/widgets/checkbox.py +4 -4
- streamlit/elements/widgets/color_picker.py +2 -2
- streamlit/elements/widgets/data_editor.py +22 -15
- streamlit/elements/widgets/file_uploader.py +8 -2
- streamlit/elements/widgets/multiselect.py +27 -17
- streamlit/elements/widgets/number_input.py +2 -2
- streamlit/elements/widgets/radio.py +5 -4
- streamlit/elements/widgets/select_slider.py +8 -5
- streamlit/elements/widgets/selectbox.py +14 -4
- streamlit/elements/widgets/slider.py +59 -33
- streamlit/elements/widgets/text_widgets.py +4 -4
- streamlit/elements/widgets/time_widgets.py +4 -4
- streamlit/elements/write.py +9 -8
- streamlit/env_util.py +1 -1
- streamlit/errors.py +20 -4
- streamlit/file_util.py +1 -1
- streamlit/git_util.py +1 -1
- streamlit/logger.py +2 -2
- streamlit/proto/Block_pb2.py +39 -31
- streamlit/proto/Block_pb2.pyi +54 -3
- streamlit/proto/Button_pb2.py +4 -2
- streamlit/proto/Button_pb2.pyi +1 -0
- streamlit/runtime/caching/cache_data_api.py +15 -2
- streamlit/runtime/caching/cache_errors.py +1 -1
- streamlit/runtime/caching/cache_resource_api.py +24 -2
- streamlit/runtime/caching/cache_utils.py +6 -3
- streamlit/runtime/caching/hashing.py +6 -9
- streamlit/runtime/fragment.py +3 -2
- streamlit/runtime/runtime.py +19 -2
- streamlit/runtime/scriptrunner/script_runner.py +3 -3
- streamlit/runtime/state/common.py +2 -1
- streamlit/runtime/state/query_params.py +2 -1
- streamlit/runtime/state/session_state.py +1 -1
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +231 -231
- streamlit/static/static/css/index.CQt5TjGB.css +1 -0
- streamlit/static/static/js/{ErrorOutline.esm.bg5MMAri.js → ErrorOutline.esm.D_4oFNKB.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.ZD5PIl3I.js → FileDownload.esm.NPgaLlUE.js} +1 -1
- streamlit/static/static/js/{FileHelper.B6jszxAn.js → FileHelper.B2t9ikoS.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DuzI-rET.js → FormClearHelper.BLEIUk6L.js} +1 -1
- streamlit/static/static/js/{Hooks.qKXFrFZm.js → Hooks.BGm9sd4U.js} +1 -1
- streamlit/static/static/js/{InputInstructions.7NdlV9ze.js → InputInstructions.DtUxCBS8.js} +1 -1
- streamlit/static/static/js/Particles.BDRPO7r3.js +1 -0
- streamlit/static/static/js/ProgressBar.B64DUUqp.js +2 -0
- streamlit/static/static/js/Toolbar.B3FquPk5.js +1 -0
- streamlit/static/static/js/{base-input.Dl5fJ2xw.js → base-input.DeBqm5mN.js} +4 -4
- streamlit/static/static/js/{checkbox.DCoT7yTn.js → checkbox.C0odQfKb.js} +2 -2
- streamlit/static/static/js/createDownloadLinkElement.ZaXNnPK4.js +1 -0
- streamlit/static/static/js/{createSuper.DIDXPRra.js → createSuper.DqQ5L3XG.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.DbNsQa8Y.js +1 -0
- streamlit/static/static/js/{downloader.DKv2kGmf.js → downloader.Bx1D0jhz.js} +1 -1
- streamlit/static/static/js/{es6.JcohG4tM.js → es6.CbPK4m0H.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.3rtAterA.js → iframeResizer.contentWindow.CfLKrptA.js} +1 -1
- streamlit/static/static/js/{index.BO22lkaO.js → index.0XDwe9RV.js} +12 -12
- streamlit/static/static/js/{index.Wj4EUfiO.js → index.4lI9TuZm.js} +3 -3
- streamlit/static/static/js/index.6s0nVIis.js +3855 -0
- streamlit/static/static/js/index.9E7bRUBU.js +1 -0
- streamlit/static/static/js/index.B9PgeLrZ.js +1 -0
- streamlit/static/static/js/index.B9vzGbOt.js +1 -0
- streamlit/static/static/js/index.BDrQKMCm.js +1 -0
- streamlit/static/static/js/index.BPsoiGgP.js +1 -0
- streamlit/static/static/js/index.CJzdLAun.js +1 -0
- streamlit/static/static/js/index.CNNlC1NL.js +1 -0
- streamlit/static/static/js/index.CO1sClzJ.js +2 -0
- streamlit/static/static/js/index.CZnagxXD.js +1 -0
- streamlit/static/static/js/{index.CnNERm7h.js → index.Cb0xSF7V.js} +289 -289
- streamlit/static/static/js/index.CgUt3tz_.js +1 -0
- streamlit/static/static/js/index.CjImmcsV.js +1 -0
- streamlit/static/static/js/index.ClRTsv8m.js +2 -0
- streamlit/static/static/js/{index.DBhELRFO.js → index.CnfWsQzS.js} +1 -1
- streamlit/static/static/js/index.CrJ1XD_V.js +1 -0
- streamlit/static/static/js/index.CtiKsjSC.js +1 -0
- streamlit/static/static/js/index.CwAuytgV.js +1 -0
- streamlit/static/static/js/index.D7GB-kly.js +1 -0
- streamlit/static/static/js/index.DA5wU0mQ.js +1 -0
- streamlit/static/static/js/{index.BVTVGhCW.js → index.DCpyIFTV.js} +1 -1
- streamlit/static/static/js/{index.Brmdn6cI.js → index.DE9wNOje.js} +1 -1
- streamlit/static/static/js/{index.B4UgLnfD.js → index.DHnB-C8A.js} +1 -1
- streamlit/static/static/js/{index.DmB_1wAI.js → index.DRTn9zvD.js} +1 -1
- streamlit/static/static/js/index.DjMjyJl9.js +7 -0
- streamlit/static/static/js/{index.BTGIlECR.js → index.DvRPFfw6.js} +162 -188
- streamlit/static/static/js/{index.BlIoUPom.js → index.DwaoC4Zp.js} +3 -3
- streamlit/static/static/js/index.F9tSej94.js +1 -0
- streamlit/static/static/js/index.HeVbRh9H.js +73 -0
- streamlit/static/static/js/index.J2D_m7LY.js +197 -0
- streamlit/static/static/js/index.PyIqRRSR.js +1 -0
- streamlit/static/static/js/index.dfivzJNz.js +1 -0
- streamlit/static/static/js/index.mRztGO69.js +3 -0
- streamlit/static/static/js/index.tB1kn_7z.js +1 -0
- streamlit/static/static/js/index.wDYef4mQ.js +12 -0
- streamlit/static/static/js/{input.vCGI-j0z.js → input.BL2buuce.js} +2 -2
- streamlit/static/static/js/{memory.CAr59PeX.js → memory.CUxjUWS7.js} +1 -1
- streamlit/static/static/js/{mergeWith.KUX-f18q.js → mergeWith.C1kp1zIi.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.7_qeQYbF.js → number-overlay-editor.WpheGpmR.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.ChgdWjjy.js → possibleConstructorReturn.DbvQboK3.js} +1 -1
- streamlit/static/static/js/{sandbox.6mITyM_H.js → sandbox.6lnFVWhX.js} +1 -1
- streamlit/static/static/js/{timepicker.BlKW9Kob.js → timepicker.Bg4xAK95.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DkNUwUhg.js → toConsumableArray.D9x7Ktv4.js} +1 -1
- streamlit/static/static/js/{uniqueId.BW6icrs1.js → uniqueId.Bm8FHN92.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.oPxte5Mj.js → useBasicWidgetState.CUSYQZpm.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.s7ZXp9QC.js → useTextInputAutoExpand.Bf2egQOG.js} +2 -2
- streamlit/static/static/js/useUpdateUiValue.lE5xnYWF.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.CCOXR7N6.js +1 -0
- streamlit/temporary_directory.py +5 -3
- streamlit/testing/v1/app_test.py +4 -1
- streamlit/testing/v1/element_tree.py +4 -5
- streamlit/type_util.py +10 -3
- streamlit/user_info.py +18 -14
- streamlit/util.py +11 -1
- streamlit/watcher/local_sources_watcher.py +4 -3
- streamlit/web/bootstrap.py +18 -12
- streamlit/web/cli.py +2 -1
- streamlit/web/server/oauth_authlib_routes.py +59 -3
- streamlit/web/server/routes.py +3 -0
- streamlit/web/server/server.py +72 -21
- {streamlit-1.47.0.dist-info → streamlit-1.48.0.dist-info}/METADATA +14 -2
- {streamlit-1.47.0.dist-info → streamlit-1.48.0.dist-info}/RECORD +154 -154
- streamlit/static/static/css/index.CsLB_Bnz.css +0 -1
- streamlit/static/static/js/ProgressBar.d6X6RRog.js +0 -2
- streamlit/static/static/js/RenderInPortalIfExists.DEmedSWH.js +0 -1
- streamlit/static/static/js/Toolbar.D8wuuqZd.js +0 -1
- streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.Bxxjm6-o.js +0 -1
- streamlit/static/static/js/index.0dTVhOfX.js +0 -1
- streamlit/static/static/js/index.4yEdNndV.js +0 -1
- streamlit/static/static/js/index.5n6QoSUA.js +0 -1
- streamlit/static/static/js/index.6nngkCAa.js +0 -2
- streamlit/static/static/js/index.94f3Fw7s.js +0 -1
- streamlit/static/static/js/index.B61tWuMK.js +0 -73
- streamlit/static/static/js/index.B7u9Flh8.js +0 -1
- streamlit/static/static/js/index.BASsihSP.js +0 -1
- streamlit/static/static/js/index.BL9HK8jG.js +0 -1
- streamlit/static/static/js/index.BQWRZ6al.js +0 -3855
- streamlit/static/static/js/index.BQXddtYi.js +0 -1
- streamlit/static/static/js/index.BUnHfDxu.js +0 -1
- streamlit/static/static/js/index.BWQlvt-p.js +0 -1
- streamlit/static/static/js/index.BhB2h-IN.js +0 -1
- streamlit/static/static/js/index.BjbAdGl1.js +0 -2
- streamlit/static/static/js/index.BqMXJWvY.js +0 -197
- streamlit/static/static/js/index.BteAxTUz.js +0 -1
- streamlit/static/static/js/index.ByH19tU7.js +0 -1
- streamlit/static/static/js/index.CH_JROvL.js +0 -1
- streamlit/static/static/js/index.CRMaL4_D.js +0 -1
- streamlit/static/static/js/index.CitqAWcf.js +0 -7
- streamlit/static/static/js/index.DNTjV0h_.js +0 -3
- streamlit/static/static/js/index.Df2TZ_h-.js +0 -1
- streamlit/static/static/js/index.GID7Wiqx.js +0 -1
- streamlit/static/static/js/index.hprQgsHY.js +0 -1
- streamlit/static/static/js/index.mJxNfDOA.js +0 -12
- streamlit/static/static/js/index.qkxYEW65.js +0 -1
- streamlit/static/static/js/useOnInputChange.CBaDeGVQ.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.DkugyWpW.js +0 -1
- {streamlit-1.47.0.data → streamlit-1.48.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.47.0.dist-info → streamlit-1.48.0.dist-info}/WHEEL +0 -0
- {streamlit-1.47.0.dist-info → streamlit-1.48.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.47.0.dist-info → streamlit-1.48.0.dist-info}/top_level.txt +0 -0
streamlit/cli_util.py
CHANGED
streamlit/commands/echo.py
CHANGED
|
@@ -19,7 +19,7 @@ import contextlib
|
|
|
19
19
|
import re
|
|
20
20
|
import textwrap
|
|
21
21
|
import traceback
|
|
22
|
-
from typing import TYPE_CHECKING, Any, Literal
|
|
22
|
+
from typing import TYPE_CHECKING, Any, Literal, cast
|
|
23
23
|
|
|
24
24
|
from streamlit.runtime.metrics_util import gather_metrics
|
|
25
25
|
|
|
@@ -81,7 +81,7 @@ def echo(
|
|
|
81
81
|
for child in ast.iter_child_nodes(node):
|
|
82
82
|
# If child doesn't have "lineno", it is not something we could display
|
|
83
83
|
if hasattr(child, "lineno"):
|
|
84
|
-
line_to_node_map[child.lineno] = child
|
|
84
|
+
line_to_node_map[cast("int", child.lineno)] = child
|
|
85
85
|
collect_body_statements(child)
|
|
86
86
|
|
|
87
87
|
collect_body_statements(root_node)
|
|
@@ -103,7 +103,7 @@ def _new_fragment_id_queue(
|
|
|
103
103
|
def rerun( # type: ignore[misc]
|
|
104
104
|
*, # The scope argument can only be passed via keyword.
|
|
105
105
|
scope: Literal["app", "fragment"] = "app",
|
|
106
|
-
) -> NoReturn:
|
|
106
|
+
) -> NoReturn: # ty: ignore[invalid-return-type]
|
|
107
107
|
"""Rerun the script immediately.
|
|
108
108
|
|
|
109
109
|
When ``st.rerun()`` is called, Streamlit halts the current script run and
|
|
@@ -194,21 +194,19 @@ def set_page_config(
|
|
|
194
194
|
|
|
195
195
|
menu_items: dict
|
|
196
196
|
Configure the menu that appears on the top-right side of this app.
|
|
197
|
-
The keys in this dict denote the menu item
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
- "
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
To remove an item that was specified in a previous call to
|
|
211
|
-
``st.set_page_config``, set its value to ``None`` in the dictionary.
|
|
197
|
+
The keys in this dict denote the menu item to configure. The following
|
|
198
|
+
keys can have string or ``None`` values:
|
|
199
|
+
|
|
200
|
+
- "Get help": The URL this menu item should point to.
|
|
201
|
+
- "Report a Bug": The URL this menu item should point to.
|
|
202
|
+
- "About": A markdown string to show in the About dialog.
|
|
203
|
+
|
|
204
|
+
A URL may also refer to an email address e.g. ``mailto:john@example.com``.
|
|
205
|
+
|
|
206
|
+
If you do not include a key, its menu item will be hidden (unless it
|
|
207
|
+
was set by a previous call to ``st.set_page_config``). To remove an
|
|
208
|
+
item that was specified in a previous call to ``st.set_page_config``,
|
|
209
|
+
set its value to ``None`` in the dictionary.
|
|
212
210
|
|
|
213
211
|
Example
|
|
214
212
|
-------
|
|
@@ -301,7 +299,9 @@ def set_menu_items_proto(
|
|
|
301
299
|
|
|
302
300
|
if ABOUT_KEY in lowercase_menu_items:
|
|
303
301
|
if lowercase_menu_items[ABOUT_KEY] is not None:
|
|
304
|
-
menu_items_proto.about_section_md = dedent(
|
|
302
|
+
menu_items_proto.about_section_md = dedent(
|
|
303
|
+
lowercase_menu_items[ABOUT_KEY] or ""
|
|
304
|
+
)
|
|
305
305
|
else:
|
|
306
306
|
# For multiple calls to set_page_config, clears previously set about markdown
|
|
307
307
|
menu_items_proto.clear_about_md = True
|
|
@@ -72,8 +72,8 @@ def _marshall_index(proto: ArrowTableProto, index: Index) -> None:
|
|
|
72
72
|
"""
|
|
73
73
|
import pandas as pd
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
index_df = pd.DataFrame(
|
|
75
|
+
index_values = map(_maybe_tuple_to_list, index.values)
|
|
76
|
+
index_df = pd.DataFrame(index_values)
|
|
77
77
|
proto.index = dataframe_util.convert_pandas_df_to_arrow_bytes(index_df)
|
|
78
78
|
|
|
79
79
|
|
|
@@ -92,8 +92,8 @@ def _marshall_columns(proto: ArrowTableProto, columns: Series) -> None:
|
|
|
92
92
|
"""
|
|
93
93
|
import pandas as pd
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
columns_df = pd.DataFrame(
|
|
95
|
+
values = map(_maybe_tuple_to_list, columns.values)
|
|
96
|
+
columns_df = pd.DataFrame(values)
|
|
97
97
|
proto.columns = dataframe_util.convert_pandas_df_to_arrow_bytes(columns_df)
|
|
98
98
|
|
|
99
99
|
|
streamlit/config.py
CHANGED
|
@@ -36,8 +36,8 @@ from streamlit.errors import StreamlitAPIException
|
|
|
36
36
|
# Descriptions of each of the possible config sections.
|
|
37
37
|
# (We use OrderedDict to make the order in which sections are declared in this
|
|
38
38
|
# file be the same order as the sections appear with `streamlit config show`)
|
|
39
|
-
_section_descriptions:
|
|
40
|
-
_test="Special test section just used for unit tests."
|
|
39
|
+
_section_descriptions: OrderedDict[str, str] = OrderedDict( # ty: ignore
|
|
40
|
+
_test="Special test section just used for unit tests." # ty: ignore
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
# Ensures that we don't try to get or set config options when config.toml files
|
|
@@ -925,6 +925,24 @@ _create_option(
|
|
|
925
925
|
type_=bool,
|
|
926
926
|
)
|
|
927
927
|
|
|
928
|
+
_create_option(
|
|
929
|
+
"server.websocketPingInterval",
|
|
930
|
+
description="""
|
|
931
|
+
The interval (in seconds) at which the server pings the client to keep
|
|
932
|
+
the websocket connection alive.
|
|
933
|
+
|
|
934
|
+
The default value should work for most deployments. However, if you're
|
|
935
|
+
experiencing frequent disconnections in certain proxy setups (e.g.,
|
|
936
|
+
"Connection error" messages), you may want to try adjusting this value.
|
|
937
|
+
|
|
938
|
+
Note: When you set this option, Streamlit automatically sets the ping
|
|
939
|
+
timeout to match this interval. For Tornado >=6.5, a value less than 30
|
|
940
|
+
may cause connection issues.
|
|
941
|
+
""",
|
|
942
|
+
default_val=None,
|
|
943
|
+
type_=int,
|
|
944
|
+
)
|
|
945
|
+
|
|
928
946
|
_create_option(
|
|
929
947
|
"server.enableStaticServing",
|
|
930
948
|
description="""
|
|
@@ -1364,13 +1382,13 @@ _create_theme_options(
|
|
|
1364
1382
|
|
|
1365
1383
|
_create_theme_options(
|
|
1366
1384
|
"codeFontWeight",
|
|
1367
|
-
categories=["theme"],
|
|
1385
|
+
categories=["theme", CustomThemeCategories.SIDEBAR],
|
|
1368
1386
|
description="""
|
|
1369
1387
|
The font weight for code blocks and code text.
|
|
1370
1388
|
|
|
1371
1389
|
This applies to font in inline code, code blocks, `st.json`, and
|
|
1372
1390
|
`st.help`. This is an integer multiple of 100. Values can be between
|
|
1373
|
-
100 and
|
|
1391
|
+
100 and 600, inclusive.
|
|
1374
1392
|
|
|
1375
1393
|
If this isn't set, the code font weight will be 400 (normal weight).
|
|
1376
1394
|
""",
|
|
@@ -1884,7 +1902,7 @@ def get_config_options(
|
|
|
1884
1902
|
# Short-circuit if config files were parsed while we were waiting on
|
|
1885
1903
|
# the lock.
|
|
1886
1904
|
if _config_options and not force_reparse:
|
|
1887
|
-
return _config_options
|
|
1905
|
+
return _config_options # ty: ignore[invalid-return-type]
|
|
1888
1906
|
|
|
1889
1907
|
old_options = _config_options
|
|
1890
1908
|
_config_options = copy.deepcopy(_config_options_template)
|
|
@@ -109,11 +109,11 @@ class BaseConnection(ABC, Generic[RawConnectionT]):
|
|
|
109
109
|
are implementing their class' ``_connect`` method. User scripts should, for the
|
|
110
110
|
most part, have no reason to use this property.
|
|
111
111
|
"""
|
|
112
|
-
connections_section = None
|
|
112
|
+
connections_section: AttrDict | None = None
|
|
113
113
|
if secrets_singleton.load_if_toml_exists():
|
|
114
114
|
connections_section = secrets_singleton.get("connections")
|
|
115
115
|
|
|
116
|
-
if type(connections_section) is not AttrDict:
|
|
116
|
+
if connections_section is None or type(connections_section) is not AttrDict:
|
|
117
117
|
return AttrDict({})
|
|
118
118
|
|
|
119
119
|
return connections_section.get(self._connection_name, AttrDict({}))
|
|
@@ -68,10 +68,10 @@ class SnowflakeConnection(BaseConnection["InternalSnowflakeConnection"]):
|
|
|
68
68
|
.. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
|
|
69
69
|
.. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
|
|
70
70
|
|
|
71
|
-
..
|
|
71
|
+
.. Important::
|
|
72
72
|
`snowflake-snowpark-python <https://pypi.org/project/snowflake-snowpark-python/>`_
|
|
73
73
|
must be installed in your environment to use this connection. You can
|
|
74
|
-
install
|
|
74
|
+
install it as an extra with Streamlit:
|
|
75
75
|
|
|
76
76
|
>>> pip install streamlit[snowflake]
|
|
77
77
|
|
|
@@ -178,6 +178,7 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
|
178
178
|
|
|
179
179
|
def _connect(self, autocommit: bool = False, **kwargs: Any) -> Engine:
|
|
180
180
|
import sqlalchemy
|
|
181
|
+
from sqlalchemy.engine import URL, make_url
|
|
181
182
|
|
|
182
183
|
kwargs = deepcopy(kwargs)
|
|
183
184
|
conn_param_kwargs = extract_from_dict(_ALL_CONNECTION_PARAMS, kwargs)
|
|
@@ -190,7 +191,7 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
|
190
191
|
)
|
|
191
192
|
|
|
192
193
|
if "url" in conn_params:
|
|
193
|
-
url =
|
|
194
|
+
url = make_url(conn_params["url"])
|
|
194
195
|
else:
|
|
195
196
|
for p in _REQUIRED_CONNECTION_PARAMS:
|
|
196
197
|
if p not in conn_params:
|
|
@@ -200,7 +201,7 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
|
200
201
|
f"+{conn_params['driver']}" if "driver" in conn_params else ""
|
|
201
202
|
)
|
|
202
203
|
|
|
203
|
-
url =
|
|
204
|
+
url = URL.create(
|
|
204
205
|
drivername=drivername,
|
|
205
206
|
username=conn_params["username"],
|
|
206
207
|
password=conn_params.get("password"),
|
|
@@ -217,7 +218,7 @@ class SQLConnection(BaseConnection["Engine"]):
|
|
|
217
218
|
|
|
218
219
|
if autocommit:
|
|
219
220
|
return cast("Engine", eng.execution_options(isolation_level="AUTOCOMMIT"))
|
|
220
|
-
return cast("Engine", eng)
|
|
221
|
+
return cast("Engine", eng) # ty: ignore[redundant-cast]
|
|
221
222
|
|
|
222
223
|
def query(
|
|
223
224
|
self,
|
streamlit/dataframe_util.py
CHANGED
|
@@ -1076,7 +1076,7 @@ def is_colum_type_arrow_incompatible(column: Series[Any] | Index) -> bool:
|
|
|
1076
1076
|
return True
|
|
1077
1077
|
|
|
1078
1078
|
# Get the first value to check if it is a supported list-like type.
|
|
1079
|
-
first_value = column.iloc[0]
|
|
1079
|
+
first_value = cast("DataFrameGenericAlias[Any]", column).iloc[0]
|
|
1080
1080
|
|
|
1081
1081
|
if ( # noqa: SIM103
|
|
1082
1082
|
not is_list_like(first_value)
|
streamlit/deprecation_util.py
CHANGED
|
@@ -27,14 +27,25 @@ TFunc = TypeVar("TFunc", bound=Callable[..., Any])
|
|
|
27
27
|
TObj = TypeVar("TObj", bound=object)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def
|
|
30
|
+
def _error_details_in_browser_enabled() -> bool:
|
|
31
31
|
"""True if we should print deprecation warnings to the browser."""
|
|
32
32
|
return bool(config.get_option("client.showErrorDetails"))
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def show_deprecation_warning(message: str) -> None:
|
|
36
|
-
"""Show a deprecation warning message.
|
|
37
|
-
|
|
35
|
+
def show_deprecation_warning(message: str, show_in_browser: bool = True) -> None:
|
|
36
|
+
"""Show a deprecation warning message.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
message : str
|
|
41
|
+
The deprecation warning message.
|
|
42
|
+
show_in_browser : bool, default=True
|
|
43
|
+
Whether to show the deprecation warning in the browser. When this is True,
|
|
44
|
+
we will show the deprecation warning in the browser unless the user has
|
|
45
|
+
disabled error details in the browser by setting the `client.showErrorDetails`
|
|
46
|
+
config option to "none".
|
|
47
|
+
"""
|
|
48
|
+
if _error_details_in_browser_enabled() and show_in_browser:
|
|
38
49
|
streamlit.warning(message)
|
|
39
50
|
|
|
40
51
|
# We always log deprecation warnings
|
|
@@ -97,7 +108,11 @@ def deprecate_func_name(
|
|
|
97
108
|
result = func(*args, **kwargs)
|
|
98
109
|
show_deprecation_warning(
|
|
99
110
|
make_deprecated_name_warning(
|
|
100
|
-
old_name,
|
|
111
|
+
old_name,
|
|
112
|
+
name_override
|
|
113
|
+
or (str(func.__name__) if hasattr(func, "__name__") else "unknown"),
|
|
114
|
+
removal_date,
|
|
115
|
+
extra_message,
|
|
101
116
|
)
|
|
102
117
|
)
|
|
103
118
|
return result
|
streamlit/elements/arrow.py
CHANGED
|
@@ -38,6 +38,9 @@ from streamlit.elements.lib.column_config_utils import (
|
|
|
38
38
|
update_column_config,
|
|
39
39
|
)
|
|
40
40
|
from streamlit.elements.lib.form_utils import current_form_id
|
|
41
|
+
from streamlit.elements.lib.layout_utils import (
|
|
42
|
+
LayoutConfig,
|
|
43
|
+
)
|
|
41
44
|
from streamlit.elements.lib.pandas_styler_utils import marshall_styler
|
|
42
45
|
from streamlit.elements.lib.policies import check_widget_policies
|
|
43
46
|
from streamlit.elements.lib.utils import Key, compute_and_register_element_id, to_key
|
|
@@ -104,17 +107,16 @@ class DataframeSelectionState(TypedDict, total=False):
|
|
|
104
107
|
Try selecting some rows. To select multiple columns, hold ``Ctrl`` while
|
|
105
108
|
selecting columns. Hold ``Shift`` to select a range of columns.
|
|
106
109
|
|
|
107
|
-
>>> import streamlit as st
|
|
108
110
|
>>> import pandas as pd
|
|
109
|
-
>>> import
|
|
111
|
+
>>> import streamlit as st
|
|
112
|
+
>>> from numpy.random import default_rng as rng
|
|
110
113
|
>>>
|
|
111
|
-
>>>
|
|
112
|
-
|
|
113
|
-
...
|
|
114
|
-
... )
|
|
114
|
+
>>> df = pd.DataFrame(
|
|
115
|
+
... rng(0).standard_normal((12, 5)), columns=["a", "b", "c", "d", "e"]
|
|
116
|
+
... )
|
|
115
117
|
>>>
|
|
116
118
|
>>> event = st.dataframe(
|
|
117
|
-
...
|
|
119
|
+
... df,
|
|
118
120
|
... key="data",
|
|
119
121
|
... on_select="rerun",
|
|
120
122
|
... selection_mode=["multi-row", "multi-column"],
|
|
@@ -438,13 +440,15 @@ class ArrowMixin:
|
|
|
438
440
|
--------
|
|
439
441
|
**Example 1: Display a dataframe**
|
|
440
442
|
|
|
441
|
-
>>> import streamlit as st
|
|
442
443
|
>>> import pandas as pd
|
|
443
|
-
>>> import
|
|
444
|
+
>>> import streamlit as st
|
|
445
|
+
>>> from numpy.random import default_rng as rng
|
|
444
446
|
>>>
|
|
445
|
-
>>> df = pd.DataFrame(
|
|
447
|
+
>>> df = pd.DataFrame(
|
|
448
|
+
... rng(0).standard_normal((50, 20)), columns=("col %d" % i for i in range(20))
|
|
449
|
+
... )
|
|
446
450
|
>>>
|
|
447
|
-
>>> st.dataframe(df)
|
|
451
|
+
>>> st.dataframe(df)
|
|
448
452
|
|
|
449
453
|
.. output::
|
|
450
454
|
https://doc-dataframe.streamlit.app/
|
|
@@ -455,11 +459,13 @@ class ArrowMixin:
|
|
|
455
459
|
You can also pass a Pandas Styler object to change the style of
|
|
456
460
|
the rendered DataFrame:
|
|
457
461
|
|
|
458
|
-
>>> import streamlit as st
|
|
459
462
|
>>> import pandas as pd
|
|
460
|
-
>>> import
|
|
463
|
+
>>> import streamlit as st
|
|
464
|
+
>>> from numpy.random import default_rng as rng
|
|
461
465
|
>>>
|
|
462
|
-
>>> df = pd.DataFrame(
|
|
466
|
+
>>> df = pd.DataFrame(
|
|
467
|
+
... rng(0).standard_normal((10, 20)), columns=("col %d" % i for i in range(20))
|
|
468
|
+
... )
|
|
463
469
|
>>>
|
|
464
470
|
>>> st.dataframe(df.style.highlight_max(axis=0))
|
|
465
471
|
|
|
@@ -471,34 +477,39 @@ class ArrowMixin:
|
|
|
471
477
|
|
|
472
478
|
You can customize a dataframe via ``column_config``, ``hide_index``, or ``column_order``.
|
|
473
479
|
|
|
474
|
-
>>> import random
|
|
475
480
|
>>> import pandas as pd
|
|
476
481
|
>>> import streamlit as st
|
|
482
|
+
>>> from numpy.random import default_rng as rng
|
|
477
483
|
>>>
|
|
478
484
|
>>> df = pd.DataFrame(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
485
|
+
... {
|
|
486
|
+
... "name": ["Roadmap", "Extras", "Issues"],
|
|
487
|
+
... "url": [
|
|
488
|
+
... "https://roadmap.streamlit.app",
|
|
489
|
+
... "https://extras.streamlit.app",
|
|
490
|
+
... "https://issues.streamlit.app",
|
|
491
|
+
... ],
|
|
492
|
+
... "stars": rng(0).integers(0, 1000, size=3),
|
|
493
|
+
... "views_history": rng(0).integers(0, 5000, size=(3, 30)).tolist(),
|
|
494
|
+
... }
|
|
495
|
+
... )
|
|
496
|
+
>>>
|
|
486
497
|
>>> st.dataframe(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
498
|
+
... df,
|
|
499
|
+
... column_config={
|
|
500
|
+
... "name": "App name",
|
|
501
|
+
... "stars": st.column_config.NumberColumn(
|
|
502
|
+
... "Github Stars",
|
|
503
|
+
... help="Number of stars on GitHub",
|
|
504
|
+
... format="%d ⭐",
|
|
505
|
+
... ),
|
|
506
|
+
... "url": st.column_config.LinkColumn("App URL"),
|
|
507
|
+
... "views_history": st.column_config.LineChartColumn(
|
|
508
|
+
... "Views (past 30 days)", y_min=0, y_max=5000
|
|
509
|
+
... ),
|
|
510
|
+
... },
|
|
511
|
+
... hide_index=True,
|
|
512
|
+
... )
|
|
502
513
|
|
|
503
514
|
.. output::
|
|
504
515
|
https://doc-dataframe-config.streamlit.app/
|
|
@@ -508,22 +519,28 @@ class ArrowMixin:
|
|
|
508
519
|
|
|
509
520
|
You can use column configuration to format your index.
|
|
510
521
|
|
|
511
|
-
>>> import
|
|
522
|
+
>>> from datetime import datetime, date
|
|
523
|
+
>>> import numpy as np
|
|
512
524
|
>>> import pandas as pd
|
|
513
|
-
>>>
|
|
525
|
+
>>> import streamlit as st
|
|
514
526
|
>>>
|
|
515
|
-
>>>
|
|
516
|
-
>>>
|
|
517
|
-
>>>
|
|
518
|
-
>>>
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
527
|
+
>>> @st.cache_data
|
|
528
|
+
>>> def load_data():
|
|
529
|
+
>>> year = datetime.now().year
|
|
530
|
+
>>> df = pd.DataFrame(
|
|
531
|
+
... {
|
|
532
|
+
... "Date": [date(year, month, 1) for month in range(1, 4)],
|
|
533
|
+
... "Total": np.random.randint(1000, 5000, size=3),
|
|
534
|
+
... }
|
|
535
|
+
... )
|
|
536
|
+
>>> df.set_index("Date", inplace=True)
|
|
537
|
+
>>> return df
|
|
522
538
|
>>>
|
|
539
|
+
>>> df = load_data()
|
|
523
540
|
>>> config = {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
541
|
+
... "_index": st.column_config.DateColumn("Month", format="MMM YYYY"),
|
|
542
|
+
... "Total": st.column_config.NumberColumn("Total ($)"),
|
|
543
|
+
... }
|
|
527
544
|
>>>
|
|
528
545
|
>>> st.dataframe(df, column_config=config)
|
|
529
546
|
|
|
@@ -677,12 +694,13 @@ class ArrowMixin:
|
|
|
677
694
|
--------
|
|
678
695
|
**Example 1: Display a simple dataframe as a static table**
|
|
679
696
|
|
|
680
|
-
>>> import streamlit as st
|
|
681
697
|
>>> import pandas as pd
|
|
682
|
-
>>> import
|
|
698
|
+
>>> import streamlit as st
|
|
699
|
+
>>> from numpy.random import default_rng as rng
|
|
683
700
|
>>>
|
|
684
701
|
>>> df = pd.DataFrame(
|
|
685
|
-
...
|
|
702
|
+
... rng(0).standard_normal(size=(10, 5)),
|
|
703
|
+
... columns=("col %d" % i for i in range(5)),
|
|
686
704
|
... )
|
|
687
705
|
>>>
|
|
688
706
|
>>> st.table(df)
|
|
@@ -693,19 +711,22 @@ class ArrowMixin:
|
|
|
693
711
|
|
|
694
712
|
**Example 2: Display a table of Markdown strings**
|
|
695
713
|
|
|
696
|
-
>>> import streamlit as st
|
|
697
714
|
>>> import pandas as pd
|
|
715
|
+
>>> import streamlit as st
|
|
698
716
|
>>>
|
|
699
717
|
>>> df = pd.DataFrame(
|
|
700
718
|
... {
|
|
701
719
|
... "Command": ["**st.table**", "*st.dataframe*"],
|
|
702
720
|
... "Type": ["`static`", "`interactive`"],
|
|
703
721
|
... "Docs": [
|
|
704
|
-
... "[:rainbow[docs]](https://docs.streamlit.io
|
|
705
|
-
... "
|
|
722
|
+
... "[:rainbow[docs]](https://docs.streamlit.io"
|
|
723
|
+
... "/develop/api-reference/data/st.dataframe)",
|
|
724
|
+
... "[:open_book:](https://docs.streamlit.io"
|
|
725
|
+
... "/develop/api-reference/data/st.table)",
|
|
706
726
|
... ],
|
|
707
727
|
... }
|
|
708
728
|
... )
|
|
729
|
+
>>>
|
|
709
730
|
>>> st.table(df)
|
|
710
731
|
|
|
711
732
|
.. output::
|
|
@@ -728,9 +749,16 @@ class ArrowMixin:
|
|
|
728
749
|
delta_path = self.dg._get_delta_path_str()
|
|
729
750
|
default_uuid = str(hash(delta_path))
|
|
730
751
|
|
|
752
|
+
# Tables dimensions are not configurable, this ensures that
|
|
753
|
+
# styles are applied correctly on the element container in the frontend.
|
|
754
|
+
layout_config = LayoutConfig(
|
|
755
|
+
width="stretch",
|
|
756
|
+
height="content",
|
|
757
|
+
)
|
|
758
|
+
|
|
731
759
|
proto = ArrowProto()
|
|
732
760
|
marshall(proto, data, default_uuid)
|
|
733
|
-
return self.dg._enqueue("arrow_table", proto)
|
|
761
|
+
return self.dg._enqueue("arrow_table", proto, layout_config=layout_config)
|
|
734
762
|
|
|
735
763
|
@gather_metrics("add_rows")
|
|
736
764
|
def add_rows(self, data: Data = None, **kwargs: Any) -> DeltaGenerator | None:
|
|
@@ -747,32 +775,30 @@ class ArrowMixin:
|
|
|
747
775
|
|
|
748
776
|
Example
|
|
749
777
|
-------
|
|
750
|
-
>>> import
|
|
778
|
+
>>> import time
|
|
751
779
|
>>> import pandas as pd
|
|
752
|
-
>>> import
|
|
780
|
+
>>> import streamlit as st
|
|
781
|
+
>>> from numpy.random import default_rng as rng
|
|
753
782
|
>>>
|
|
754
783
|
>>> df1 = pd.DataFrame(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
>>>
|
|
758
|
-
>>> my_table = st.table(df1)
|
|
784
|
+
>>> rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
|
|
785
|
+
>>> )
|
|
759
786
|
>>>
|
|
760
787
|
>>> df2 = pd.DataFrame(
|
|
761
|
-
|
|
762
|
-
|
|
788
|
+
>>> rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
|
|
789
|
+
>>> )
|
|
763
790
|
>>>
|
|
791
|
+
>>> my_table = st.table(df1)
|
|
792
|
+
>>> time.sleep(1)
|
|
764
793
|
>>> my_table.add_rows(df2)
|
|
765
|
-
>>> # Now the table shown in the Streamlit app contains the data for
|
|
766
|
-
>>> # df1 followed by the data for df2.
|
|
767
794
|
|
|
768
795
|
You can do the same thing with plots. For example, if you want to add
|
|
769
796
|
more data to a line chart:
|
|
770
797
|
|
|
771
798
|
>>> # Assuming df1 and df2 from the example above still exist...
|
|
772
799
|
>>> my_chart = st.line_chart(df1)
|
|
800
|
+
>>> time.sleep(1)
|
|
773
801
|
>>> my_chart.add_rows(df2)
|
|
774
|
-
>>> # Now the chart shown in the Streamlit app contains the data for
|
|
775
|
-
>>> # df1 followed by the data for df2.
|
|
776
802
|
|
|
777
803
|
And for plots whose datasets are named, you can pass the data with a
|
|
778
804
|
keyword argument where the key is the name:
|
|
@@ -838,30 +864,30 @@ def _arrow_add_rows(
|
|
|
838
864
|
|
|
839
865
|
Example
|
|
840
866
|
-------
|
|
841
|
-
>>> import
|
|
867
|
+
>>> import time
|
|
842
868
|
>>> import pandas as pd
|
|
843
|
-
>>> import
|
|
869
|
+
>>> import streamlit as st
|
|
870
|
+
>>> from numpy.random import default_rng as rng
|
|
844
871
|
>>>
|
|
845
872
|
>>> df1 = pd.DataFrame(
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
>>> my_table = st.table(df1)
|
|
873
|
+
>>> rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
|
|
874
|
+
>>> )
|
|
849
875
|
>>>
|
|
850
876
|
>>> df2 = pd.DataFrame(
|
|
851
|
-
|
|
852
|
-
|
|
877
|
+
>>> rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
|
|
878
|
+
>>> )
|
|
879
|
+
>>>
|
|
880
|
+
>>> my_table = st.table(df1)
|
|
881
|
+
>>> time.sleep(1)
|
|
853
882
|
>>> my_table.add_rows(df2)
|
|
854
|
-
>>> # Now the table shown in the Streamlit app contains the data for
|
|
855
|
-
>>> # df1 followed by the data for df2.
|
|
856
883
|
|
|
857
884
|
You can do the same thing with plots. For example, if you want to add
|
|
858
885
|
more data to a line chart:
|
|
859
886
|
|
|
860
887
|
>>> # Assuming df1 and df2 from the example above still exist...
|
|
861
888
|
>>> my_chart = st.line_chart(df1)
|
|
889
|
+
>>> time.sleep(1)
|
|
862
890
|
>>> my_chart.add_rows(df2)
|
|
863
|
-
>>> # Now the chart shown in the Streamlit app contains the data for
|
|
864
|
-
>>> # df1 followed by the data for df2.
|
|
865
891
|
|
|
866
892
|
And for plots whose datasets are named, you can pass the data with a
|
|
867
893
|
keyword argument where the key is the name:
|
|
@@ -410,13 +410,13 @@ class PydeckMixin:
|
|
|
410
410
|
Here's a chart using a HexagonLayer and a ScatterplotLayer. It uses either the
|
|
411
411
|
light or dark map style, based on which Streamlit theme is currently active:
|
|
412
412
|
|
|
413
|
-
>>> import streamlit as st
|
|
414
413
|
>>> import pandas as pd
|
|
415
|
-
>>> import numpy as np
|
|
416
414
|
>>> import pydeck as pdk
|
|
415
|
+
>>> import streamlit as st
|
|
416
|
+
>>> from numpy.random import default_rng as rng
|
|
417
417
|
>>>
|
|
418
|
-
>>>
|
|
419
|
-
...
|
|
418
|
+
>>> df = pd.DataFrame(
|
|
419
|
+
... rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
|
|
420
420
|
... columns=["lat", "lon"],
|
|
421
421
|
... )
|
|
422
422
|
>>>
|
|
@@ -432,7 +432,7 @@ class PydeckMixin:
|
|
|
432
432
|
... layers=[
|
|
433
433
|
... pdk.Layer(
|
|
434
434
|
... "HexagonLayer",
|
|
435
|
-
... data=
|
|
435
|
+
... data=df,
|
|
436
436
|
... get_position="[lon, lat]",
|
|
437
437
|
... radius=200,
|
|
438
438
|
... elevation_scale=4,
|
|
@@ -442,7 +442,7 @@ class PydeckMixin:
|
|
|
442
442
|
... ),
|
|
443
443
|
... pdk.Layer(
|
|
444
444
|
... "ScatterplotLayer",
|
|
445
|
-
... data=
|
|
445
|
+
... data=df,
|
|
446
446
|
... get_position="[lon, lat]",
|
|
447
447
|
... get_color="[200, 30, 0, 160]",
|
|
448
448
|
... get_radius=200,
|