streamlit-nightly 1.52.3.dev20260113__py3-none-any.whl → 1.53.1.dev20260115__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.
Files changed (135) hide show
  1. streamlit/__init__.py +0 -26
  2. streamlit/commands/logo.py +2 -0
  3. streamlit/commands/page_config.py +16 -16
  4. streamlit/components/v2/__init__.py +2 -2
  5. streamlit/config.py +29 -0
  6. streamlit/connections/base_connection.py +16 -4
  7. streamlit/connections/snowflake_connection.py +254 -205
  8. streamlit/elements/form.py +2 -2
  9. streamlit/elements/lib/streamlit_plotly_theme.py +9 -11
  10. streamlit/elements/metric.py +49 -48
  11. streamlit/elements/widgets/button.py +9 -9
  12. streamlit/elements/widgets/chat.py +5 -9
  13. streamlit/elements/widgets/data_editor.py +3 -3
  14. streamlit/elements/widgets/file_uploader.py +10 -11
  15. streamlit/elements/widgets/select_slider.py +4 -0
  16. streamlit/proto/NewSession_pb2.py +18 -18
  17. streamlit/proto/NewSession_pb2.pyi +5 -1
  18. streamlit/runtime/app_session.py +78 -58
  19. streamlit/runtime/caching/cache_data_api.py +25 -21
  20. streamlit/runtime/caching/cache_resource_api.py +69 -41
  21. streamlit/runtime/connection_factory.py +67 -41
  22. streamlit/runtime/scriptrunner_utils/script_run_context.py +0 -21
  23. streamlit/runtime/state/query_params.py +0 -19
  24. streamlit/static/index.html +1 -1
  25. streamlit/static/manifest.json +296 -296
  26. streamlit/static/static/js/{ErrorOutline.esm.BjVqd_6R.js → ErrorOutline.esm.CiSfK8ht.js} +1 -1
  27. streamlit/static/static/js/{FileDownload.esm.DJCSsghl.js → FileDownload.esm.ItNjcEfs.js} +1 -1
  28. streamlit/static/static/js/{FileHelper.C---TH7o.js → FileHelper.xS7f19FE.js} +1 -1
  29. streamlit/static/static/js/{FormClearHelper.C-6BC487.js → FormClearHelper.N8_BCinn.js} +1 -1
  30. streamlit/static/static/js/{InputInstructions.sxc3InCI.js → InputInstructions.CrsdK7CQ.js} +1 -1
  31. streamlit/static/static/js/Particles.BDlTHC3I.js +1 -0
  32. streamlit/static/static/js/{ProgressBar.BiYsyZCC.js → ProgressBar.Bk2qeHfS.js} +2 -2
  33. streamlit/static/static/js/{StreamlitSyntaxHighlighter.9jZF8jX1.js → StreamlitSyntaxHighlighter.BcuPrPcw.js} +1 -1
  34. streamlit/static/static/js/{TableChart.esm.BdA4Q1rZ.js → TableChart.esm.CP7XPz8I.js} +1 -1
  35. streamlit/static/static/js/Toolbar.DCJcLwve.js +1 -0
  36. streamlit/static/static/js/{WidgetLabelHelpIconInline.DxODTLS2.js → WidgetLabelHelpIconInline.BPqxu1b-.js} +1 -1
  37. streamlit/static/static/js/{base-input.Gf1cKuQR.js → base-input.x4muJJ13.js} +4 -4
  38. streamlit/static/static/js/{checkbox.CnoNruf3.js → checkbox.C5r4AIaH.js} +1 -1
  39. streamlit/static/static/js/{createDownloadLinkElement.B48AepiL.js → createDownloadLinkElement.C83kkEeT.js} +1 -1
  40. streamlit/static/static/js/{data-grid-overlay-editor.Cmdq9aqU.js → data-grid-overlay-editor.0sOWm4IB.js} +1 -1
  41. streamlit/static/static/js/{downloader.CQLoQdMX.js → downloader.C_6FfoEv.js} +1 -1
  42. streamlit/static/static/js/{embed.oKwocwU8.js → embed.BnJ6-SK4.js} +14 -14
  43. streamlit/static/static/js/{es6.BRxlY_y5.js → es6.44_BWfFd.js} +2 -2
  44. streamlit/static/static/js/{formatNumber.DaagZyZe.js → formatNumber.DhHZAosz.js} +1 -1
  45. streamlit/static/static/js/{iconPosition.Q3hNvmK4.js → iconPosition.shOoQuRR.js} +1 -1
  46. streamlit/static/static/js/{iframeResizer.contentWindow.B6EBvI9L.js → iframeResizer.contentWindow.savEE5Vs.js} +1 -1
  47. streamlit/static/static/js/{index.BF23fbfs.js → index.AdijUi9Z.js} +1 -1
  48. streamlit/static/static/js/{index.OpATzEaW.js → index.B5HlOnvq.js} +1 -1
  49. streamlit/static/static/js/{index.Ca7MUNWJ.js → index.B6ewTTej.js} +1 -1
  50. streamlit/static/static/js/{index.CP-hoxJM.js → index.B8Of3XXR.js} +1 -1
  51. streamlit/static/static/js/{index.whRT3Vm3.js → index.BCaCSVj6.js} +1 -1
  52. streamlit/static/static/js/index.BE7Rhig1.js +1 -0
  53. streamlit/static/static/js/{index.BkSwGJoh.js → index.BHpLZ7X6.js} +2 -2
  54. streamlit/static/static/js/{index.na9UBuse.js → index.BNvP8E5Q.js} +1 -1
  55. streamlit/static/static/js/{index.CYE7b5Du.js → index.BNzuyXeN.js} +2 -2
  56. streamlit/static/static/js/{index.slgxPafU.js → index.BT7o4A9V.js} +1 -1
  57. streamlit/static/static/js/{index.BXEC4cf3.js → index.BYY3iuVE.js} +1 -1
  58. streamlit/static/static/js/index.BZI7jTDf.js +1 -0
  59. streamlit/static/static/js/{index.19_qtO6t.js → index.BZXk3Qxq.js} +1 -1
  60. streamlit/static/static/js/{index.B03eQZoH.js → index.BhQvq6YD.js} +1 -1
  61. streamlit/static/static/js/{index.WXybx2Xq.js → index.BkIReLGJ.js} +3 -3
  62. streamlit/static/static/js/{index.BoX8d5rK.js → index.Bl7SMZUw.js} +1 -1
  63. streamlit/static/static/js/{index.BGBTkulf.js → index.BqtgAGnG.js} +2 -2
  64. streamlit/static/static/js/{index.KtjGDGY5.js → index.BwnLQnAk.js} +1 -1
  65. streamlit/static/static/js/index.C1coXTgf.js +2 -0
  66. streamlit/static/static/js/{index.CVlg41MB.js → index.C6uOmY9O.js} +1 -1
  67. streamlit/static/static/js/index.CF88nImM.js +1 -0
  68. streamlit/static/static/js/{index.CFCBhOfx.js → index.CFlGfFvq.js} +1 -1
  69. streamlit/static/static/js/{index.Xg-Qttib.js → index.CQgiNpC7.js} +1 -1
  70. streamlit/static/static/js/{index.CCFwVy90.js → index.CZJkiRFm.js} +1 -1
  71. streamlit/static/static/js/index.Ch1TdQMG.js +1 -0
  72. streamlit/static/static/js/{index.CvIqsWy1.js → index.Ck2mQvBi.js} +1 -1
  73. streamlit/static/static/js/{index.BAI9aHCq.js → index.CrD2lwZG.js} +1 -1
  74. streamlit/static/static/js/index.CySNwKoN.js +2 -0
  75. streamlit/static/static/js/index.D3LEkXqN.js +1 -0
  76. streamlit/static/static/js/{index.QTaWooav.js → index.D8BQH06Z.js} +1 -1
  77. streamlit/static/static/js/{index.B9kZB0o1.js → index.DBtWixG1.js} +1 -1
  78. streamlit/static/static/js/{index.BzwlrgZO.js → index.DIsNrJpC.js} +1 -1
  79. streamlit/static/static/js/{index.Fu73QtkD.js → index.DO3HICut.js} +1 -1
  80. streamlit/static/static/js/{index.KN1VmyYN.js → index.D_ziFad8.js} +1 -1
  81. streamlit/static/static/js/{index.pU9mQeVC.js → index.Dblsdn8d.js} +1 -1
  82. streamlit/static/static/js/{index.Boa0Egng.js → index.DcdD0ROn.js} +2 -2
  83. streamlit/static/static/js/{index.CvB9JBqS.js → index.DfHm3P22.js} +51 -51
  84. streamlit/static/static/js/{index.BRfGUOQ-.js → index.DiwhD0Ic.js} +46 -46
  85. streamlit/static/static/js/index.DvZDNiBV.js +11 -0
  86. streamlit/static/static/js/{index.CJ4oJe0V.js → index.HjydQ4bj.js} +1 -1
  87. streamlit/static/static/js/{index.BbSFVZ3p.js → index.HsxzYHNf.js} +1 -1
  88. streamlit/static/static/js/{index.BVT89mQw.js → index.SVJGpnpy.js} +1 -1
  89. streamlit/static/static/js/index.SjKkVSL7.js +1 -0
  90. streamlit/static/static/js/index.hX8_3tMP.js +1 -0
  91. streamlit/static/static/js/{index.CCQ5p_WC.js → index.jZin0w6_.js} +1 -1
  92. streamlit/static/static/js/{index.BnfTPrHb.js → index.pQvPlPcA.js} +4 -4
  93. streamlit/static/static/js/index.pzQTLx9j.js +1 -0
  94. streamlit/static/static/js/{index.D6X2coHR.js → index.s44_OVd6.js} +33 -33
  95. streamlit/static/static/js/{input.CPzINTl-.js → input.jAD-v9D6.js} +2 -2
  96. streamlit/static/static/js/{main.DSPn8dUe.js → main.Cas0fuOs.js} +1 -1
  97. streamlit/static/static/js/{memory.CfD8IGoU.js → memory.ENruL8Qk.js} +1 -1
  98. streamlit/static/static/js/{number-overlay-editor.4Ae0qegV.js → number-overlay-editor.DAOTdulh.js} +2 -2
  99. streamlit/static/static/js/{pandasStylerUtils.D2EjZ7k6.js → pandasStylerUtils.DChYgcPq.js} +1 -1
  100. streamlit/static/static/js/{sandbox.C6vcPIm0.js → sandbox.DWZYRCm0.js} +1 -1
  101. streamlit/static/static/js/{styled-components.BBmp8buj.js → styled-components.3lwVqgRW.js} +1 -1
  102. streamlit/static/static/js/{throttle.BPcPpy-S.js → throttle.DfOW1Cns.js} +1 -1
  103. streamlit/static/static/js/{timepicker.ryzkTs2C.js → timepicker.CXHgL5f9.js} +1 -1
  104. streamlit/static/static/js/{toConsumableArray.Dg1nDaB_.js → toConsumableArray.DiW0GSDV.js} +1 -1
  105. streamlit/static/static/js/uniqueId.Dfi3SGKZ.js +1 -0
  106. streamlit/static/static/js/{useBasicWidgetState.A4U5lzAm.js → useBasicWidgetState.DnPEt_f3.js} +1 -1
  107. streamlit/static/static/js/{useIntlLocale.DWJgLlNz.js → useIntlLocale.BZEGSOVD.js} +8 -8
  108. streamlit/static/static/js/{useTextInputAutoExpand.BrBonw8t.js → useTextInputAutoExpand.MGVZMqyt.js} +1 -1
  109. streamlit/static/static/js/useUpdateUiValue.CPl6CEx3.js +1 -0
  110. streamlit/static/static/js/{useWaveformController.CBlvXlgZ.js → useWaveformController.DOpzDyZu.js} +1 -1
  111. streamlit/static/static/js/{withCalculatedWidth.D4cpOyNe.js → withCalculatedWidth.DgKFTeif.js} +1 -1
  112. streamlit/static/static/js/{withFullScreenWrapper.BMim3w94.js → withFullScreenWrapper.K1jkwhPu.js} +1 -1
  113. streamlit/user_info.py +225 -166
  114. {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260115.dist-info}/METADATA +1 -1
  115. {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260115.dist-info}/RECORD +119 -120
  116. streamlit/commands/experimental_query_params.py +0 -169
  117. streamlit/static/static/js/Particles.S8yD7iW-.js +0 -1
  118. streamlit/static/static/js/Toolbar.B9DaaDfN.js +0 -1
  119. streamlit/static/static/js/index.43b777iP.js +0 -1
  120. streamlit/static/static/js/index.C0fSEz-3.js +0 -1
  121. streamlit/static/static/js/index.CIbgt5wY.js +0 -1
  122. streamlit/static/static/js/index.CSfsEKCF.js +0 -2
  123. streamlit/static/static/js/index.CrPjcPY1.js +0 -1
  124. streamlit/static/static/js/index.D1pK_Vw2.js +0 -1
  125. streamlit/static/static/js/index.DGYHxruh.js +0 -1
  126. streamlit/static/static/js/index.DJ7P09eb.js +0 -2
  127. streamlit/static/static/js/index.Dh5SAThV.js +0 -11
  128. streamlit/static/static/js/index.QHnxuesF.js +0 -1
  129. streamlit/static/static/js/index.j4fnjyHo.js +0 -1
  130. streamlit/static/static/js/uniqueId.BFHzT5KQ.js +0 -1
  131. streamlit/static/static/js/useUpdateUiValue.BkOWyNVX.js +0 -1
  132. {streamlit_nightly-1.52.3.dev20260113.data → streamlit_nightly-1.53.1.dev20260115.data}/scripts/streamlit.cmd +0 -0
  133. {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260115.dist-info}/WHEEL +0 -0
  134. {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260115.dist-info}/entry_points.txt +0 -0
  135. {streamlit_nightly-1.52.3.dev20260113.dist-info → streamlit_nightly-1.53.1.dev20260115.dist-info}/top_level.txt +0 -0
