streamlit-nightly 1.36.1.dev20240630__py2.py3-none-any.whl → 1.36.1.dev20240702__py2.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.
@@ -69,7 +69,7 @@ def navigation(
69
69
  ``streamlit run``) acts like a router or frame of common elements around
70
70
  each of your pages. Streamlit executes the entrypoint file with every app
71
71
  rerun. To execute the current page, you must call the ``.run()`` method on
72
- the page object returned by ``st.navigation``.
72
+ the ``StreamlitPage`` object returned by ``st.navigation``.
73
73
 
74
74
  The set of available pages can be updated with each rerun for dynamic
75
75
  navigation. By default, ``st.navigation`` draws the available pages in the
streamlit/config.py CHANGED
@@ -95,8 +95,6 @@ def set_user_option(key: str, value: Any) -> None:
95
95
 
96
96
  Currently, only the following config options can be set within the script itself:
97
97
  * client.caching
98
- * client.displayEnabled
99
- * deprecation.*
100
98
 
101
99
  Calling with any other options will raise StreamlitAPIException.
102
100
 
@@ -270,23 +268,6 @@ def _delete_option(key: str) -> None:
270
268
 
271
269
  _create_section("global", "Global options that apply across all of Streamlit.")
272
270
 
273
- _create_option(
274
- "global.disableWatchdogWarning",
275
- description="""
276
- By default, Streamlit checks if the Python watchdog module is available
277
- and, if not, prints a warning asking for you to install it. The watchdog
278
- module is not required, but highly recommended. It improves Streamlit's
279
- ability to detect changes to files in your filesystem.
280
-
281
- If you'd like to turn off this warning, set this to True.
282
- """,
283
- default_val=False,
284
- type_=bool,
285
- deprecated=True,
286
- deprecation_text="global.disableWatchdogWarning has been deprecated and will be removed in a future version.",
287
- expiration_date="2024-01-20",
288
- )
289
-
290
271
 
291
272
  _create_option(
292
273
  "global.disableWidgetStateDuplicationWarning",
@@ -328,18 +309,6 @@ def _global_development_mode() -> bool:
328
309
  )
329
310
 
330
311
 
