streamlit-nightly 1.43.3.dev20250312__py3-none-any.whl → 1.43.3.dev20250313__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/auth_util.py +2 -1
- streamlit/commands/experimental_query_params.py +1 -1
- streamlit/commands/logo.py +3 -3
- streamlit/components/v1/__init__.py +1 -3
- streamlit/config.py +3 -2
- streamlit/config_option.py +1 -3
- streamlit/connections/snowflake_connection.py +0 -1
- streamlit/connections/sql_connection.py +0 -1
- streamlit/dataframe_util.py +7 -6
- streamlit/delta_generator_singletons.py +2 -2
- streamlit/elements/arrow.py +0 -1
- streamlit/elements/exception.py +3 -1
- streamlit/elements/form.py +3 -3
- streamlit/elements/json.py +2 -2
- streamlit/elements/layouts.py +0 -5
- streamlit/elements/lib/built_in_chart_utils.py +1 -2
- streamlit/elements/lib/column_config_utils.py +0 -3
- streamlit/elements/lib/column_types.py +6 -39
- streamlit/elements/lib/image_utils.py +2 -1
- streamlit/elements/lib/options_selector_utils.py +6 -3
- streamlit/elements/lib/subtitle_utils.py +2 -0
- streamlit/elements/lib/utils.py +0 -2
- streamlit/elements/media.py +2 -1
- streamlit/elements/metric.py +0 -1
- streamlit/elements/progress.py +1 -1
- streamlit/elements/text.py +2 -2
- streamlit/elements/vega_charts.py +2 -1
- streamlit/elements/widgets/audio_input.py +2 -1
- streamlit/elements/widgets/button.py +0 -1
- streamlit/elements/widgets/button_group.py +2 -3
- streamlit/elements/widgets/data_editor.py +2 -3
- streamlit/elements/widgets/slider.py +1 -1
- streamlit/elements/widgets/text_widgets.py +1 -0
- streamlit/elements/write.py +0 -1
- streamlit/errors.py +4 -2
- streamlit/external/langchain/streamlit_callback_handler.py +1 -2
- streamlit/file_util.py +4 -2
- streamlit/navigation/page.py +0 -1
- streamlit/platform.py +1 -3
- streamlit/runtime/caching/cache_data_api.py +5 -5
- streamlit/runtime/caching/cache_errors.py +1 -1
- streamlit/runtime/caching/cache_resource_api.py +4 -4
- streamlit/runtime/caching/cache_utils.py +6 -4
- streamlit/runtime/caching/storage/cache_storage_protocol.py +6 -6
- streamlit/runtime/caching/storage/dummy_cache_storage.py +2 -2
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +6 -6
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -6
- streamlit/runtime/connection_factory.py +0 -1
- streamlit/runtime/context.py +1 -1
- streamlit/runtime/credentials.py +1 -1
- streamlit/runtime/forward_msg_cache.py +1 -1
- streamlit/runtime/forward_msg_queue.py +2 -1
- streamlit/runtime/fragment.py +2 -1
- streamlit/runtime/memory_media_file_storage.py +2 -2
- streamlit/runtime/metrics_util.py +2 -2
- streamlit/runtime/runtime_util.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +1 -1
- streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
- streamlit/runtime/scriptrunner_utils/script_run_context.py +1 -0
- streamlit/runtime/secrets.py +5 -3
- streamlit/runtime/state/common.py +1 -1
- streamlit/runtime/state/safe_session_state.py +1 -1
- streamlit/runtime/state/session_state.py +4 -3
- streamlit/runtime/stats.py +1 -1
- streamlit/runtime/uploaded_file_manager.py +4 -3
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.C9csNfwR.js → FileDownload.esm.imTamlxP.js} +1 -1
- streamlit/static/static/js/{FileHelper.CTWNHaVI.js → FileHelper.BwPSCUvG.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.1VkFJY3v.js → FormClearHelper.DB5q2Avl.js} +1 -1
- streamlit/static/static/js/{Hooks.vPqq3xQ5.js → Hooks.Cxijo2P7.js} +1 -1
- streamlit/static/static/js/{InputInstructions.7jABRwB0.js → InputInstructions.B3OvMrKL.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BWY8ITDS.js → ProgressBar.DmTol130.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.CP_sn1OG.js → RenderInPortalIfExists.B8t62565.js} +1 -1
- streamlit/static/static/js/{Toolbar.DzqMcgvB.js → Toolbar.CbG49UPG.js} +1 -1
- streamlit/static/static/js/{base-input.DjuthXF0.js → base-input.D7sJ1S2g.js} +1 -1
- streamlit/static/static/js/{checkbox.BddRUN3_.js → checkbox.0Qx7AQxA.js} +1 -1
- streamlit/static/static/js/{createSuper.BAGgahBq.js → createSuper.DYiyAta_.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.Bscjz8_-.js → data-grid-overlay-editor.DH61CZYo.js} +1 -1
- streamlit/static/static/js/{downloader.BgDSv-Ig.js → downloader.ClUad3SK.js} +1 -1
- streamlit/static/static/js/{es6.3kVHyEdR.js → es6.oePMPTIo.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.n2oqEwdf.js → iframeResizer.contentWindow.DWkIX4K7.js} +1 -1
- streamlit/static/static/js/{index.C8ZHYetm.js → index.1VrMb7Gq.js} +1 -1
- streamlit/static/static/js/{index.zrNj-omI.js → index.62zz5frt.js} +1 -1
- streamlit/static/static/js/{index.k2DDVmzp.js → index.BJRyQckV.js} +1 -1
- streamlit/static/static/js/{index.CrZncPLs.js → index.BQVZQA1G.js} +1 -1
- streamlit/static/static/js/{index.UJT9uVs_.js → index.BSZRb65z.js} +1 -1
- streamlit/static/static/js/{index.N6CP_9Qh.js → index.BUJE3tb_.js} +1 -1
- streamlit/static/static/js/{index.mMuChmJi.js → index.BWsaTYC-.js} +1 -1
- streamlit/static/static/js/{index.ChDimwy6.js → index.BccrUqFL.js} +1 -1
- streamlit/static/static/js/{index.CFbiFnmq.js → index.BhzKPoO6.js} +1 -1
- streamlit/static/static/js/{index.FJszpQ-y.js → index.BpNXx3zc.js} +5 -5
- streamlit/static/static/js/{index.B1ZLFKil.js → index.BzEstIKX.js} +1 -1
- streamlit/static/static/js/{index.j6cgFK9c.js → index.C-ilKj2l.js} +1 -1
- streamlit/static/static/js/{index.D3EE2F77.js → index.CCAIkxXD.js} +2367 -1541
- streamlit/static/static/js/{index.S_LaABz9.js → index.CEXlj4h2.js} +1 -1
- streamlit/static/static/js/{index.CYrF9jN2.js → index.CEtBn4Yo.js} +1 -1
- streamlit/static/static/js/{index.D3uVQMaA.js → index.CM7PC5PD.js} +1 -1
- streamlit/static/static/js/{index.Dv6XiWKs.js → index.CSLXWDcG.js} +1 -1
- streamlit/static/static/js/{index.Cj7yHfOR.js → index.CqywW5KK.js} +1 -1
- streamlit/static/static/js/{index.D7k3QVrz.js → index.CyRCgpSs.js} +1 -1
- streamlit/static/static/js/{index.pEU90S1o.js → index.CzFs8nXc.js} +3 -3
- streamlit/static/static/js/{index.DAghU1FB.js → index.Czxn5B2N.js} +1 -1
- streamlit/static/static/js/{index.B8IuPu4x.js → index.D0OLo5Dp.js} +1 -1
- streamlit/static/static/js/{index.BaYVwylD.js → index.D2JlVfHE.js} +1 -1
- streamlit/static/static/js/{index.OtBp-Blq.js → index.DJRmF7dm.js} +1 -1
- streamlit/static/static/js/{index.C28BRw13.js → index.Dd9D963h.js} +1 -1
- streamlit/static/static/js/{index.DAAc9Gb3.js → index.DhcpqbOJ.js} +1 -1
- streamlit/static/static/js/{index.DbI6X421.js → index.DlEF0vUx.js} +1 -1
- streamlit/static/static/js/{index.BNTyamf9.js → index.DnJimAdR.js} +1 -1
- streamlit/static/static/js/{index.BfTunuGf.js → index.DoqMrowT.js} +1 -1
- streamlit/static/static/js/{index.BPcgpI5G.js → index.DqsHy8ck.js} +1 -1
- streamlit/static/static/js/{index.3k9e_sFT.js → index.DtS10fdK.js} +1 -1
- streamlit/static/static/js/{index.BQXOwXQG.js → index.XZw2NTV4.js} +1 -1
- streamlit/static/static/js/{index.svH5ea22.js → index.YB9Oe71d.js} +1 -1
- streamlit/static/static/js/{index.DlXteNnv.js → index.axjxDsFs.js} +1 -1
- streamlit/static/static/js/{index.Bd5GUMH8.js → index.kB2IGVOe.js} +1 -1
- streamlit/static/static/js/{index.0JqsAt5p.js → index.tVO_vJdT.js} +1 -1
- streamlit/static/static/js/{index.CrjCtGqg.js → index.uPQFE7KD.js} +1 -1
- streamlit/static/static/js/{input.A7Xel5Mz.js → input.od7ufwko.js} +1 -1
- streamlit/static/static/js/{memory.DKAi1aOw.js → memory.B4tdC6o-.js} +1 -1
- streamlit/static/static/js/{mergeWith.BOXngkwE.js → mergeWith.BIQlVIWW.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.Dr9nZLr4.js → number-overlay-editor.yJDCpy9b.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.Dmq70n5Q.js → possibleConstructorReturn.CarGSmuW.js} +1 -1
- streamlit/static/static/js/{sandbox.OiNVhKVk.js → sandbox.DMCKOK6i.js} +1 -1
- streamlit/static/static/js/{textarea.BvcErhuX.js → textarea.CKKbJt6B.js} +1 -1
- streamlit/static/static/js/{timepicker.BndxQ_56.js → timepicker.BgsARtBm.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.Bvyh5k2t.js → toConsumableArray.DXHhbr1a.js} +1 -1
- streamlit/static/static/js/{uniqueId.BJXawxf6.js → uniqueId.Cb5oTCCd.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.-z6NaxAe.js → useBasicWidgetState.8rZ80dWq.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.DvBUKld6.js → useOnInputChange.Bc5KC47X.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.CubK7zml.js → withFullScreenWrapper.CSP3iCNz.js} +1 -1
- streamlit/string_util.py +3 -2
- streamlit/testing/v1/element_tree.py +30 -30
- streamlit/testing/v1/util.py +2 -1
- streamlit/time_util.py +1 -3
- streamlit/type_util.py +2 -1
- streamlit/user_info.py +0 -1
- streamlit/watcher/event_based_path_watcher.py +1 -1
- streamlit/web/bootstrap.py +3 -1
- streamlit/web/cache_storage_manager_config.py +1 -1
- streamlit/web/cli.py +2 -2
- streamlit/web/server/authlib_tornado_integration.py +1 -1
- streamlit/web/server/browser_websocket_handler.py +2 -1
- streamlit/web/server/routes.py +2 -2
- streamlit/web/server/server_util.py +2 -4
- {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/RECORD +151 -151
- {streamlit_nightly-1.43.3.dev20250312.data → streamlit_nightly-1.43.3.dev20250313.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.43.3.dev20250312.dist-info → streamlit_nightly-1.43.3.dev20250313.dist-info}/top_level.txt +0 -0
streamlit/elements/lib/utils.py
CHANGED
@@ -114,7 +114,6 @@ def _register_element_id(
|
|
114
114
|
|
115
115
|
Parameters
|
116
116
|
----------
|
117
|
-
|
118
117
|
element_type : str
|
119
118
|
The type of the element to register.
|
120
119
|
|
@@ -123,7 +122,6 @@ def _register_element_id(
|
|
123
122
|
|
124
123
|
Raises
|
125
124
|
------
|
126
|
-
|
127
125
|
StreamlitDuplicateElementKey
|
128
126
|
If the element key is not unique.
|
129
127
|
|
streamlit/elements/media.py
CHANGED
@@ -693,7 +693,8 @@ def _validate_and_normalize(data: npt.NDArray[Any]) -> tuple[bytes, int]:
|
|
693
693
|
|
694
694
|
def _make_wav(data: npt.NDArray[Any], sample_rate: int) -> bytes:
|
695
695
|
"""
|
696
|
-
Transform a numpy array to a PCM bytestring
|
696
|
+
Transform a numpy array to a PCM bytestring.
|
697
|
+
|
697
698
|
We use code from IPython display module to convert numpy array to wave bytes
|
698
699
|
https://github.com/ipython/ipython/blob/1015c392f3d50cf4ff3e9f29beede8c1abfdcb2a/IPython/lib/display.py#L146
|
699
700
|
"""
|
streamlit/elements/metric.py
CHANGED
streamlit/elements/progress.py
CHANGED
@@ -35,7 +35,7 @@ FloatOrInt: TypeAlias = Union[int, float]
|
|
35
35
|
def _check_float_between(value: float, low: float = 0.0, high: float = 1.0) -> bool:
|
36
36
|
"""
|
37
37
|
Checks given value is 'between' the bounds of [low, high],
|
38
|
-
considering close values around bounds are acceptable input
|
38
|
+
considering close values around bounds are acceptable input.
|
39
39
|
|
40
40
|
Notes
|
41
41
|
-----
|
streamlit/elements/text.py
CHANGED
@@ -33,7 +33,7 @@ class TextMixin:
|
|
33
33
|
*, # keyword-only arguments:
|
34
34
|
help: str | None = None,
|
35
35
|
) -> DeltaGenerator:
|
36
|
-
"""Write text without Markdown or HTML parsing.
|
36
|
+
r"""Write text without Markdown or HTML parsing.
|
37
37
|
|
38
38
|
For monospace text, use |st.code|_.
|
39
39
|
|
@@ -57,7 +57,7 @@ class TextMixin:
|
|
57
57
|
-------
|
58
58
|
>>> import streamlit as st
|
59
59
|
>>>
|
60
|
-
>>> st.text("This is text
|
60
|
+
>>> st.text("This is text\n[and more text](that's not a Markdown link).")
|
61
61
|
|
62
62
|
.. output ::
|
63
63
|
https://doc-text.streamlit.app/
|
@@ -287,7 +287,8 @@ def _marshall_chart_data(
|
|
287
287
|
data: Data = None,
|
288
288
|
) -> None:
|
289
289
|
"""Adds the data to the proto and removes it from the spec dict.
|
290
|
-
These operations will happen in-place.
|
290
|
+
These operations will happen in-place.
|
291
|
+
"""
|
291
292
|
|
292
293
|
# Pull data out of spec dict when it's in a 'datasets' key:
|
293
294
|
# datasets: {foo: df1_bytes, bar: df2_bytes}, ...}
|
@@ -218,7 +218,8 @@ class AudioInputMixin:
|
|
218
218
|
label_visibility: LabelVisibility = "visible",
|
219
219
|
) -> UploadedFile | None:
|
220
220
|
"""Deprecated alias for st.audio_input.
|
221
|
-
See the docstring for the widget's new name.
|
221
|
+
See the docstring for the widget's new name.
|
222
|
+
"""
|
222
223
|
|
223
224
|
show_deprecation_warning(
|
224
225
|
make_deprecated_name_warning(
|
@@ -537,7 +537,6 @@ class ButtonGroupMixin:
|
|
537
537
|
|
538
538
|
Examples
|
539
539
|
--------
|
540
|
-
|
541
540
|
**Example 1: Multi-select pills**
|
542
541
|
|
543
542
|
Display a multi-select pills widget, and show the selection:
|
@@ -747,7 +746,6 @@ class ButtonGroupMixin:
|
|
747
746
|
|
748
747
|
Examples
|
749
748
|
--------
|
750
|
-
|
751
749
|
**Example 1: Multi-select segmented control**
|
752
750
|
|
753
751
|
Display a multi-select segmented control widget, and show the
|
@@ -831,7 +829,8 @@ class ButtonGroupMixin:
|
|
831
829
|
|
832
830
|
def _transformed_format_func(option: V) -> ButtonGroupProto.Option:
|
833
831
|
"""If option starts with a material icon or an emoji, we extract it to send
|
834
|
-
it parsed to the frontend.
|
832
|
+
it parsed to the frontend.
|
833
|
+
"""
|
835
834
|
transformed = format_func(option) if format_func else str(option)
|
836
835
|
transformed_parts = transformed.split(" ")
|
837
836
|
icon: str | None = None
|
@@ -392,13 +392,11 @@ def _is_supported_index(df_index: pd.Index) -> bool:
|
|
392
392
|
|
393
393
|
Parameters
|
394
394
|
----------
|
395
|
-
|
396
395
|
df_index : pd.Index
|
397
396
|
The index to check.
|
398
397
|
|
399
398
|
Returns
|
400
399
|
-------
|
401
|
-
|
402
400
|
bool
|
403
401
|
True if the index is supported, False otherwise.
|
404
402
|
"""
|
@@ -426,7 +424,8 @@ def _is_supported_index(df_index: pd.Index) -> bool:
|
|
426
424
|
|
427
425
|
def _fix_column_headers(data_df: pd.DataFrame) -> None:
|
428
426
|
"""Fix the column headers of the provided dataframe inplace to work
|
429
|
-
correctly for data editing.
|
427
|
+
correctly for data editing.
|
428
|
+
"""
|
430
429
|
import pandas as pd
|
431
430
|
|
432
431
|
if isinstance(data_df.columns, pd.MultiIndex):
|
@@ -145,7 +145,7 @@ def _datetime_to_micros(dt: datetime) -> int:
|
|
145
145
|
|
146
146
|
|
147
147
|
def _micros_to_datetime(micros: int, orig_tz: tzinfo | None) -> datetime:
|
148
|
-
"""Restore times/datetimes to original timezone (dates are always naive)"""
|
148
|
+
"""Restore times/datetimes to original timezone (dates are always naive)."""
|
149
149
|
utc_dt = UTC_EPOCH + timedelta(microseconds=micros)
|
150
150
|
# Add the original timezone. No conversion is required here,
|
151
151
|
# since in the serialization, we also just replace the timestamp with UTC.
|
@@ -485,6 +485,7 @@ class TextWidgetsMixin:
|
|
485
485
|
is ``"hidden"``, Streamlit displays an empty spacer instead of the
|
486
486
|
label, which can help keep the widget alligned with other widgets.
|
487
487
|
If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
488
|
+
|
488
489
|
Returns
|
489
490
|
-------
|
490
491
|
str or None
|
streamlit/elements/write.py
CHANGED
streamlit/errors.py
CHANGED
@@ -43,7 +43,8 @@ class DeprecationError(Error):
|
|
43
43
|
|
44
44
|
class FragmentStorageKeyError(Error, KeyError):
|
45
45
|
"""A KeyError raised when a KeyError is encountered during a FragmentStorage
|
46
|
-
operation.
|
46
|
+
operation.
|
47
|
+
"""
|
47
48
|
|
48
49
|
pass
|
49
50
|
|
@@ -150,7 +151,8 @@ class StreamlitAPIWarning(StreamlitAPIException, Warning):
|
|
150
151
|
|
151
152
|
class StreamlitModuleNotFoundError(StreamlitAPIWarning):
|
152
153
|
"""Print a pretty message when a Streamlit command requires a dependency
|
153
|
-
that is not one of our core dependencies.
|
154
|
+
that is not one of our core dependencies.
|
155
|
+
"""
|
154
156
|
|
155
157
|
def __init__(self, module_name, *args):
|
156
158
|
message = (
|
@@ -170,7 +170,7 @@ class LLMThought:
|
|
170
170
|
|
171
171
|
@property
|
172
172
|
def last_tool(self) -> ToolRecord | None:
|
173
|
-
"""The last tool executed by this thought"""
|
173
|
+
"""The last tool executed by this thought."""
|
174
174
|
return self._last_tool
|
175
175
|
|
176
176
|
def _reset_llm_token_stream(self) -> None:
|
@@ -286,7 +286,6 @@ class StreamlitCallbackHandler(BaseCallbackHandler):
|
|
286
286
|
|
287
287
|
Parameters
|
288
288
|
----------
|
289
|
-
|
290
289
|
parent_container
|
291
290
|
The `st.container` that will contain all the Streamlit elements that the
|
292
291
|
Handler creates.
|
streamlit/file_util.py
CHANGED
@@ -89,7 +89,9 @@ def streamlit_read(path, binary=False):
|
|
89
89
|
@contextlib.contextmanager
|
90
90
|
def streamlit_write(path, binary=False):
|
91
91
|
"""Opens a file for writing within the streamlit path, and
|
92
|
-
ensuring that the path exists.
|
92
|
+
ensuring that the path exists.
|
93
|
+
|
94
|
+
For example:
|
93
95
|
|
94
96
|
with streamlit_write('foo/bar.txt') as bar:
|
95
97
|
...
|
@@ -125,7 +127,7 @@ def get_static_dir() -> str:
|
|
125
127
|
|
126
128
|
|
127
129
|
def get_app_static_dir(main_script_path: str) -> str:
|
128
|
-
"""Get the folder where app static files live"""
|
130
|
+
"""Get the folder where app static files live."""
|
129
131
|
main_script_path = Path(main_script_path)
|
130
132
|
static_dir = main_script_path.parent / APP_STATIC_FOLDER_NAME
|
131
133
|
return os.path.abspath(static_dir)
|
streamlit/navigation/page.py
CHANGED
streamlit/platform.py
CHANGED
@@ -21,9 +21,7 @@ from streamlit.runtime.scriptrunner_utils.script_run_context import get_script_r
|
|
21
21
|
|
22
22
|
|
23
23
|
def post_parent_message(message: str) -> None:
|
24
|
-
"""
|
25
|
-
Sends a string message to the parent window (when host configuration allows).
|
26
|
-
"""
|
24
|
+
"""Sends a string message to the parent window (when host configuration allows)."""
|
27
25
|
ctx = get_script_run_ctx()
|
28
26
|
if ctx is None:
|
29
27
|
return
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
"""@st.cache_data: pickle-based caching"""
|
15
|
+
"""@st.cache_data: pickle-based caching."""
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
@@ -81,7 +81,7 @@ CachePersistType: TypeAlias = Union[Literal["disk"], None]
|
|
81
81
|
|
82
82
|
|
83
83
|
class CachedDataFuncInfo(CachedFuncInfo):
|
84
|
-
"""Implements the CachedFuncInfo interface for @st.cache_data"""
|
84
|
+
"""Implements the CachedFuncInfo interface for @st.cache_data."""
|
85
85
|
|
86
86
|
def __init__(
|
87
87
|
self,
|
@@ -113,7 +113,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
|
|
113
113
|
|
114
114
|
@property
|
115
115
|
def display_name(self) -> str:
|
116
|
-
"""A human-readable name for the cached function"""
|
116
|
+
"""A human-readable name for the cached function."""
|
117
117
|
return f"{self.func.__module__}.{self.func.__qualname__}"
|
118
118
|
|
119
119
|
def get_function_cache(self, function_key: str) -> Cache:
|
@@ -127,7 +127,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
|
|
127
127
|
|
128
128
|
def validate_params(self) -> None:
|
129
129
|
"""
|
130
|
-
Validate the params passed to @st.cache_data are compatible with cache storage
|
130
|
+
Validate the params passed to @st.cache_data are compatible with cache storage.
|
131
131
|
|
132
132
|
When called, this method could log warnings if cache params are invalid
|
133
133
|
for current storage.
|
@@ -141,7 +141,7 @@ class CachedDataFuncInfo(CachedFuncInfo):
|
|
141
141
|
|
142
142
|
|
143
143
|
class DataCaches(CacheStatsProvider):
|
144
|
-
"""Manages all DataCache instances"""
|
144
|
+
"""Manages all DataCache instances."""
|
145
145
|
|
146
146
|
def __init__(self):
|
147
147
|
self._caches_lock = threading.Lock()
|
@@ -137,6 +137,6 @@ class UnserializableReturnValueError(MarkdownFormattedException):
|
|
137
137
|
|
138
138
|
|
139
139
|
class UnevaluatedDataFrameError(StreamlitAPIException):
|
140
|
-
"""Used to display a message about uncollected dataframe being used"""
|
140
|
+
"""Used to display a message about uncollected dataframe being used."""
|
141
141
|
|
142
142
|
pass
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
"""@st.cache_resource implementation"""
|
15
|
+
"""@st.cache_resource implementation."""
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
@@ -67,7 +67,7 @@ def _equal_validate_funcs(a: ValidateFunc | None, b: ValidateFunc | None) -> boo
|
|
67
67
|
|
68
68
|
|
69
69
|
class ResourceCaches(CacheStatsProvider):
|
70
|
-
"""Manages all ResourceCache instances"""
|
70
|
+
"""Manages all ResourceCache instances."""
|
71
71
|
|
72
72
|
def __init__(self):
|
73
73
|
self._caches_lock = threading.Lock()
|
@@ -141,7 +141,7 @@ def get_resource_cache_stats_provider() -> CacheStatsProvider:
|
|
141
141
|
|
142
142
|
|
143
143
|
class CachedResourceFuncInfo(CachedFuncInfo):
|
144
|
-
"""Implements the CachedFuncInfo interface for @st.cache_resource"""
|
144
|
+
"""Implements the CachedFuncInfo interface for @st.cache_resource."""
|
145
145
|
|
146
146
|
def __init__(
|
147
147
|
self,
|
@@ -171,7 +171,7 @@ class CachedResourceFuncInfo(CachedFuncInfo):
|
|
171
171
|
|
172
172
|
@property
|
173
173
|
def display_name(self) -> str:
|
174
|
-
"""A human-readable name for the cached function"""
|
174
|
+
"""A human-readable name for the cached function."""
|
175
175
|
return f"{self.func.__module__}.{self.func.__qualname__}"
|
176
176
|
|
177
177
|
def get_function_cache(self, function_key: str) -> Cache:
|
@@ -103,7 +103,8 @@ class Cache:
|
|
103
103
|
def clear(self, key: str | None = None):
|
104
104
|
"""Clear values from this cache.
|
105
105
|
If no argument is passed, all items are cleared from the cache.
|
106
|
-
A key can be passed to clear that key from the cache only.
|
106
|
+
A key can be passed to clear that key from the cache only.
|
107
|
+
"""
|
107
108
|
with self._value_locks_lock:
|
108
109
|
if not key:
|
109
110
|
self._value_locks.clear()
|
@@ -163,7 +164,8 @@ def make_cached_func_wrapper(info: CachedFuncInfo) -> Callable[..., Any]:
|
|
163
164
|
|
164
165
|
class BoundCachedFunc:
|
165
166
|
"""A wrapper around a CachedFunc that binds it to a specific instance in case of
|
166
|
-
decorated function is a class method.
|
167
|
+
decorated function is a class method.
|
168
|
+
"""
|
167
169
|
|
168
170
|
def __init__(self, cached_func: CachedFunc, instance: Any):
|
169
171
|
self._cached_func = cached_func
|
@@ -260,7 +262,8 @@ class CachedFunc:
|
|
260
262
|
|
261
263
|
def _handle_cache_hit(self, result: CachedResult) -> Any:
|
262
264
|
"""Handle a cache hit: replay the result's cached messages, and return its
|
263
|
-
value.
|
265
|
+
value.
|
266
|
+
"""
|
264
267
|
replay_cached_messages(
|
265
268
|
result,
|
266
269
|
self._info.cache_type,
|
@@ -352,7 +355,6 @@ class CachedFunc:
|
|
352
355
|
|
353
356
|
Parameters
|
354
357
|
----------
|
355
|
-
|
356
358
|
*args: Any
|
357
359
|
Arguments of the cached functions.
|
358
360
|
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
"""Declares the CacheStorageContext dataclass, which contains parameter information for
|
16
|
-
each function decorated by `@st.cache_data` (for example: ttl, max_entries etc.)
|
16
|
+
each function decorated by `@st.cache_data` (for example: ttl, max_entries etc.).
|
17
17
|
|
18
18
|
Declares the CacheStorageManager protocol, which implementations are used
|
19
19
|
to create CacheStorage instances and to optionally clear all cache storages,
|
@@ -61,11 +61,11 @@ from typing import Literal, Protocol
|
|
61
61
|
|
62
62
|
|
63
63
|
class CacheStorageError(Exception):
|
64
|
-
"""Base exception raised by the cache storage"""
|
64
|
+
"""Base exception raised by the cache storage."""
|
65
65
|
|
66
66
|
|
67
67
|
class CacheStorageKeyNotFoundError(CacheStorageError):
|
68
|
-
"""Raised when the key is not found in the cache storage"""
|
68
|
+
"""Raised when the key is not found in the cache storage."""
|
69
69
|
|
70
70
|
|
71
71
|
class InvalidCacheStorageContext(CacheStorageError):
|
@@ -138,17 +138,17 @@ class CacheStorage(Protocol):
|
|
138
138
|
|
139
139
|
@abstractmethod
|
140
140
|
def set(self, key: str, value: bytes) -> None:
|
141
|
-
"""Sets the value for a given key"""
|
141
|
+
"""Sets the value for a given key."""
|
142
142
|
raise NotImplementedError
|
143
143
|
|
144
144
|
@abstractmethod
|
145
145
|
def delete(self, key: str) -> None:
|
146
|
-
"""Delete a given key"""
|
146
|
+
"""Delete a given key."""
|
147
147
|
raise NotImplementedError
|
148
148
|
|
149
149
|
@abstractmethod
|
150
150
|
def clear(self) -> None:
|
151
|
-
"""Remove all keys for the storage"""
|
151
|
+
"""Remove all keys for the storage."""
|
152
152
|
raise NotImplementedError
|
153
153
|
|
154
154
|
def close(self) -> None:
|
@@ -26,7 +26,7 @@ from streamlit.runtime.caching.storage.in_memory_cache_storage_wrapper import (
|
|
26
26
|
|
27
27
|
class MemoryCacheStorageManager(CacheStorageManager):
|
28
28
|
def create(self, context: CacheStorageContext) -> CacheStorage:
|
29
|
-
"""Creates a new cache storage instance wrapped with in-memory cache layer"""
|
29
|
+
"""Creates a new cache storage instance wrapped with in-memory cache layer."""
|
30
30
|
persist_storage = DummyCacheStorage()
|
31
31
|
return InMemoryCacheStorageWrapper(
|
32
32
|
persist_storage=persist_storage, context=context
|
@@ -43,7 +43,7 @@ class DummyCacheStorage(CacheStorage):
|
|
43
43
|
def get(self, key: str) -> bytes:
|
44
44
|
"""
|
45
45
|
Dummy gets the value for a given key,
|
46
|
-
always raises an CacheStorageKeyNotFoundError
|
46
|
+
always raises an CacheStorageKeyNotFoundError.
|
47
47
|
"""
|
48
48
|
raise CacheStorageKeyNotFoundError("Key not found in dummy cache")
|
49
49
|
|
@@ -81,7 +81,7 @@ class InMemoryCacheStorageWrapper(CacheStorage):
|
|
81
81
|
def get(self, key: str) -> bytes:
|
82
82
|
"""
|
83
83
|
Returns the stored value for the key or raise CacheStorageKeyNotFoundError if
|
84
|
-
the key is not found
|
84
|
+
the key is not found.
|
85
85
|
"""
|
86
86
|
try:
|
87
87
|
entry_bytes = self._read_from_mem_cache(key)
|
@@ -91,23 +91,23 @@ class InMemoryCacheStorageWrapper(CacheStorage):
|
|
91
91
|
return entry_bytes
|
92
92
|
|
93
93
|
def set(self, key: str, value: bytes) -> None:
|
94
|
-
"""Sets the value for a given key"""
|
94
|
+
"""Sets the value for a given key."""
|
95
95
|
self._write_to_mem_cache(key, value)
|
96
96
|
self._persist_storage.set(key, value)
|
97
97
|
|
98
98
|
def delete(self, key: str) -> None:
|
99
|
-
"""Delete a given key"""
|
99
|
+
"""Delete a given key."""
|
100
100
|
self._remove_from_mem_cache(key)
|
101
101
|
self._persist_storage.delete(key)
|
102
102
|
|
103
103
|
def clear(self) -> None:
|
104
|
-
"""Delete all keys for the in memory cache, and also the persistent storage"""
|
104
|
+
"""Delete all keys for the in memory cache, and also the persistent storage."""
|
105
105
|
with self._mem_cache_lock:
|
106
106
|
self._mem_cache.clear()
|
107
107
|
self._persist_storage.clear()
|
108
108
|
|
109
109
|
def get_stats(self) -> list[CacheStat]:
|
110
|
-
"""Returns a list of stats in bytes for the cache memory storage per item"""
|
110
|
+
"""Returns a list of stats in bytes for the cache memory storage per item."""
|
111
111
|
stats = []
|
112
112
|
|
113
113
|
with self._mem_cache_lock:
|
@@ -122,7 +122,7 @@ class InMemoryCacheStorageWrapper(CacheStorage):
|
|
122
122
|
return stats
|
123
123
|
|
124
124
|
def close(self) -> None:
|
125
|
-
"""Closes the cache storage"""
|
125
|
+
"""Closes the cache storage."""
|
126
126
|
self._persist_storage.close()
|
127
127
|
|
128
128
|
def _read_from_mem_cache(self, key: str) -> bytes:
|
@@ -91,7 +91,7 @@ _CACHED_FILE_EXTENSION: Final = "memo"
|
|
91
91
|
|
92
92
|
class LocalDiskCacheStorageManager(CacheStorageManager):
|
93
93
|
def create(self, context: CacheStorageContext) -> CacheStorage:
|
94
|
-
"""Creates a new cache storage instance wrapped with in-memory cache layer"""
|
94
|
+
"""Creates a new cache storage instance wrapped with in-memory cache layer."""
|
95
95
|
persist_storage = LocalDiskCacheStorage(context)
|
96
96
|
return InMemoryCacheStorageWrapper(
|
97
97
|
persist_storage=persist_storage, context=context
|
@@ -117,7 +117,7 @@ class LocalDiskCacheStorageManager(CacheStorageManager):
|
|
117
117
|
|
118
118
|
class LocalDiskCacheStorage(CacheStorage):
|
119
119
|
"""Cache storage that persists data to disk
|
120
|
-
This is the default cache persistence layer for `@st.cache_data
|
120
|
+
This is the default cache persistence layer for `@st.cache_data`.
|
121
121
|
"""
|
122
122
|
|
123
123
|
def __init__(self, context: CacheStorageContext):
|
@@ -138,7 +138,7 @@ class LocalDiskCacheStorage(CacheStorage):
|
|
138
138
|
"""
|
139
139
|
Returns the stored value for the key if persisted,
|
140
140
|
raise CacheStorageKeyNotFoundError if not found, or not configured
|
141
|
-
with persist="disk"
|
141
|
+
with persist="disk".
|
142
142
|
"""
|
143
143
|
if self.persist == "disk":
|
144
144
|
path = self._get_cache_file_path(key)
|
@@ -158,7 +158,7 @@ class LocalDiskCacheStorage(CacheStorage):
|
|
158
158
|
)
|
159
159
|
|
160
160
|
def set(self, key: str, value: bytes) -> None:
|
161
|
-
"""Sets the value for a given key"""
|
161
|
+
"""Sets the value for a given key."""
|
162
162
|
if self.persist == "disk":
|
163
163
|
path = self._get_cache_file_path(key)
|
164
164
|
try:
|
@@ -191,7 +191,7 @@ class LocalDiskCacheStorage(CacheStorage):
|
|
191
191
|
)
|
192
192
|
|
193
193
|
def clear(self) -> None:
|
194
|
-
"""Delete all keys for the current storage"""
|
194
|
+
"""Delete all keys for the current storage."""
|
195
195
|
cache_dir = get_cache_folder_path()
|
196
196
|
|
197
197
|
if os.path.isdir(cache_dir):
|
@@ -203,7 +203,7 @@ class LocalDiskCacheStorage(CacheStorage):
|
|
203
203
|
os.remove(os.path.join(cache_dir, file_name))
|
204
204
|
|
205
205
|
def close(self) -> None:
|
206
|
-
"""Dummy implementation of close, we don't need to actually "close" anything"""
|
206
|
+
"""Dummy implementation of close, we don't need to actually "close" anything."""
|
207
207
|
|
208
208
|
def _get_cache_file_path(self, value_key: str) -> str:
|
209
209
|
"""Return the path of the disk cache file for the given value."""
|
streamlit/runtime/context.py
CHANGED
@@ -273,7 +273,7 @@ class ContextProxy:
|
|
273
273
|
@property
|
274
274
|
@gather_metrics("context.locale")
|
275
275
|
def locale(self) -> str | None:
|
276
|
-
"""The locale of the user browser, read-only"""
|
276
|
+
"""The locale of the user browser, read-only."""
|
277
277
|
ctx = get_script_run_ctx()
|
278
278
|
if ctx is None or ctx.context_info is None:
|
279
279
|
return None
|
streamlit/runtime/credentials.py
CHANGED
@@ -66,7 +66,7 @@ Collecting usage statistics. To deactivate, set browser.gatherUsageStats to fals
|
|
66
66
|
|
67
67
|
|
68
68
|
def _send_email(email: str) -> None:
|
69
|
-
"""Send the user's email for metrics, if submitted"""
|
69
|
+
"""Send the user's email for metrics, if submitted."""
|
70
70
|
import requests
|
71
71
|
|
72
72
|
if email is None or "@" not in email:
|
@@ -281,7 +281,7 @@ class ForwardMsgCache(CacheStatsProvider):
|
|
281
281
|
del self._entries[msg_hash]
|
282
282
|
|
283
283
|
def clear(self) -> None:
|
284
|
-
"""Remove all entries from the cache"""
|
284
|
+
"""Remove all entries from the cache."""
|
285
285
|
self._entries.clear()
|
286
286
|
|
287
287
|
def get_stats(self) -> list[CacheStat]:
|
@@ -40,7 +40,8 @@ class ForwardMsgQueue:
|
|
40
40
|
before_enqueue_msg: Callable[[ForwardMsg], None] | None,
|
41
41
|
) -> None:
|
42
42
|
"""Set a callback to be called before a message is enqueued.
|
43
|
-
Used in static streamlit app generation.
|
43
|
+
Used in static streamlit app generation.
|
44
|
+
"""
|
44
45
|
ForwardMsgQueue._before_enqueue_msg = before_enqueue_msg
|
45
46
|
|
46
47
|
def __init__(self):
|
streamlit/runtime/fragment.py
CHANGED
@@ -61,7 +61,8 @@ class FragmentStorage(Protocol):
|
|
61
61
|
@abstractmethod
|
62
62
|
def clear(self, new_fragment_ids: set[str] | None = None) -> None:
|
63
63
|
"""Remove all fragments saved in this FragmentStorage unless listed in
|
64
|
-
new_fragment_ids.
|
64
|
+
new_fragment_ids.
|
65
|
+
"""
|
65
66
|
raise NotImplementedError
|
66
67
|
|
67
68
|
@abstractmethod
|
@@ -90,7 +90,7 @@ class MemoryFile(NamedTuple):
|
|
90
90
|
|
91
91
|
class MemoryMediaFileStorage(MediaFileStorage, CacheStatsProvider):
|
92
92
|
def __init__(self, media_endpoint: str):
|
93
|
-
"""Create a new MemoryMediaFileStorage instance
|
93
|
+
"""Create a new MemoryMediaFileStorage instance.
|
94
94
|
|
95
95
|
Parameters
|
96
96
|
----------
|
@@ -130,7 +130,7 @@ class MemoryMediaFileStorage(MediaFileStorage, CacheStatsProvider):
|
|
130
130
|
def get_file(self, filename: str) -> MemoryFile:
|
131
131
|
"""Return the MemoryFile with the given filename. Filenames are of the
|
132
132
|
form "file_id.extension". (Note that this is *not* the optional
|
133
|
-
user-specified filename for download files.)
|
133
|
+
user-specified filename for download files.).
|
134
134
|
|
135
135
|
Raises a MediaFileStorageError if no such file exists.
|
136
136
|
"""
|
@@ -160,7 +160,7 @@ _DBUS_MACHINE_ID_PATH = "/var/lib/dbus/machine-id"
|
|
160
160
|
|
161
161
|
|
162
162
|
def _get_machine_id_v3() -> str:
|
163
|
-
"""Get the machine ID
|
163
|
+
"""Get the machine ID.
|
164
164
|
|
165
165
|
This is a unique identifier for a user for tracking metrics,
|
166
166
|
that is broken in different ways in some Linux distros and Docker images.
|
@@ -186,7 +186,7 @@ class Installation:
|
|
186
186
|
|
187
187
|
@classmethod
|
188
188
|
def instance(cls) -> Installation:
|
189
|
-
"""Returns the singleton Installation"""
|
189
|
+
"""Returns the singleton Installation."""
|
190
190
|
# We use a double-checked locking optimization to avoid the overhead
|
191
191
|
# of acquiring the lock in the common case:
|
192
192
|
# https://en.wikipedia.org/wiki/Double-checked_locking
|