streamlit/__init__.py CHANGED
@@ -60,7 +60,6 @@ _os.environ["MPLBACKEND"] = "Agg"
60
60
  # Must be at the top, to avoid circular dependency.
61
61
  from streamlit import logger as _logger
62
62
  from streamlit import config as _config
63
- from streamlit.deprecation_util import deprecate_func_name as _deprecate_func_name
64
63
  from streamlit.version import STREAMLIT_VERSION_STRING as _STREAMLIT_VERSION_STRING
65
64
 
66
65
  # Give the package a version.
@@ -116,10 +115,6 @@ from streamlit.user_info import (
116
115
  login as _login,
117
116
  logout as _logout,
118
117
  )
119
- from streamlit.commands.experimental_query_params import (
120
- get_query_params as _get_query_params,
121
- set_query_params as _set_query_params,
122
- )
123
118
 
124
119
  import streamlit.column_config as _column_config
125
120
 
@@ -283,27 +278,6 @@ user = _UserInfoProxy()
283
278
  # Experimental APIs
284
279
  experimental_user = _DeprecatedUserInfoProxy()
285
280
 
286
- _EXPERIMENTAL_QUERY_PARAMS_DEPRECATE_MSG = (
287
- "Refer to our [docs page](https://docs.streamlit.io/develop/api-reference/caching-and-state/st.query_params) "
288
- "for more information."
289
- )
290
-
291
- experimental_get_query_params = _deprecate_func_name(
292
- _get_query_params,
293
- "experimental_get_query_params",
294
- "2024-04-11",
295
- _EXPERIMENTAL_QUERY_PARAMS_DEPRECATE_MSG,
296
- name_override="query_params",
297
- )
298
- experimental_set_query_params = _deprecate_func_name(
299
- _set_query_params,
300
- "experimental_set_query_params",
301
- "2024-04-11",
302
- _EXPERIMENTAL_QUERY_PARAMS_DEPRECATE_MSG,
303
- name_override="query_params",
304
- )
305
-
306
-
307
281
  # make it possible to call streamlit.components.v1.html etc. by importing it here