331
- _create_option(
332
- "global.logLevel",
333
- description="""Level of logging: 'error', 'warning', 'info', or 'debug'.
334
-
335
- Default: 'info'
336
- """,
337
- deprecated=True,
338
- deprecation_text="global.logLevel has been replaced with logger.level",
339
- expiration_date="2020-11-30",
340
- replaced_by="logger.level",
341
- )
342
-
343
312
  _create_option(
344
313
  "global.e2eTest",
345
314
  description="Are we in an e2e (playwright) test? Set automatically when our e2e tests are running.",
@@ -401,21 +370,6 @@ _create_option(
401
370
  type_=bool,
402
371
  )
403
372
 
404
- _create_option(
405
- "global.dataFrameSerialization",
406
- description="""
407
- DataFrame serialization.
408
-
409
- Acceptable values:
410
- - 'legacy': Serialize DataFrames using Streamlit's custom format. Slow
411
- but battle-tested.
412
- - 'arrow': Serialize DataFrames using Apache Arrow. Much faster and versatile.""",
413
- default_val="arrow",
414
- type_=str,
415
- deprecated=True,
416
- deprecation_text="Legacy serialization has been removed. All dataframes will be serialized using Apache Arrow.",
417
- expiration_date="2023-11-01",
418
- )
419
373
 
420
374
  # Config Section: Logger #
421
375
  _create_section("logger", "Settings to customize Streamlit log messages.")
@@ -427,9 +381,7 @@ def _logger_log_level() -> str:
427
381
 
428
382
  Default: 'info'
429
383
  """
430
- if get_option("global.logLevel"):
431
- return str(get_option("global.logLevel"))
432
- elif get_option("global.developmentMode"):
384
+ if get_option("global.developmentMode"):
433
385
  return "debug"
434
386
  else:
435
387
  return "info"
@@ -471,17 +423,6 @@ _create_option(
471
423
 
472
424
  _create_section("client", "Settings for scripts that use Streamlit.")
473
425
 
474
- _create_option(
475
- "client.displayEnabled",
476
- description="""If false, makes your Streamlit script not draw to a
477
- Streamlit app.""",
478
- default_val=True,
479
- type_=bool,
480
- scriptable=True,
481
- deprecated=True,
482
- deprecation_text="client.displayEnabled has been deprecated and will be removed in a future version.",
483
- expiration_date="2024-01-20",
484
- )
485
426
 
486
427
  _create_option(
487
428
  "client.showErrorDetails",
@@ -544,33 +485,6 @@ _create_option(
544
485
  type_=bool,
545
486
  )
546
487
 
547
- _create_option(
548
- "runner.installTracer",
549
- description="""
550
- Install a Python tracer to allow you to stop or pause your script at
551
- any point and introspect it. As a side-effect, this slows down your
552
- script's execution.
553
- """,
554
- default_val=False,
555
- type_=bool,
556
- deprecated=True,
557
- deprecation_text="runner.installTracer has been deprecated and will be removed in a future version.",
558
- expiration_date="2024-01-20",
559
- )
560
-
561
- _create_option(
562
- "runner.fixMatplotlib",
563
- description="""
564
- Sets the MPLBACKEND environment variable to Agg inside Streamlit to
565
- prevent Python crashing.
566
- """,
567
- default_val=True,
568
- deprecated=True,
569
- deprecation_text="runner.fixMatplotlib has been deprecated and will be removed in a future version.",
570
- expiration_date="2024-01-20",
571
- type_=bool,
572
- )
573
-
574
488
  _create_option(
575
489
  "runner.postScriptGC",
576
490
  description="""
@@ -925,17 +839,6 @@ _create_option(
925
839
  visibility="hidden",
926
840
  )
927
841
 
928
- _create_option(
929
- "ui.hideSidebarNav",
930
- description="Flag to hide the sidebar page navigation component.",
931
- default_val=False,
932
- type_=bool,
933
- deprecated=True,
934
- deprecation_text="ui.hideSidebarNav has been deprecated and replaced with client.showSidebarNavigation. It will be removed in a future version.",
935
- expiration_date="2024-01-20",
936
- visibility="hidden",
937
- )
938
-
939
842
 
940
843
  # Config Section: Mapbox #
941
844
 
@@ -982,44 +885,6 @@ _create_option(
982
885
  )
983
886
 
984
887
 
985
- # Config Section: deprecations
986
-
987
- _create_section("deprecation", "Configuration to show or hide deprecation warnings.")
988
-
989
- _create_option(
990
- "deprecation.showfileUploaderEncoding",
991
- description="Set to false to disable the deprecation warning for the file uploader encoding.",
992
- default_val=True,
993
- scriptable=True,
994
- type_=bool,
995
- deprecated=True,
996
- deprecation_text="deprecation.showfileUploaderEncoding has been deprecated and will be removed in a future version.",
997
- expiration_date="2021-01-06",
998
- )
999
-
1000
- _create_option(
1001
- "deprecation.showImageFormat",
1002
- description="Set to false to disable the deprecation warning for the image format parameter.",
1003
- default_val=True,
1004
- scriptable=True,
1005
- type_=bool,
1006
- deprecated=True,
1007
- deprecation_text="The format parameter for st.image has been removed.",
1008
- expiration_date="2021-03-24",
1009
- )
1010
-
1011
- _create_option(
1012
- "deprecation.showPyplotGlobalUse",
1013
- description="Set to false to disable the deprecation warning for using the global pyplot instance.",
1014
- default_val=True,
1015
- scriptable=True,
1016
- deprecated=True,
1017
- deprecation_text="The support for global pyplot instances is planned to be removed soon.",
1018
- expiration_date="2024-04-15",
1019
- type_=bool,
1020
- )
1021
-
1022
-
1023
888
  # Config Section: Custom Theme #
1024
889
 
1025
890
  _create_section("theme", "Settings to define a custom theme for your Streamlit app.")
@@ -110,7 +110,7 @@ def dialog_decorator(
110
110
  app should generally be stored in Session State.
111
111
 
112
112
  A user can dismiss a modal dialog by clicking outside of it, clicking the
113
- "**X**" in its upper-right corner, or pressing``ESC`` on their keyboard.
113
+ "**X**" in its upper-right corner, or pressing ``ESC`` on their keyboard.
114
114
  Dismissing a modal dialog does not trigger an app rerun. To close the modal
115
115
  dialog programmatically, call ``st.rerun()`` explicitly inside of the
116
116
  dialog function.
@@ -23,7 +23,6 @@ from streamlit.errors import (
23
23
  MarkdownFormattedException,
24
24
  StreamlitAPIException,
25
25
  StreamlitAPIWarning,
26
- StreamlitDeprecationWarning,
27
26
  UncaughtAppException,
28
27
  )
29
28
  from streamlit.logger import get_logger
@@ -88,16 +87,11 @@ def marshall(exception_proto: ExceptionProto, exception: BaseException) -> None:
88
87
  # If this is a StreamlitAPIException, we prune all Streamlit entries
89
88
  # from the exception's stack trace.
90
89
  is_api_exception = isinstance(exception, StreamlitAPIException)
91
- is_deprecation_exception = isinstance(exception, StreamlitDeprecationWarning)
92
90
  is_markdown_exception = isinstance(exception, MarkdownFormattedException)
93
91
  is_uncaught_app_exception = isinstance(exception, UncaughtAppException)
94
92
 
95
- stack_trace = (
96
- []
97
- if is_deprecation_exception
98
- else _get_stack_trace_str_list(
99
- exception, strip_streamlit_stack_entries=is_api_exception
100
- )
93
+ stack_trace = _get_stack_trace_str_list(
94
+ exception, strip_streamlit_stack_entries=is_api_exception
101
95
  )
102
96
 
103
97
  # Some exceptions (like UserHashError) have an alternate_name attribute so
@@ -205,6 +205,7 @@ def _validate_image_format_string(
205
205
  if format == "JPG":
206
206
  return "JPEG"
207
207
 
208
+ pil_image: PILImage
208
209
  if isinstance(image_data, bytes):
209
210
  from PIL import Image
210
211
 
@@ -287,7 +288,7 @@ def _ensure_image_size_and_format(
287
288
  """
288
289
  from PIL import Image
289
290
 
290
- pil_image = Image.open(io.BytesIO(image_data))
291
+ pil_image: PILImage = Image.open(io.BytesIO(image_data))
291
292
  actual_width, actual_height = pil_image.size
292
293
 
293
294
  if width < 0 and actual_width > MAXIMUM_CONTENT_WIDTH:
@@ -95,7 +95,7 @@ class MediaMixin:
95
95
  one of the following:
96
96
 
97
97
  * ``None`` (default): The element plays from the beginning.
98
- * An``int`` or ``float`` specifying the time in seconds. ``float``
98
+ * An ``int`` or ``float`` specifying the time in seconds. ``float``
99
99
  values are rounded down to whole seconds.
100
100
  * A string specifying the time in a format supported by `Pandas'
101
101
  Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
@@ -20,8 +20,7 @@ import io
20
20
  from typing import TYPE_CHECKING, Any, cast
21
21
 
22
22
  import streamlit.elements.image as image_utils
23
- from streamlit import config
24
- from streamlit.errors import StreamlitDeprecationWarning
23
+ from streamlit.deprecation_util import show_deprecation_warning
25
24
  from streamlit.proto.Image_pb2 import ImageList as ImageListProto
26
25
  from streamlit.runtime.metrics_util import gather_metrics
27
26
 
@@ -45,9 +44,13 @@ class PyplotMixin:
45
44
  Parameters
46
45
  ----------
47
46
  fig : Matplotlib Figure
48
- The figure to plot. When this argument isn't specified, this
49
- function will render the global figure (but this is deprecated,
50
- as described below)
47
+ The Matplotlib ``Figure`` object to render. See
48
+ https://matplotlib.org/stable/gallery/index.html for examples.
49
+
50
+ .. note::
51
+ When this argument isn't specified, this function will render the global
52
+ Matplotlib figure object. However, this feature is deprecated and
53
+ will be removed in a later version.
51
54
 
52
55
  clear_figure : bool
53
56
  If True, the figure will be cleared after being rendered.
@@ -87,15 +90,6 @@ class PyplotMixin:
87
90
  https://doc-pyplot.streamlit.app/
88
91
  height: 630px
89
92
 
90
- Notes
91
- -----
92
- .. note::
93
- Deprecation warning. After December 1st, 2020, we will remove the ability
94
- to specify no arguments in `st.pyplot()`, as that requires the use of
95
- Matplotlib's global figure object, which is not thread-safe. So
96
- please always pass a figure object as shown in the example section
97
- above.
98
-
99
93
  Matplotlib supports several types of "backends". If you're getting an
100
94
  error using Matplotlib with Streamlit, try setting your backend to "TkAgg"::
101
95
 
@@ -105,8 +99,24 @@ class PyplotMixin:
105
99
 
106
100
  """
107
101
 
108
- if not fig and config.get_option("deprecation.showPyplotGlobalUse"):
109
- self.dg.exception(PyplotGlobalUseWarning())
102
+ if not fig:
103
+ show_deprecation_warning("""
104
+ Calling `st.pyplot()` without providing a figure argument has been deprecated
105
+ and will be removed in a later version as it requires the use of Matplotlib's
106
+ global figure object, which is not thread-safe.
107
+
108
+ To future-proof this code, you should pass in a figure as shown below:
109
+
110
+ ```python
111
+ fig, ax = plt.subplots()
112
+ ax.scatter([1, 2, 3], [1, 2, 3])
113
+ # other plotting actions...
114
+ st.pyplot(fig)
115
+ ```
116
+
117
+ If you have a specific use case that requires this functionality, please let us
118
+ know via [issue on Github](https://github.com/streamlit/streamlit/issues).
119
+ """)
110
120
 
111
121
  image_list_proto = ImageListProto()
112
122
  marshall(
@@ -181,26 +191,3 @@ def marshall(
181
191
  # plt calls will be starting fresh.
182
192
  if clear_figure:
183
193
  fig.clf()
184
-
185
-
186
- class PyplotGlobalUseWarning(StreamlitDeprecationWarning):
187
- def __init__(self) -> None:
188
- super().__init__(
189
- msg=self._get_message(), config_option="deprecation.showPyplotGlobalUse"
190
- )
191
-
192
- def _get_message(self) -> str:
193
- return """
194
- You are calling `st.pyplot()` without any arguments. After December 1st, 2020,
195
- we will remove the ability to do this as it requires the use of Matplotlib's global
196
- figure object, which is not thread-safe.
197
-
198
- To future-proof this code, you should pass in a figure as shown below:
199
-
200
- ```python
201
- >>> fig, ax = plt.subplots()
202
- >>> ax.scatter([1, 2, 3], [1, 2, 3])
203
- >>> ... other plotting actions ...
204
- >>> st.pyplot(fig)
205
- ```
206
- """
streamlit/errors.py CHANGED
@@ -108,35 +108,6 @@ class StreamlitAPIWarning(StreamlitAPIException, Warning):
108
108
  return util.repr_(self)
109
109
 
110
110
 
111
- class StreamlitDeprecationWarning(StreamlitAPIWarning):
112
- """Used to display a warning.
113
-
114
- Note that this should not be "raised", but passed to st.exception
115
- instead.
116
- """
117
-
118
- def __init__(self, config_option, msg, *args):
119
- message = """
120
- {0}
121
-
122
- You can disable this warning by disabling the config option:
123
- `{1}`
124
-
125
- ```
126
- st.set_option('{1}', False)
127
- ```
128
- or in your `.streamlit/config.toml`
129
- ```
130
- [deprecation]
131
- {2} = false
132
- ```
133
- """.format(msg, config_option, config_option.split(".")[1])
134
- super().__init__(message, *args)
135
-
136
- def __repr__(self) -> str:
137
- return util.repr_(self)
138
-
139
-
140
111
  class StreamlitModuleNotFoundError(StreamlitAPIWarning):
141
112
  """Print a pretty message when a Streamlit command requires a dependency
142
113
  that is not one of our core dependencies."""
@@ -41,11 +41,16 @@ def Page(
41
41
  ``st.navigation`` to declare a page in your app.
42
42
 
43
43
  When a user navigates to a page, ``st.navigation`` returns the selected
44
- ``StreamlitPage`` object. Call ``StreamlitPage.run()`` on the returned page
45
- to execute the page. You can only run the page returned by
44
+ ``StreamlitPage`` object. Call ``.run()`` on the returned ``StreamlitPage``
45
+ object to execute the page. You can only run the page returned by
46
46
  ``st.navigation``, and you can only run it once per app rerun.
47
47
 
48
- A page can be defined by a Python file or ``Callable``.
48
+ A page can be defined by a Python file or ``Callable``. Python files used
49
+ as a ``StreamlitPage`` source will have ``__name__ == "__page__"``.
50
+ Functions used as a ``StreamlitPage`` source will have ``__name__``
51
+ corresponding to the module they were imported from. Only the entrypoint
52
+ file and functions defined within the entrypoint file have
53
+ ``__name__ == "__main__"`` to adhere to Python convention.
49
54
 
50
55
  Parameters
51
56
  ----------
@@ -211,7 +211,7 @@ class Config(google.protobuf.message.Message):
211
211
  hide_top_bar: builtins.bool
212
212
  """See config option "ui.hideTopBar"."""
213
213
  hide_sidebar_nav: builtins.bool
214
- """See config option "ui.hideSidebarNav"."""
214
+ """See config option "client.showSidebarNavigation"."""
215
215
  toolbar_mode: global___Config.ToolbarMode.ValueType
216
216
  def __init__(
217
217
  self,
@@ -270,8 +270,6 @@ class AppSession:
270
270
  The message to enqueue
271
271
 
272
272
  """
273
- if not config.get_option("client.displayEnabled"):
274
- return
275
273
 
276
274
  if self._debug_last_backmsg_id:
277
275
  msg.debug_last_backmsg_id = self._debug_last_backmsg_id
@@ -883,8 +881,6 @@ def _populate_config_msg(msg: Config) -> None:
883
881
  msg.max_cached_message_age = config.get_option("global.maxCachedMessageAge")
884
882
  msg.allow_run_on_save = config.get_option("server.allowRunOnSave")
885
883
  msg.hide_top_bar = config.get_option("ui.hideTopBar")
886
- # ui.hideSidebarNav is deprecated, will be removed in the future
887
- msg.hide_sidebar_nav = config.get_option("ui.hideSidebarNav")
888
884
  if config.get_option("client.showSidebarNavigation") is False:
889
885
  msg.hide_sidebar_nav = True
890
886
  msg.toolbar_mode = _get_toolbar_mode()
@@ -336,12 +336,7 @@ class ScriptRunner:
336
336
  # Whenever we enqueue a ForwardMsg, we also handle any pending
337
337
  # execution control request. This means that a script can be
338
338
  # cleanly interrupted and stopped inside most `st.foo` calls.
339
- #
340
- # (If "runner.installTracer" is true, then we'll actually be
341
- # handling these requests in a callback called after every Python
342
- # instruction instead.)
343
- if not config.get_option("runner.installTracer"):
344
- self._maybe_handle_execution_control_request()
339
+ self._maybe_handle_execution_control_request()
345
340
 
346
341
  # Pass the message to our associated AppSession.
347
342
  self.on_event.send(
@@ -382,17 +377,6 @@ class ScriptRunner:
382
377
  assert request.type == ScriptRequestType.STOP
383
378
  raise StopException()
384
379
 
385
- def _install_tracer(self) -> None:
386
- """Install function that runs before each line of the script."""
387
-
388
- def trace_calls(frame, event, arg):
389
- self._maybe_handle_execution_control_request()
390
- return trace_calls
391
-
392
- # Python interpreters are not required to implement sys.settrace.
393
- if hasattr(sys, "settrace"):
394
- sys.settrace(trace_calls)
395
-
396
380
  @contextmanager
397
381
  def _set_execing_flag(self):
398
382
  """A context for setting the ScriptRunner._execing flag.
@@ -426,8 +410,12 @@ class ScriptRunner:
426
410
  start_time: float = timer()
427
411
  prep_time: float = 0 # This will be overwritten once preparations are done.
428
412
 
429
- # Reset DeltaGenerators, widgets, media files.
430
- runtime.get_instance().media_file_mgr.clear_session_refs()
413
+ if not rerun_data.fragment_id_queue:
414
+ # Don't clear session refs for media files if we're running a fragment.
415
+ # Otherwise, we're likely to remove files that still have corresponding
416
+ # download buttons/links to them present in the app, which will result
417
+ # in a 404 should the user click on them.
418
+ runtime.get_instance().media_file_mgr.clear_session_refs()
431
419
 
432
420
  self._pages_manager.set_script_intent(
433
421
  rerun_data.page_script_hash, rerun_data.page_name
@@ -520,9 +508,6 @@ class ScriptRunner:
520
508
  # is to run it. Errors thrown during execution will be shown to the
521
509
  # user as ExceptionElements.
522
510
 
523
- if config.get_option("runner.installTracer"):
524
- self._install_tracer()
525
-
526
511
  # Create fake module. This gives us a name global namespace to
527
512
  # execute the code in.
528
513
  module = self._new_module("__main__")
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.29bca1b5.css",
4
- "main.js": "./static/js/main.0326e951.js",
4
+ "main.js": "./static/js/main.e2ab315a.js",
5
5
  "static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
6
6
  "static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
7
7
  "static/js/2736.4336e2b9.chunk.js": "./static/js/2736.4336e2b9.chunk.js",
@@ -151,6 +151,6 @@
151
151
  },
152
152
  "entrypoints": [
153
153
  "static/css/main.29bca1b5.css",
154
- "static/js/main.0326e951.js"
154
+ "static/js/main.e2ab315a.js"
155
155
  ]
156
156
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.0326e951.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.e2ab315a.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>