streamlit-nightly 1.52.3.dev20260113__py3-none-any.whl → 1.53.1.dev20260114__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/commands/logo.py +2 -0
- streamlit/commands/page_config.py +16 -16
- streamlit/components/v2/__init__.py +2 -2
- streamlit/connections/base_connection.py +16 -4
- streamlit/connections/snowflake_connection.py +254 -205
- streamlit/elements/form.py +2 -2
- streamlit/elements/metric.py +49 -48
- streamlit/elements/widgets/button.py +9 -9
- streamlit/elements/widgets/chat.py +5 -9
- streamlit/elements/widgets/data_editor.py +3 -3
- streamlit/elements/widgets/file_uploader.py +10 -11
- streamlit/elements/widgets/select_slider.py +4 -0
- streamlit/runtime/caching/cache_data_api.py +25 -21
- streamlit/runtime/caching/cache_resource_api.py +69 -41
- streamlit/runtime/connection_factory.py +67 -41
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +304 -304
- streamlit/static/static/js/{ErrorOutline.esm.BjVqd_6R.js → ErrorOutline.esm.BAZUU4id.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.DJCSsghl.js → FileDownload.esm.C6tTTniR.js} +1 -1
- streamlit/static/static/js/{FileHelper.C---TH7o.js → FileHelper.BOHlwlc9.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.C-6BC487.js → FormClearHelper.D4lty7rT.js} +1 -1
- streamlit/static/static/js/{InputInstructions.sxc3InCI.js → InputInstructions.BWw9lhud.js} +1 -1
- streamlit/static/static/js/{Particles.S8yD7iW-.js → Particles.BDi7fIn-.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BiYsyZCC.js → ProgressBar.DCHh4N3P.js} +1 -1
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.9jZF8jX1.js → StreamlitSyntaxHighlighter.BRydQwEj.js} +1 -1
- streamlit/static/static/js/{TableChart.esm.BdA4Q1rZ.js → TableChart.esm.7KFX5I_G.js} +1 -1
- streamlit/static/static/js/{Toolbar.B9DaaDfN.js → Toolbar.guIuiwEF.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.DxODTLS2.js → WidgetLabelHelpIconInline.CzodezAH.js} +1 -1
- streamlit/static/static/js/{base-input.Gf1cKuQR.js → base-input.Cg7NpsfS.js} +1 -1
- streamlit/static/static/js/{checkbox.CnoNruf3.js → checkbox.Bs20OTna.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.B48AepiL.js → createDownloadLinkElement.DSqCyu38.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.Cmdq9aqU.js → data-grid-overlay-editor.Ch4SqNfY.js} +1 -1
- streamlit/static/static/js/{downloader.CQLoQdMX.js → downloader.Oj5CTGJA.js} +1 -1
- streamlit/static/static/js/{embed.oKwocwU8.js → embed.CqzzUq73.js} +1 -1
- streamlit/static/static/js/{es6.BRxlY_y5.js → es6.CYrlw0Vn.js} +2 -2
- streamlit/static/static/js/{formatNumber.DaagZyZe.js → formatNumber.CT_v8e75.js} +1 -1
- streamlit/static/static/js/{iconPosition.Q3hNvmK4.js → iconPosition.DPAvXTmd.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.B6EBvI9L.js → iframeResizer.contentWindow.T4DvQsIf.js} +1 -1
- streamlit/static/static/js/{index.BoX8d5rK.js → index.AGYZDQZm.js} +1 -1
- streamlit/static/static/js/{index.KtjGDGY5.js → index.B3HdcUdo.js} +1 -1
- streamlit/static/static/js/{index.B9kZB0o1.js → index.B8ZZdPqF.js} +1 -1
- streamlit/static/static/js/{index.CFCBhOfx.js → index.B9Oowxt8.js} +1 -1
- streamlit/static/static/js/{index.CCQ5p_WC.js → index.BEzgNZOm.js} +1 -1
- streamlit/static/static/js/{index.D1pK_Vw2.js → index.BJnWg9Jq.js} +1 -1
- streamlit/static/static/js/{index.na9UBuse.js → index.BPxuKK0S.js} +1 -1
- streamlit/static/static/js/{index.QTaWooav.js → index.BTA0d5oq.js} +1 -1
- streamlit/static/static/js/{index.pU9mQeVC.js → index.BTqav7_K.js} +1 -1
- streamlit/static/static/js/{index.BXEC4cf3.js → index.BZ8xp-w9.js} +1 -1
- streamlit/static/static/js/{index.BF23fbfs.js → index.BoWBzl6h.js} +1 -1
- streamlit/static/static/js/index.Bqgt60FU.js +1 -0
- streamlit/static/static/js/{index.Dh5SAThV.js → index.BsYYrijt.js} +1 -1
- streamlit/static/static/js/{index.19_qtO6t.js → index.CGRIbGGV.js} +1 -1
- streamlit/static/static/js/{index.CSfsEKCF.js → index.CJQq5LcR.js} +1 -1
- streamlit/static/static/js/{index.Fu73QtkD.js → index.CPYB1awG.js} +1 -1
- streamlit/static/static/js/{index.BzwlrgZO.js → index.CVKk1nkB.js} +1 -1
- streamlit/static/static/js/{index.B03eQZoH.js → index.CVXiBeDI.js} +1 -1
- streamlit/static/static/js/{index.BRfGUOQ-.js → index.CXVpBAvU.js} +4 -4
- streamlit/static/static/js/{index.slgxPafU.js → index.Cfe-tCQJ.js} +1 -1
- streamlit/static/static/js/{index.D6X2coHR.js → index.ClFk8x0U.js} +1 -1
- streamlit/static/static/js/{index.WXybx2Xq.js → index.CnXxoVEM.js} +1 -1
- streamlit/static/static/js/{index.j4fnjyHo.js → index.Cw4eSvJ7.js} +1 -1
- streamlit/static/static/js/{index.KN1VmyYN.js → index.D6HCANv6.js} +1 -1
- streamlit/static/static/js/{index.CP-hoxJM.js → index.D7KbBAWb.js} +1 -1
- streamlit/static/static/js/{index.CCFwVy90.js → index.D84XHt50.js} +1 -1
- streamlit/static/static/js/{index.BkSwGJoh.js → index.DL_Ooizi.js} +1 -1
- streamlit/static/static/js/{index.QHnxuesF.js → index.DNyw7S7Z.js} +1 -1
- streamlit/static/static/js/{index.BAI9aHCq.js → index.DPlPEuq6.js} +1 -1
- streamlit/static/static/js/{index.CJ4oJe0V.js → index.DQzRwgrT.js} +1 -1
- streamlit/static/static/js/{index.CVlg41MB.js → index.DXRGd--0.js} +1 -1
- streamlit/static/static/js/{index.CIbgt5wY.js → index.DZDt5hYD.js} +1 -1
- streamlit/static/static/js/{index.BVT89mQw.js → index.DesNeXSA.js} +1 -1
- streamlit/static/static/js/{index.Boa0Egng.js → index.Dg9k4R8B.js} +1 -1
- streamlit/static/static/js/{index.43b777iP.js → index.Do9A7QCt.js} +1 -1
- streamlit/static/static/js/{index.DJ7P09eb.js → index.DrSH3pK3.js} +1 -1
- streamlit/static/static/js/{index.OpATzEaW.js → index.Dtd5z2rM.js} +1 -1
- streamlit/static/static/js/{index.BnfTPrHb.js → index.DzldU3Hy.js} +1 -1
- streamlit/static/static/js/{index.C0fSEz-3.js → index.GZi6GTJa.js} +1 -1
- streamlit/static/static/js/{index.CYE7b5Du.js → index.LOA31DFn.js} +1 -1
- streamlit/static/static/js/{index.Ca7MUNWJ.js → index.MtwRNvlS.js} +1 -1
- streamlit/static/static/js/{index.BbSFVZ3p.js → index.XHtvnZ0-.js} +1 -1
- streamlit/static/static/js/{index.CvIqsWy1.js → index.Yj6vcyFD.js} +1 -1
- streamlit/static/static/js/{index.BGBTkulf.js → index.b-MrPulo.js} +1 -1
- streamlit/static/static/js/{index.DGYHxruh.js → index.hcUYvTqs.js} +1 -1
- streamlit/static/static/js/{index.CvB9JBqS.js → index.tLZuZM89.js} +6 -6
- streamlit/static/static/js/{index.Xg-Qttib.js → index.wngeYhKj.js} +1 -1
- streamlit/static/static/js/{index.whRT3Vm3.js → index.xCV2qwtw.js} +1 -1
- streamlit/static/static/js/{input.CPzINTl-.js → input.CYXuTqoa.js} +1 -1
- streamlit/static/static/js/{main.DSPn8dUe.js → main.BE-siVKv.js} +1 -1
- streamlit/static/static/js/{memory.CfD8IGoU.js → memory.V554ztRg.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.4Ae0qegV.js → number-overlay-editor.BiUTOXIl.js} +1 -1
- streamlit/static/static/js/{pandasStylerUtils.D2EjZ7k6.js → pandasStylerUtils.Dej3Tstq.js} +1 -1
- streamlit/static/static/js/{sandbox.C6vcPIm0.js → sandbox.gpd7KGMo.js} +1 -1
- streamlit/static/static/js/{styled-components.BBmp8buj.js → styled-components.Coj4dr6D.js} +1 -1
- streamlit/static/static/js/{throttle.BPcPpy-S.js → throttle.gZUdtYp7.js} +1 -1
- streamlit/static/static/js/{timepicker.ryzkTs2C.js → timepicker.B-Y4aU15.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.Dg1nDaB_.js → toConsumableArray.CcKcKvEd.js} +1 -1
- streamlit/static/static/js/uniqueId.PRn3V1WU.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.A4U5lzAm.js → useBasicWidgetState.D-fc_aIL.js} +1 -1
- streamlit/static/static/js/{useIntlLocale.DWJgLlNz.js → useIntlLocale.CY32IeNt.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.BrBonw8t.js → useTextInputAutoExpand.C0jK7TwF.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.BkOWyNVX.js → useUpdateUiValue.CDQloDgB.js} +1 -1
- streamlit/static/static/js/{useWaveformController.CBlvXlgZ.js → useWaveformController.BLEIAIDo.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.D4cpOyNe.js → withCalculatedWidth.B3oSlRC0.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BMim3w94.js → withFullScreenWrapper.Cw_ebNmr.js} +1 -1
- streamlit/user_info.py +225 -166
- {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260114.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260114.dist-info}/RECORD +111 -111
- streamlit/static/static/js/index.CrPjcPY1.js +0 -1
- streamlit/static/static/js/uniqueId.BFHzT5KQ.js +0 -1
- {streamlit_nightly-1.52.3.dev20260113.data → streamlit_nightly-1.53.1.dev20260114.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260114.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260114.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260114.dist-info}/top_level.txt +0 -0
streamlit/elements/metric.py
CHANGED
|
@@ -108,11 +108,6 @@ class MetricMixin:
|
|
|
108
108
|
) -> DeltaGenerator:
|
|
109
109
|
r"""Display a metric in big bold font, with an optional indicator of how the metric changed.
|
|
110
110
|
|
|
111
|
-
Tip: If you want to display a large number, it may be a good idea to
|
|
112
|
-
shorten it using packages like `millify <https://github.com/azaitsev/millify>`_
|
|
113
|
-
or `numerize <https://github.com/davidsa03/numerize>`_. E.g. ``1234`` can be
|
|
114
|
-
displayed as ``1.2k`` using ``st.metric("Short number", millify(1234))``.
|
|
115
|
-
|
|
116
111
|
Parameters
|
|
117
112
|
----------
|
|
118
113
|
label : str
|
|
@@ -135,35 +130,38 @@ class MetricMixin:
|
|
|
135
130
|
value : int, float, decimal.Decimal, str, or None
|
|
136
131
|
Value of the metric. ``None`` is rendered as a long dash.
|
|
137
132
|
|
|
138
|
-
The value can optionally contain GitHub-flavored Markdown,
|
|
139
|
-
|
|
140
|
-
parameter of ``st.markdown``.
|
|
133
|
+
The value can optionally contain GitHub-flavored Markdown, subject
|
|
134
|
+
to the same limitations described in the ``label`` parameter.
|
|
141
135
|
|
|
142
136
|
delta : int, float, decimal.Decimal, str, or None
|
|
143
|
-
|
|
144
|
-
the
|
|
145
|
-
sign (str), the arrow points down and the text is red; else the
|
|
146
|
-
arrow points up and the text is green. If None (default), no delta
|
|
147
|
-
indicator is shown.
|
|
137
|
+
Amount or indicator of change in the metric. An arrow is shown next
|
|
138
|
+
to the delta, oriented according to its sign:
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
140
|
+
- If the delta is ``None`` or an empty string, no arrow is shown.
|
|
141
|
+
- If the delta is a negative number or starts with a minus sign,
|
|
142
|
+
the arrow points down and the delta is red.
|
|
143
|
+
- Otherwise, the arrow points up and the delta is green.
|
|
144
|
+
|
|
145
|
+
You can modify the display, color, and orientation of the arrow
|
|
146
|
+
using the ``delta_color`` and ``delta_arrow`` parameters.
|
|
147
|
+
|
|
148
|
+
The delta can optionally contain GitHub-flavored Markdown, subject
|
|
149
|
+
to the same limitations described in the ``label`` parameter.
|
|
152
150
|
|
|
153
151
|
delta_color : str
|
|
154
|
-
The color of the delta
|
|
155
|
-
|
|
156
|
-
- ``"normal"`` (default): The
|
|
157
|
-
|
|
158
|
-
- ``"inverse"``: The
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
- ``"off"``: The
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
152
|
+
The color of the delta and chart. This can be one of the following:
|
|
153
|
+
|
|
154
|
+
- ``"normal"`` (default): The color is red when the delta is
|
|
155
|
+
negative and green otherwise.
|
|
156
|
+
- ``"inverse"``: The color is green when the delta is negative and
|
|
157
|
+
red otherwise. This is useful when a negative change is
|
|
158
|
+
considered good, like a decrease in cost.
|
|
159
|
+
- ``"off"``: The color is gray regardless of the delta.
|
|
160
|
+
- A named color from the basic palette: The chart and delta are the
|
|
161
|
+
specified color regardless of their value. This can be one of the
|
|
162
|
+
following: ``"red"``, ``"orange"``, ``"yellow"``, ``"green"``,
|
|
163
|
+
``"blue"``, ``"violet"``, ``"gray"``/``"grey"``, or
|
|
164
|
+
``"primary"``.
|
|
167
165
|
|
|
168
166
|
help : str or None
|
|
169
167
|
A tooltip that gets displayed next to the metric label. Streamlit
|
|
@@ -189,26 +187,26 @@ class MetricMixin:
|
|
|
189
187
|
The height of the metric element. This can be one of the following:
|
|
190
188
|
|
|
191
189
|
- ``"content"`` (default): The height of the element matches the
|
|
192
|
-
|
|
190
|
+
height of its content.
|
|
193
191
|
- ``"stretch"``: The height of the element matches the height of
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
its content or the height of the parent container, whichever is
|
|
193
|
+
larger. If the element is not in a parent container, the height
|
|
194
|
+
of the element matches the height of its content.
|
|
197
195
|
- An integer specifying the height in pixels: The element has a
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
fixed height. If the content is larger than the specified
|
|
197
|
+
height, scrolling is enabled.
|
|
200
198
|
|
|
201
199
|
width : "stretch", "content", or int
|
|
202
200
|
The width of the metric element. This can be one of the following:
|
|
203
201
|
|
|
204
202
|
- ``"stretch"`` (default): The width of the element matches the
|
|
205
|
-
|
|
203
|
+
width of the parent container.
|
|
206
204
|
- ``"content"``: The width of the element matches the width of its
|
|
207
|
-
|
|
205
|
+
content, but doesn't exceed the width of the parent container.
|
|
208
206
|
- An integer specifying the width in pixels: The element has a
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
fixed width. If the specified width is greater than the width of
|
|
208
|
+
the parent container, the width of the element matches the width
|
|
209
|
+
of the parent container.
|
|
212
210
|
|
|
213
211
|
chart_data : Iterable or None
|
|
214
212
|
A sequence of numeric values to display as a sparkline chart. If
|
|
@@ -218,6 +216,9 @@ class MetricMixin:
|
|
|
218
216
|
be used. Each value will be cast to ``float`` internally by
|
|
219
217
|
default.
|
|
220
218
|
|
|
219
|
+
The chart uses the color of the delta indicator, which can be
|
|
220
|
+
modified using the ``delta_color`` parameter.
|
|
221
|
+
|
|
221
222
|
chart_type : "line", "bar", or "area"
|
|
222
223
|
The type of sparkline chart to display. This can be one of the
|
|
223
224
|
following:
|
|
@@ -231,18 +232,18 @@ class MetricMixin:
|
|
|
231
232
|
one of the following strings:
|
|
232
233
|
|
|
233
234
|
- ``"auto"`` (default): The arrow direction follows the sign of
|
|
234
|
-
|
|
235
|
+
``delta``.
|
|
235
236
|
- ``"up"`` or ``"down"``: The arrow is forced to point in the
|
|
236
|
-
|
|
237
|
+
specified direction.
|
|
237
238
|
- ``"off"``: No arrow is shown, but the delta value remains
|
|
238
|
-
|
|
239
|
+
visible.
|
|
239
240
|
|
|
240
241
|
format : str or None
|
|
241
242
|
A format string controlling how numbers are displayed for ``value``
|
|
242
243
|
and ``delta``. The format is only applied if the value or delta is
|
|
243
|
-
numeric
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
numeric. If the value or delta is a string with non-numeric
|
|
245
|
+
characters, the format is ignored. The format can be one of the
|
|
246
|
+
following values:
|
|
246
247
|
|
|
247
248
|
- ``None`` (default): No formatting is applied.
|
|
248
249
|
- ``"plain"``: Show the full number without any formatting (e.g. "1234.567").
|
|
@@ -257,8 +258,8 @@ class MetricMixin:
|
|
|
257
258
|
- ``"scientific"``: Show the number in scientific notation (e.g. "1.235E3").
|
|
258
259
|
- ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
|
|
259
260
|
- printf-style format string: Format the number with a printf
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
|
|
262
|
+
``"%.2f"`` to show a float with 2 decimal places.
|
|
262
263
|
|
|
263
264
|
Examples
|
|
264
265
|
--------
|
|
@@ -223,8 +223,8 @@ class ButtonMixin:
|
|
|
223
223
|
- ``"spinner"``: Displays a spinner as an icon.
|
|
224
224
|
|
|
225
225
|
icon_position : "left" or "right"
|
|
226
|
-
The position of the icon relative to the button label.
|
|
227
|
-
``"left"``.
|
|
226
|
+
The position of the icon relative to the button label. This
|
|
227
|
+
defaults to ``"left"``.
|
|
228
228
|
|
|
229
229
|
disabled : bool
|
|
230
230
|
An optional boolean that disables the button if set to ``True``.
|
|
@@ -539,8 +539,8 @@ class ButtonMixin:
|
|
|
539
539
|
- ``"spinner"``: Displays a spinner as an icon.
|
|
540
540
|
|
|
541
541
|
icon_position : "left" or "right"
|
|
542
|
-
The position of the icon relative to the button label.
|
|
543
|
-
``"left"``.
|
|
542
|
+
The position of the icon relative to the button label. This
|
|
543
|
+
defaults to ``"left"``.
|
|
544
544
|
|
|
545
545
|
disabled : bool
|
|
546
546
|
An optional boolean that disables the download button if set to
|
|
@@ -847,8 +847,8 @@ class ButtonMixin:
|
|
|
847
847
|
- ``"spinner"``: Displays a spinner as an icon.
|
|
848
848
|
|
|
849
849
|
icon_position : "left" or "right"
|
|
850
|
-
The position of the icon relative to the button label.
|
|
851
|
-
``"left"``.
|
|
850
|
+
The position of the icon relative to the button label. This
|
|
851
|
+
defaults to ``"left"``.
|
|
852
852
|
|
|
853
853
|
disabled : bool
|
|
854
854
|
An optional boolean that disables the link button if set to
|
|
@@ -990,7 +990,7 @@ class ButtonMixin:
|
|
|
990
990
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
|
991
991
|
|
|
992
992
|
icon : str or None
|
|
993
|
-
An optional emoji or icon to display next to the
|
|
993
|
+
An optional emoji or icon to display next to the link label. If
|
|
994
994
|
``icon`` is ``None`` (default), the icon is inferred from the
|
|
995
995
|
``StreamlitPage`` object or no icon is displayed. If ``icon`` is a
|
|
996
996
|
string, the following options are valid:
|
|
@@ -1010,8 +1010,8 @@ class ButtonMixin:
|
|
|
1010
1010
|
- ``"spinner"``: Displays a spinner as an icon.
|
|
1011
1011
|
|
|
1012
1012
|
icon_position : "left" or "right"
|
|
1013
|
-
The position of the icon relative to the
|
|
1014
|
-
to ``"left"``.
|
|
1013
|
+
The position of the icon relative to the link label. This
|
|
1014
|
+
defaults to ``"left"``.
|
|
1015
1015
|
|
|
1016
1016
|
help : str or None
|
|
1017
1017
|
A tooltip that gets displayed when the link is hovered over. If
|
|
@@ -633,16 +633,12 @@ class ChatMixin:
|
|
|
633
633
|
``None`` (default), there will be no maximum.
|
|
634
634
|
|
|
635
635
|
max_upload_size : int or None
|
|
636
|
-
The maximum allowed size of each uploaded file
|
|
637
|
-
in megabytes.
|
|
636
|
+
The maximum allowed size of each uploaded file in megabytes.
|
|
638
637
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
When this is ``None`` (default), the chat input falls back to
|
|
644
|
-
``server.maxUploadSize`` for its file size limit. For more
|
|
645
|
-
information on how to set config options, see |config.toml|_.
|
|
638
|
+
If this is ``None`` (default), the maximum file size is set by the
|
|
639
|
+
``server.maxUploadSize`` configuration option in your
|
|
640
|
+
``config.toml`` file. If this is an integer, it must be positive
|
|
641
|
+
and will override the ``server.maxUploadSize`` configuration option.
|
|
646
642
|
|
|
647
643
|
accept_file : bool, "multiple", or "directory"
|
|
648
644
|
Whether the chat input should accept files. This can be one of the
|
|
@@ -792,10 +792,10 @@ class DataEditorMixin:
|
|
|
792
792
|
first index column.
|
|
793
793
|
|
|
794
794
|
num_rows : "fixed", "dynamic", "add", or "delete"
|
|
795
|
-
Specifies if the user can add and delete rows in the data editor.
|
|
795
|
+
Specifies if the user can add and/or delete rows in the data editor.
|
|
796
796
|
|
|
797
|
-
- ``"fixed"`` (default): The user
|
|
798
|
-
- ``"dynamic"``: The user can add and delete rows,
|
|
797
|
+
- ``"fixed"`` (default): The user can't add or delete rows.
|
|
798
|
+
- ``"dynamic"``: The user can add and delete rows, and column
|
|
799
799
|
sorting is disabled.
|
|
800
800
|
- ``"add"``: The user can only add rows (no deleting), and column
|
|
801
801
|
sorting is disabled.
|
|
@@ -266,9 +266,12 @@ class FileUploaderMixin:
|
|
|
266
266
|
width: WidthWithoutContent = "stretch",
|
|
267
267
|
) -> UploadedFile | list[UploadedFile] | None:
|
|
268
268
|
r"""Display a file uploader widget.
|
|
269
|
+
|
|
269
270
|
By default, uploaded files are limited to 200 MB each. You can
|
|
270
|
-
configure this using the ``server.maxUploadSize``
|
|
271
|
-
more information on how to set
|
|
271
|
+
configure this globally using the ``server.maxUploadSize`` configuration
|
|
272
|
+
option. For more information on how to set configuration options, see
|
|
273
|
+
|config.toml|_. Additionally, you can set a per-widget limit using the
|
|
274
|
+
``max_upload_size`` parameter.
|
|
272
275
|
|
|
273
276
|
.. |config.toml| replace:: ``config.toml``
|
|
274
277
|
.. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
|
|
@@ -315,16 +318,12 @@ class FileUploaderMixin:
|
|
|
315
318
|
part of the app developer's responsibility.
|
|
316
319
|
|
|
317
320
|
max_upload_size : int or None
|
|
318
|
-
The maximum allowed size of each uploaded file
|
|
319
|
-
in megabytes.
|
|
320
|
-
|
|
321
|
-
When set to a positive integer, this per-widget limit takes
|
|
322
|
-
precedence over the global ``server.maxUploadSize`` configuration
|
|
323
|
-
option.
|
|
321
|
+
The maximum allowed size of each uploaded file in megabytes.
|
|
324
322
|
|
|
325
|
-
|
|
326
|
-
``server.maxUploadSize``
|
|
327
|
-
|
|
323
|
+
If this is ``None`` (default), the maximum file size is set by the
|
|
324
|
+
``server.maxUploadSize`` configuration option in your
|
|
325
|
+
``config.toml`` file. If this is an integer, it must be positive
|
|
326
|
+
and will override the ``server.maxUploadSize`` configuration option.
|
|
328
327
|
|
|
329
328
|
accept_multiple_files : bool or "directory"
|
|
330
329
|
Whether to accept more than one file in a submission. This can be one
|
|
@@ -200,6 +200,10 @@ class SelectSliderMixin:
|
|
|
200
200
|
``options`` is dataframe-like, the first column will be used. Each
|
|
201
201
|
label will be cast to ``str`` internally by default.
|
|
202
202
|
|
|
203
|
+
Each item in the iterable can optionally contain GitHub-flavored
|
|
204
|
+
Markdown, subject to the same limitations described in the
|
|
205
|
+
``label`` parameter.
|
|
206
|
+
|
|
203
207
|
value : a supported type or a tuple/list of supported types or None
|
|
204
208
|
The value of the slider when it first renders. If a tuple/list
|
|
205
209
|
of two values is passed here, then a range slider with those lower
|
|
@@ -465,6 +465,11 @@ class CacheDataAPI:
|
|
|
465
465
|
) -> CachedFunc[P, R] | Callable[[Callable[P, R]], CachedFunc[P, R]]:
|
|
466
466
|
"""Decorator to cache functions that return data (e.g. dataframe transforms, database queries, ML inference).
|
|
467
467
|
|
|
468
|
+
Cached objects can be global or session-scoped. Global cached data is
|
|
469
|
+
available across all users, sessions, and reruns. Session-scoped cached
|
|
470
|
+
data is only available in the current session and removed when the
|
|
471
|
+
session disconnects.
|
|
472
|
+
|
|
468
473
|
Cached objects are stored in "pickled" form, which means that the return
|
|
469
474
|
value of a cached function must be pickleable. Each caller of the cached
|
|
470
475
|
function gets its own copy of the cached data.
|
|
@@ -472,20 +477,17 @@ class CacheDataAPI:
|
|
|
472
477
|
You can clear a function's cache with ``func.clear()`` or clear the entire
|
|
473
478
|
cache with ``st.cache_data.clear()``.
|
|
474
479
|
|
|
475
|
-
A function's arguments must be hashable to cache it.
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
instead. Within each user session, an ``@st.cache_data``-decorated
|
|
487
|
-
function returns a *copy* of the cached return value (if the value is
|
|
488
|
-
already cached). To cache shared global resources (singletons), use
|
|
480
|
+
A function's arguments must be hashable to cache it. Streamlit makes a
|
|
481
|
+
best effort to hash a variety of objects, but the fallback hashing method
|
|
482
|
+
requires that the argument be pickleable, also. If you have an unhashable
|
|
483
|
+
argument (like a database connection) or an argument you want to exclude
|
|
484
|
+
from caching, use an underscore prefix in the argument name. In this case,
|
|
485
|
+
Streamlit will return a cached value when all other arguments match a
|
|
486
|
+
previous function call. Alternatively, you can declare custom hashing
|
|
487
|
+
functions with ``hash_funcs``.
|
|
488
|
+
|
|
489
|
+
Objects cached by ``st.cache_data`` are returned as copies. To cache a
|
|
490
|
+
shared resource or something you want to mutate in place, use
|
|
489
491
|
``st.cache_resource`` instead. To learn more about caching, see
|
|
490
492
|
`Caching overview
|
|
491
493
|
<https://docs.streamlit.io/develop/concepts/architecture/caching>`_.
|
|
@@ -544,13 +546,15 @@ class CacheDataAPI:
|
|
|
544
546
|
of how this can be used.
|
|
545
547
|
|
|
546
548
|
scope : "global" or "session"
|
|
547
|
-
The scope for the
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
549
|
+
The scope for the data cache. If this is ``"global"`` (default),
|
|
550
|
+
the data is cached globally. If this is ``"session"``, the data is
|
|
551
|
+
removed from the cache when the session disconnects.
|
|
552
|
+
|
|
553
|
+
Because a session-scoped cache is cleared when a session disconnects,
|
|
554
|
+
an unstable network connection can cause the cache to populate
|
|
555
|
+
multiple times in a single session. If this is a problem, you might
|
|
556
|
+
consider adjusting the ``server.websocketPingInterval``
|
|
557
|
+
configuration option.
|
|
554
558
|
|
|
555
559
|
Example
|
|
556
560
|
-------
|
|
@@ -362,33 +362,30 @@ class CacheResourceAPI:
|
|
|
362
362
|
on_release: OnRelease | None = None,
|
|
363
363
|
scope: CacheScope = "global",
|
|
364
364
|
) -> CachedFunc[P, R] | Callable[[Callable[P, R]], CachedFunc[P, R]]:
|
|
365
|
-
"""Decorator to cache functions that return
|
|
365
|
+
"""Decorator to cache functions that return resource objects (e.g. database connections, ML models).
|
|
366
366
|
|
|
367
|
-
Cached objects
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
367
|
+
Cached objects can be global or session-scoped. Global resources are
|
|
368
|
+
shared across all users, sessions, and reruns. Session-scoped resources are
|
|
369
|
+
scoped to the current session and are removed when the session disconnects.
|
|
370
|
+
Global resources must be thread-safe. If thread safety is an issue,
|
|
371
|
+
consider using a session-scoped cache or storing the resource in
|
|
372
|
+
``st.session_state`` instead.
|
|
371
373
|
|
|
372
374
|
You can clear a function's cache with ``func.clear()`` or clear the entire
|
|
373
375
|
cache with ``st.cache_resource.clear()``.
|
|
374
376
|
|
|
375
|
-
A function's arguments must be hashable to cache it.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
function returns the cached instance of the return value (if the value
|
|
388
|
-
is already cached). Therefore, objects cached by ``st.cache_resource``
|
|
389
|
-
act like singletons and can mutate. To cache data and return copies,
|
|
390
|
-
use ``st.cache_data`` instead. To learn more about caching, see
|
|
391
|
-
`Caching overview
|
|
377
|
+
A function's arguments must be hashable to cache it. Streamlit makes a
|
|
378
|
+
best effort to hash a variety of objects, but the fallback hashing method
|
|
379
|
+
requires that the argument be pickleable, also. If you have an unhashable
|
|
380
|
+
argument (like a database connection) or an argument you want to exclude
|
|
381
|
+
from caching, use an underscore prefix in the argument name. In this case,
|
|
382
|
+
Streamlit will return a cached value when all other arguments match a
|
|
383
|
+
previous function call. Alternatively, you can declare custom hashing
|
|
384
|
+
functions with ``hash_funcs``.
|
|
385
|
+
|
|
386
|
+
Objects cached by ``st.cache_resource`` act like singletons and can
|
|
387
|
+
mutate. To cache data and return copies, use ``st.cache_data`` instead.
|
|
388
|
+
To learn more about caching, see `Caching overview
|
|
392
389
|
<https://docs.streamlit.io/develop/concepts/architecture/caching>`_.
|
|
393
390
|
|
|
394
391
|
.. warning::
|
|
@@ -410,7 +407,8 @@ class CacheResourceAPI:
|
|
|
410
407
|
function's source code.
|
|
411
408
|
|
|
412
409
|
ttl : float, timedelta, str, or None
|
|
413
|
-
The maximum
|
|
410
|
+
The maximum age of a returned entry from the cache. This can be one
|
|
411
|
+
of the following values:
|
|
414
412
|
|
|
415
413
|
- ``None`` if cache entries should never expire (default).
|
|
416
414
|
- A number specifying the time in seconds.
|
|
@@ -459,30 +457,40 @@ class CacheResourceAPI:
|
|
|
459
457
|
of how this can be used.
|
|
460
458
|
|
|
461
459
|
on_release : callable or None
|
|
462
|
-
|
|
460
|
+
A function to call when an entry is removed from the cache.
|
|
463
461
|
The removed item will be provided to the function as an argument.
|
|
464
462
|
|
|
465
|
-
This is only useful for caches
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
expiration can happen on any app render or load, so care should be taken
|
|
470
|
-
to ensure that ``on_release`` functions are thread-safe and do not rely on
|
|
471
|
-
session state.
|
|
463
|
+
This is only useful for caches that remove entries normally.
|
|
464
|
+
Most commonly, this is used session-scoped caches to release
|
|
465
|
+
per-session resources. This can also be used with ``max_entries``
|
|
466
|
+
or ``ttl`` settings.
|
|
472
467
|
|
|
473
|
-
|
|
468
|
+
TTL expiration only happens when expired resources are accessed.
|
|
469
|
+
Therefore, don't rely on TTL expiration to guarantee timely cleanup.
|
|
470
|
+
Also, expiration can happen on any script run. Ensure that
|
|
471
|
+
``on_release`` functions are thread-safe and don't rely on session
|
|
472
|
+
state.
|
|
473
|
+
|
|
474
|
+
The ``on_release`` function isn't guaranteed to be called when an
|
|
475
|
+
app is shut down.
|
|
474
476
|
|
|
475
477
|
scope : "global" or "session"
|
|
476
|
-
The scope for the resource. If "global"
|
|
477
|
-
|
|
478
|
+
The scope for the resource cache. If this is ``"global"`` (default),
|
|
479
|
+
the resource is cached globally. If this is ``"session"``, the
|
|
480
|
+
resource is removed from the cache when the session disconnects.
|
|
478
481
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
the
|
|
482
|
+
Because a session-scoped cache is cleared when a session disconnects,
|
|
483
|
+
an unstable network connection can cause the cache to populate
|
|
484
|
+
multiple times in a single session. If this is a problem, you might
|
|
485
|
+
consider adjusting the ``server.websocketPingInterval``
|
|
486
|
+
configuration option.
|
|
483
487
|
|
|
484
488
|
Example
|
|
485
489
|
-------
|
|
490
|
+
**Example 1: Global cache**
|
|
491
|
+
|
|
492
|
+
By default, an ``@st.cache_resource``-decorated function uses a global cache.
|
|
493
|
+
|
|
486
494
|
>>> import streamlit as st
|
|
487
495
|
>>>
|
|
488
496
|
>>> @st.cache_resource
|
|
@@ -501,7 +509,22 @@ class CacheResourceAPI:
|
|
|
501
509
|
>>> s3 = get_database_session(SESSION_URL_2)
|
|
502
510
|
>>> # This is a different URL, so the function executes.
|
|
503
511
|
|
|
504
|
-
|
|
512
|
+
**Example 2: Session-scoped cache**
|
|
513
|
+
|
|
514
|
+
By passing ``scope="session"``, an ``@st.cache_resource``-decorated function
|
|
515
|
+
uses a session-scoped cache. You can also use ``on_release`` to clean up
|
|
516
|
+
resources when they are no longer needed.
|
|
517
|
+
|
|
518
|
+
>>> import streamlit as st
|
|
519
|
+
>>>
|
|
520
|
+
>>> @st.cache_resource(scope="session", on_release=lambda sess: sess.close())
|
|
521
|
+
... def get_database_session(url):
|
|
522
|
+
... # Create a database session object that points to the URL.
|
|
523
|
+
... return session
|
|
524
|
+
|
|
525
|
+
**Example 3: Unhashable arguments**
|
|
526
|
+
|
|
527
|
+
By default, all parameters to a cached function must be hashable.
|
|
505
528
|
Any parameter whose name begins with ``_`` will not be hashed. You can use
|
|
506
529
|
this as an "escape hatch" for parameters that are not hashable:
|
|
507
530
|
|
|
@@ -521,7 +544,9 @@ class CacheResourceAPI:
|
|
|
521
544
|
>>> # value - even though the _sessionmaker parameter was different
|
|
522
545
|
>>> # in both calls.
|
|
523
546
|
|
|
524
|
-
|
|
547
|
+
**Example 4: Clearing a cache**
|
|
548
|
+
|
|
549
|
+
A cached function's cache can be procedurally cleared:
|
|
525
550
|
|
|
526
551
|
>>> import streamlit as st
|
|
527
552
|
>>>
|
|
@@ -530,12 +555,14 @@ class CacheResourceAPI:
|
|
|
530
555
|
... # Create a database connection object that points to the URL.
|
|
531
556
|
... return connection
|
|
532
557
|
>>>
|
|
533
|
-
>>>
|
|
558
|
+
>>> get_database_session.clear(_sessionmaker, "https://streamlit.io/")
|
|
534
559
|
>>> # Clear the cached entry for the arguments provided.
|
|
535
560
|
>>>
|
|
536
561
|
>>> get_database_session.clear()
|
|
537
562
|
>>> # Clear all cached entries for this function.
|
|
538
563
|
|
|
564
|
+
**Example 5: Custom hashing**
|
|
565
|
+
|
|
539
566
|
To override the default hashing behavior, pass a custom hash function.
|
|
540
567
|
You can do that by mapping a type (e.g. ``Person``) to a hash
|
|
541
568
|
function (``str``) like this:
|
|
@@ -562,6 +589,7 @@ class CacheResourceAPI:
|
|
|
562
589
|
>>> @st.cache_resource(hash_funcs={"__main__.Person": str})
|
|
563
590
|
... def get_person_name(person: Person):
|
|
564
591
|
... return person.name
|
|
592
|
+
|
|
565
593
|
"""
|
|
566
594
|
|
|
567
595
|
if scope not in ("global", "session"):
|