308
282
  # import in the very end to avoid partially-initialized module import errors, because
309
283
  # streamlit.components.v1 also uses some streamlit imports
@@ -56,6 +56,8 @@ def logo(
56
56
  `configuration option <https://docs.streamlit.io/develop/api-reference/configuration/config.toml>`_
57
57
  ``client.toolbarMode="minimal"``.
58
58
 
59
+ If a user clicks the logo, they are redirected to your app's home page.
60
+
59
61
  Parameters
60
62
  ----------
61
63
  image: Anything supported by st.image (except list)
@@ -170,28 +170,28 @@ def set_page_config(
170
170
  .. _st.image: https://docs.streamlit.io/develop/api-reference/media/st.image
171
171
 
172
172
  layout: "centered", "wide", or None
173
- How the page content should be laid out. If this is ``None`` (default),
174
- the page layout is inherited from the previous call of
175
- ``st.set_page_config``. If this is ``None`` and no previous call
176
- exists, the page layout is ``"centered"``.
173
+ Layout of the page content. The following layouts are supported:
177
174
 
178
- ``"centered"`` constrains the elements into a centered column of fixed
179
- width. ``"wide"`` uses the entire screen.
175
+ - ``None`` (default): The page layout is inherited from the previous
176
+ call of ``st.set_page_config``. If no previous call exists, the page
177
+ layout is ``"centered"``.
178
+ - ``"centered"``: Page elements are constrained to a centered column of
179
+ fixed width.
180
+ - ``"wide"``: Page elements use the entire screen width.
180
181
 
181
182
  initial_sidebar_state: "auto", "expanded", "collapsed", int, or None
182
- How the sidebar should start out. If this is ``None`` (default), the
183
- sidebar state is inherited from the previous call of
184
- ``st.set_page_config``. If no previous call exists, the sidebar state
185
- is ``"auto"``.
186
-
187
- The following states are supported:
183
+ Initial state of the sidebar. The following states are supported:
188
184
 
189
- - ``"auto"``: The sidebar is hidden on small devices and shown otherwise.
185
+ - ``None`` (default): The sidebar state is inherited from the previous
186
+ call of ``st.set_page_config``. If no previous call exists, the
187
+ sidebar state is ``"auto"``.
188
+ - ``"auto"``: The sidebar is hidden on small devices and shown
189
+ otherwise.
190
190
  - ``"expanded"``: The sidebar is shown initially.
191
191
  - ``"collapsed"``: The sidebar is hidden initially.
192
- - ``int``: Set the initial sidebar width in pixels. The sidebar will use
193
- "auto" behavior but start with the specified width. Must be a positive integer.
194
- The width is limited to a minimum of 200px and a maximum of 600px.
192
+ - ``int``: The sidebar will use ``"auto"`` behavior but start with the
193
+ specified width in pixels. The width must be between 200 and 600
194
+ pixels, inclusive.
195
195
 
196
196
  In most cases, ``"auto"`` provides the best user experience across
197
197
  devices of different sizes.
@@ -214,8 +214,8 @@ def component(
214
214
  ) -> ComponentRenderer:
215
215
  '''Register an ``st.components.v2`` component and return a callable to mount it.
216
216
 
217
- Components may provide any combination of HTML, CSS, and JavaScript. If none
218
- are provided, the component will render as an empty element without raising
217
+ Components can have any combination of HTML, CSS, and JavaScript. If none
218
+ are provided, the component renders as an empty element without raising
219
219
  an error.
220
220
 
221
221
  If your component is defined in an installed package, you can declare an
streamlit/config.py CHANGED
@@ -2279,6 +2279,35 @@ _create_theme_options(
2279
2279
  """,
2280
2280
  )
2281
2281
 
2282
+ _create_theme_options(
2283
+ "chartDivergingColors",
2284
+ categories=["theme"],
2285
+ description="""
2286
+ An array of ten colors to use for diverging chart data.
2287
+
2288
+ The ten colors create a diverging color scale, typically used for data
2289
+ with a meaningful midpoint. These colors apply to Plotly, Altair, and
2290
+ Vega-Lite charts.
2291
+
2292
+ Invalid color strings are skipped. If there are not exactly ten
2293
+ valid colors specified, Streamlit uses a default set of colors.
2294
+
2295
+ The default colors are:
2296
+ [
2297
+ "#7d353b", #red100
2298
+ "#bd4043", #red90
2299
+ "#ff4b4b", #red70
2300
+ "#ff8c8c", #red50
2301
+ "#ffc7c7", #red30
2302
+ "#a6dcff", #blue30
2303
+ "#60b4ff", #blue50
2304
+ "#1c83e1", #blue70
2305
+ "#0054a3", #blue90
2306
+ "#004280", #blue100
2307
+ ]
2308
+ """,
2309
+ )
2310
+
2282
2311
  # Config Section: Secrets #
2283
2312
 
2284
2313
  _create_section("secrets", "Secrets configuration.")
@@ -35,6 +35,13 @@ class BaseConnection(ABC, Generic[RawConnectionT]):
35
35
  implementation of connections more convenient. See the docstrings for each of the
36
36
  methods of this class for more information
37
37
 
38
+ By default, ``BaseConnection`` is a global-scoped connection. It has a class
39
+ method |BaseConnection.scope()|_ that returns ``"global"``. To implement a session-scoped
40
+ connection, override this method to return ``"session"`` in your subclass.
41
+
42
+ .. |BaseConnection.scope()| replace:: ``BaseConnection.scope()``
43
+ .. _BaseConnection.scope(): #baseconnectionscope
44
+
38
45
  .. note::
39
46
  While providing an implementation of ``_connect`` is technically all that's
40
47
  required to define a valid connection, connections should also provide the user
@@ -179,14 +186,19 @@ class BaseConnection(ABC, Generic[RawConnectionT]):
179
186
  def scope(cls) -> Literal["global", "session"]:
180
187
  """Returns the scope of this connection type.
181
188
 
182
- "global" connection instances will be cached globally, and typically created
183
- once during the lifetime of an application. "session" connection instances will
184
- be cached per session, and typically will be created once per user session.
189
+ This is a class method. ``"global"`` connection instances will be cached
190
+ globally and are typically created once during the lifetime of an
191
+ application. ``"session"`` connection instances will be cached per
192
+ session and are typically created once per user session.
193
+
194
+ A connection's scope can't be changed for different instances of the
195
+ same connection type. If you want to switch between global and
196
+ session-scoped connections, you should create two different connection
197
+ types.
185
198
 
186
199
  Returns
187
200
  -------
188
201
  "global" or "session"
189
- The scope of this connection type.
190
202
  """
191
203
  return "global"
192
204
 
@@ -54,211 +54,12 @@ SNOWPARK_USER_TOKEN_HEADER_NAME = "Sf-Context-Current-User-Token" # noqa: S105
54
54
 
55
55
 
56
56
  class BaseSnowflakeConnection(BaseConnection["InternalSnowflakeConnection"]):
57
- """A connection to Snowflake using the Snowflake Connector for Python.
58
-
59
- For standard connections, create an instance of this using
60
- ``st.connection("snowflake")`` or
61
- ``st.connection("<name>", type="snowflake")``. Connection parameters for a
62
- SnowflakeConnection can be specified using ``secrets.toml`` and/or
63
- ``**kwargs``. Connection parameters are passed to
64
- |snowflake.connector.connect()|.
65
-
66
- When an app is running in Streamlit in Snowflake,
67
- ``st.connection("snowflake")`` connects automatically using the app owner's
68
- role without further configuration. ``**kwargs`` will be ignored in this
69
- case. Use ``secrets.toml`` and ``**kwargs`` to configure your connection
70
- for local development.
71
-
72
- When an app is running in Snowpark Container Services and has caller's rights
73
- enabled, ``st.connection("snowflake-callers-rights")`` connects automatically
74
- using the current user's identity tokens. This will be a session-scoped connection
75
- to ensure that the identity stays tied to the active user. Unlike with
76
- ``"snowflake"`` connections, it will use the Snowpark Container Services connection
77
- settings even when other ``**kwargs`` are provided.
78
-
79
- BaseSnowflakeConnection includes several convenience methods. For example, you
80
- can directly execute a SQL query with ``.query()`` or access the underlying
81
- Snowflake Connector object with ``.raw_connection``.
82
-
83
- .. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
84
- .. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
85
-
86
- .. Important::
87
- `snowflake-snowpark-python <https://pypi.org/project/snowflake-snowpark-python/>`_
88
- must be installed in your environment to use this connection. You can
89
- install it as an extra with Streamlit:
90
-
91
- .. code-block:: shell
92
-
93
- pip install streamlit[snowflake]
94
-
95
- .. Important::
96
- Account identifiers must be of the form ``<orgname>-<account_name>``
97
- where ``<orgname>`` is the name of your Snowflake organization and
98
- ``<account_name>`` is the unique name of your account within your
99
- organization. This is dash-separated, not dot-separated like when used
100
- in SQL queries. For more information, see `Account identifiers
101
- <https://docs.snowflake.com/en/user-guide/admin-account-identifier>`_.
102
-
103
- .. Important::
104
- Caller's rights connections rely on credentials provided when a user first
105
- connects to a Streamlit app. These credentials are only valid for a short period
106
- of time - so caller's rights connections must be created at the top of an app
107
- or else the connection may fail.
108
-
109
- Examples
110
- --------
111
- **Example 1: Configuration with Streamlit secrets**
112
-
113
- You can configure your Snowflake connection using Streamlit's
114
- `Secrets management <https://docs.streamlit.io/develop/concepts/connections/secrets-management>`_.
115
- For example, if you have MFA enabled on your account, you can connect using
116
- `key-pair authentication <https://docs.snowflake.com/en/user-guide/key-pair-auth>`_.
117
-
118
- ``.streamlit/secrets.toml``:
119
-
120
- >>> [connections.snowflake]
121
- >>> account = "xxx-xxx"
122
- >>> user = "xxx"
123
- >>> private_key_file = "/xxx/xxx/xxx.p8"
124
- >>> role = "xxx"
125
- >>> warehouse = "xxx"
126
- >>> database = "xxx"
127
- >>> schema = "xxx"
128
-
129
- Your app code:
130
-
131
- >>> import streamlit as st
132
- >>> conn = st.connection("snowflake")
133
- >>> df = conn.query("SELECT * FROM my_table")
134
-
135
- **Example 2: Configuration with keyword arguments and external authentication**
136
-
137
- You can configure your Snowflake connection with keyword arguments. The
138
- keyword arguments are merged with (and take precedence over) the values in
139
- ``secrets.toml``. However, if you name your connection ``"snowflake"`` and
140
- don't have a ``[connections.snowflake]`` dictionary in your
141
- ``secrets.toml`` file, Streamlit will ignore any keyword arguments and use
142
- the default Snowflake connection as described in Example 5 and Example 6.
143
- To configure your connection using only keyword arguments, declare a name
144
- for the connection other than ``"snowflake"``.
145
-
146
- For example, if your Snowflake account supports SSO, you can set up a quick
147
- local connection for development using `browser-based SSO
148
- <https://docs.snowflake.com/en/user-guide/admin-security-fed-auth-use#how-browser-based-sso-works>`_.
149
- Because there is nothing configured in ``secrets.toml``, the name is an
150
- empty string and the type is set to ``"snowflake"``. This prevents
151
- Streamlit from ignoring the keyword arguments and using a default
152
- Snowflake connection.
153
-
154
- >>> import streamlit as st
155
- >>> conn = st.connection(
156
- ... "",
157
- ... type="snowflake",
158
- ... account="xxx-xxx",
159
- ... user="xxx",
160
- ... authenticator="externalbrowser",
161
- ... )
162
- >>> df = conn.query("SELECT * FROM my_table")
163
-
164
- **Example 3: Named connection with Snowflake's connection configuration file**
165
-
166
- Snowflake's Python Connector supports a `connection configuration file
167
- <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#connecting-using-the-connections-toml-file>`_,
168
- which is well integrated with Streamlit's ``SnowflakeConnection``. If you
169
- already have one or more connections configured, all you need to do is pass
170
- the name of the connection to use.
171
-
172
- ``~/.snowflake/connections.toml``:
173
-
174
- >>> [my_connection]
175
- >>> account = "xxx-xxx"
176
- >>> user = "xxx"
177
- >>> password = "xxx"
178
- >>> warehouse = "xxx"
179
- >>> database = "xxx"
180
- >>> schema = "xxx"
181
-
182
- Your app code:
183
-
184
- >>> import streamlit as st
185
- >>> conn = st.connection("my_connection", type="snowflake")
186
- >>> df = conn.query("SELECT * FROM my_table")
187
-
188
- **Example 4: Named connection with Streamlit secrets and Snowflake's connection configuration file**
189
-
190
- If you have a Snowflake configuration file with a connection named
191
- ``my_connection`` as in Example 3, you can pass the connection name through
192
- ``secrets.toml``.
193
-
194
- ``.streamlit/secrets.toml``:
195
-
196
- >>> [connections.snowflake]
197
- >>> connection_name = "my_connection"
198
-
199
- Your app code:
200
-
201
- >>> import streamlit as st
202
- >>> conn = st.connection("snowflake")
203
- >>> df = conn.query("SELECT * FROM my_table")
204
-
205
- **Example 5: Default connection with an environment variable**
206
-
207
- If you don't have a ``[connections.snowflake]`` dictionary in your
208
- ``secrets.toml`` file and use ``st.connection("snowflake")``, Streamlit
209
- will use the default connection for the `Snowflake Python Connector
210
- <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#setting-a-default-connection>`_.
211
-
212
- If you have a Snowflake configuration file with a connection named
213
- ``my_connection`` as in Example 3, you can set an environment variable to
214
- declare it as the default Snowflake connection.
215
-
216
- >>> SNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"
217
-
218
- Your app code:
219
-
220
- >>> import streamlit as st
221
- >>> conn = st.connection("snowflake")
222
- >>> df = conn.query("SELECT * FROM my_table")
223
-
224
- **Example 6: Default connection in Snowflake's connection configuration file**
225
-
226
- If you have a Snowflake configuration file that defines your ``default``
227
- connection, Streamlit will automatically use it if no other connection is
228
- declared.
229
-
230
- ``~/.snowflake/connections.toml``:
231
-
232
- >>> [default]
233
- >>> account = "xxx-xxx"
234
- >>> user = "xxx"
235
- >>> password = "xxx"
236
- >>> warehouse = "xxx"
237
- >>> database = "xxx"
238
- >>> schema = "xxx"
239
-
240
- Your app code:
241
-
242
- >>> import streamlit as st
243
- >>> conn = st.connection("snowflake")
244
- >>> df = conn.query("SELECT * FROM my_table")
245
-
246
- **Example 7: Caller's rights connection when running in Snowpark Container Services**
247
-
248
- This connection will work for any Streamlit-in-Snowflake app using a container
249
- runtime, as well as any self-managed caller's rights Service in Snowpark Container
250
- Services that is hosting Streamlit.
251
-
252
- This will use the Snowpark-provided account, host, database, and schema to connect.
253
- Additionally, it will set ``client_session_keep_alive`` to ``True``. These values
254
- may be overridden with ``**kwargs``.
255
-
256
- Your app code:
257
-
258
- >>> import streamlit as st
259
- >>> conn = st.connection("snowflake-callers-rights")
260
- >>> df = conn.query("SELECT * FROM my_table")
57
+ """Base class for Snowflake connections.
261
58
 
59
+ This base class provides the common methods and properties for Snowflake
60
+ connections. See the docstrings for each of these methods for more
61
+ information. The docstring for ``SnowflakeConnection`` provides an overall
62
+ description of the Snowflake connection types.
262
63
  """
263
64
 
264
65
  def query(
@@ -553,7 +354,255 @@ class BaseSnowflakeConnection(BaseConnection["InternalSnowflakeConnection"]):
553
354
  class SnowflakeConnection(BaseSnowflakeConnection):
554
355
  """A connection to Snowflake using the Snowflake Connector for Python.
555
356
 
556
- See ``BaseSnowflakeConnection`` for complete docs.
357
+ For standard connections, create an instance of this using
358
+ ``st.connection("snowflake")`` or
359
+ ``st.connection("<name>", type="snowflake")``. Connection parameters for a
360
+ SnowflakeConnection can be specified using ``secrets.toml`` and/or
361
+ ``**kwargs``. Connection parameters are passed to
362
+ |snowflake.connector.connect()|_.
363
+
364
+ When an app is running in Streamlit in Snowflake,
365
+ ``st.connection("snowflake")`` connects automatically using the app owner's
366
+ role without further configuration. ``**kwargs`` are ignored in this
367
+ case. Use ``secrets.toml`` and ``**kwargs`` to configure your connection
368
+ for local development.
369
+
370
+ When an app is running in Snowpark Container Services and has caller's rights
371
+ enabled, ``st.connection("snowflake-callers-rights")`` connects automatically
372
+ using the current user's identity tokens. This is a session-scoped connection
373
+ to ensure that the identity stays tied to the active user. Unlike with
374
+ ``"snowflake"`` connections, it will use the Snowpark Container Services
375
+ connection settings even when other ``**kwargs`` are provided.
376
+
377
+ The Snowflake connection includes several convenience methods. For example, you
378
+ can directly execute a SQL query with ``.query()`` or access the underlying
379
+ Snowflake Connector object with ``.raw_connection``.
380
+
381
+ .. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
382
+ .. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
383
+
384
+ .. Important::
385
+ - `snowflake-snowpark-python <https://pypi.org/project/snowflake-snowpark-python/>`_
386
+ must be installed in your environment to use this connection. You can
387
+ install it as an extra with Streamlit:
388
+
389
+ .. code-block:: shell
390
+
391
+ pip install streamlit[snowflake]
392
+
393
+ - Account identifiers must be of the form ``<orgname>-<account_name>``
394
+ where ``<orgname>`` is the name of your Snowflake organization and
395
+ ``<account_name>`` is the unique name of your account within your
396
+ organization. This is dash-separated, not dot-separated like when used
397
+ in SQL queries. For more information, see `Account identifiers
398
+ <https://docs.snowflake.com/en/user-guide/admin-account-identifier>`_.
399
+
400
+ - Caller's rights connections rely on credentials provided when a user first
401
+ connects to a Streamlit app. These credentials are only valid for about
402
+ two minutes. Therefore, caller's rights connections must be created at
403
+ the top of an app or else the connection may fail.
404
+
405
+ - To develop locally with a caller's rights connection, use an
406
+ environment variable to logically switch between a ``"snowflake"``
407
+ connection locally and a ``"snowflake-callers-rights"`` connection in
408
+ Snowpark Container Services.
409
+
410
+ Examples
411
+ --------
412
+ **Example 1: Configuration with Streamlit secrets**
413
+
414
+ You can configure your Snowflake connection using Streamlit's
415
+ `Secrets management <https://docs.streamlit.io/develop/concepts/connections/secrets-management>`_.
416
+ For example, if you have MFA enabled on your account, you can connect using
417
+ `key-pair authentication <https://docs.snowflake.com/en/user-guide/key-pair-auth>`_.
418
+
419
+ .. code-block:: toml
420
+ :filename: ~/.snowflake/connections.toml
421
+
422
+ [connections.snowflake]
423
+ account = "xxx-xxx"
424
+ user = "xxx"
425
+ private_key_file = "/xxx/xxx/xxx.p8"
426
+ role = "xxx"
427
+ warehouse = "xxx"
428
+ database = "xxx"
429
+ schema = "xxx"
430
+
431
+ .. code-block:: python
432
+ :filename: streamlit_app.py
433
+
434
+ import streamlit as st
435
+
436
+ conn = st.connection("snowflake")
437
+ df = conn.query("SELECT * FROM my_table")
438
+
439
+ **Example 2: Configuration with keyword arguments and external authentication**
440
+
441
+ You can configure your Snowflake connection with keyword arguments. The
442
+ keyword arguments are merged with (and take precedence over) the values in
443
+ ``secrets.toml``. However, if you name your connection ``"snowflake"`` and
444
+ don't have a ``[connections.snowflake]`` dictionary in your
445
+ ``secrets.toml`` file, Streamlit will ignore any keyword arguments and use
446
+ the default Snowflake connection as described in Example 5 and Example 6.
447
+ To configure your connection using only keyword arguments, declare a name
448
+ for the connection other than ``"snowflake"``.
449
+
450
+ For example, if your Snowflake account supports SSO, you can set up a quick
451
+ local connection for development using `browser-based SSO
452
+ <https://docs.snowflake.com/en/user-guide/admin-security-fed-auth-use#how-browser-based-sso-works>`_.
453
+ Because there is nothing configured in ``secrets.toml``, the name is an
454
+ empty string and the type is set to ``"snowflake"``. This prevents
455
+ Streamlit from ignoring the keyword arguments and using a default
456
+ Snowflake connection.
457
+
458
+ .. code-block:: python
459
+ :filename: streamlit_app.py
460
+
461
+ import streamlit as st
462
+
463
+ conn = st.connection(
464
+ "",
465
+ type="snowflake",
466
+ account="xxx-xxx",
467
+ user="xxx",
468
+ authenticator="externalbrowser",
469
+ )
470
+ df = conn.query("SELECT * FROM my_table")
471
+
472
+ **Example 3: Named connection with Snowflake's connection configuration file**
473
+
474
+ Snowflake's Python Connector supports a `connection configuration file
475
+ <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#connecting-using-the-connections-toml-file>`_,
476
+ which is well integrated with Streamlit's ``SnowflakeConnection``. If you
477
+ already have one or more connections configured, all you need to do is pass
478
+ the name of the connection to use.
479
+
480
+ .. code-block:: toml
481
+ :filename: ~/.snowflake/connections.toml
482
+
483
+ [my_connection]
484
+ account = "xxx-xxx"
485
+ user = "xxx"
486
+ password = "xxx"
487
+ warehouse = "xxx"
488
+ database = "xxx"
489
+ schema = "xxx"
490
+
491
+ .. code-block:: python
492
+ :filename: streamlit_app.py
493
+
494
+ import streamlit as st
495
+
496
+ conn = st.connection("my_connection", type="snowflake")
497
+ df = conn.query("SELECT * FROM my_table")
498
+
499
+ **Example 4: Named connection with Streamlit secrets and Snowflake's connection configuration file**
500
+
501
+ If you have a Snowflake configuration file with a connection named
502
+ ``my_connection`` as in Example 3, you can pass the connection name through
503
+ ``secrets.toml``.
504
+
505
+ .. code-block:: toml
506
+ :filename: .streamlit/secrets.toml
507
+
508
+ [connections.snowflake]
509
+ connection_name = "my_connection"
510
+
511
+ .. code-block:: python
512
+ :filename: streamlit_app.py
513
+
514
+ import streamlit as st
515
+
516
+ conn = st.connection("snowflake")
517
+ df = conn.query("SELECT * FROM my_table")
518
+
519
+ **Example 5: Default connection with an environment variable**
520
+
521
+ If you don't have a ``[connections.snowflake]`` dictionary in your
522
+ ``secrets.toml`` file and use ``st.connection("snowflake")``, Streamlit
523
+ will use the default connection for the `Snowflake Python Connector
524
+ <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#setting-a-default-connection>`_.
525
+
526
+ If you have a Snowflake configuration file with a connection named
527
+ ``my_connection`` as in Example 3, you can set an environment variable to
528
+ declare it as the default Snowflake connection.
529
+
530
+ .. code-block:: toml
531
+ :filename: .streamlit/secrets.toml
532
+
533
+ SNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"
534
+
535
+ .. code-block:: python
536
+ :filename: streamlit_app.py
537
+
538
+ import streamlit as st
539
+
540
+ conn = st.connection("snowflake")
541
+ df = conn.query("SELECT * FROM my_table")
542
+
543
+ **Example 6: Default connection in Snowflake's connection configuration file**
544
+
545
+ If you have a Snowflake configuration file that defines your ``default``
546
+ connection, Streamlit will automatically use it if no other connection is
547
+ declared.
548
+
549
+ .. code-block:: toml
550
+ :filename: ~/.snowflake/connections.toml
551
+
552
+ [default]
553
+ account = "xxx-xxx"
554
+ user = "xxx"
555
+ password = "xxx"
556
+ warehouse = "xxx"
557
+ database = "xxx"
558
+ schema = "xxx"
559
+
560
+ .. code-block:: python
561
+ :filename: streamlit_app.py
562
+
563
+ import streamlit as st
564
+
565
+ conn = st.connection("snowflake")
566
+ df = conn.query("SELECT * FROM my_table")
567
+
568
+ **Example 7: Caller's rights connection when running in Snowpark Container Services**
569
+
570
+ You can use ``"snowflake-callers-rights"`` type connections in any
571
+ environment running on Snowpark Container Services, including Streamlit in
572
+ Snowflake on containers and any self-managed caller's rights Service.
573
+
574
+ This will use the Snowpark-provided account, host, database, and schema to connect.
575
+ Additionally, it will set ``client_session_keep_alive`` to ``True``. These values
576
+ may be overridden with ``**kwargs`` in ``st.connection``. For a complete list
577
+ of keyword arguments, see the documentation for |snowflake.connector.connect()|_.
578
+
579
+ .. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
580
+ .. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
581
+
582
+ .. code-block:: python
583
+ :filename: streamlit_app.py
584
+
585
+ import streamlit as st
586
+
587
+ conn = st.connection("snowflake-callers-rights")
588
+ df = conn.query("SELECT * FROM my_table")
589
+
590
+ If you want to develop locally with a caller's rights connection, use an
591
+ environment variable to logically switch between a ``"snowflake"``
592
+ connection locally and a ``"snowflake-callers-rights"`` connection in
593
+ Snowpark Container Services.
594
+
595
+ .. code-block:: python
596
+ :filename: streamlit_app.py
597
+
598
+ import streamlit as st
599
+
600
+ conn = (
601
+ st.connection("snowflake")
602
+ if "LOCAL_DEVELOPMENT" in st.secrets and st.secrets["LOCAL_DEVELOPMENT"]
603
+ else st.connection("snowflake-callers-rights")
604
+ )
605
+ df = conn.query("SELECT * FROM my_table")
557
606
  """
558
607
 
559
608
  def _connect(self, **kwargs: Any) -> InternalSnowflakeConnection:
@@ -341,8 +341,8 @@ class FormMixin:
341
341
  - ``"spinner"``: Displays a spinner as an icon.
342
342
 
343
343
  icon_position : "left" or "right"
344
- The position of the icon relative to the button label. Defaults to
345
- ``"left"``.
344
+ The position of the icon relative to the button label. This
345
+ defaults to ``"left"``.
346
346
 
347
347
  disabled : bool
348
348
  Whether to disable the button. If this is ``False`` (default), the