streamlit-nightly 1.32.3.dev20240325__py2.py3-none-any.whl → 1.32.3.dev20240328__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.
Files changed (85) hide show
  1. streamlit/__init__.py +4 -2
  2. streamlit/components/v1/__init__.py +3 -17
  3. streamlit/components/v1/{custom_component.py → components.py} +159 -11
  4. streamlit/delta_generator.py +3 -0
  5. streamlit/elements/media.py +52 -4
  6. streamlit/elements/widgets/time_widgets.py +5 -21
  7. streamlit/errors.py +0 -6
  8. streamlit/proto/AutoRerun_pb2.py +25 -0
  9. streamlit/proto/AutoRerun_pb2.pyi +48 -0
  10. streamlit/proto/ClientState_pb2.py +3 -3
  11. streamlit/proto/ClientState_pb2.pyi +4 -1
  12. streamlit/proto/Delta_pb2.py +2 -2
  13. streamlit/proto/Delta_pb2.pyi +4 -1
  14. streamlit/proto/ForwardMsg_pb2.py +10 -9
  15. streamlit/proto/ForwardMsg_pb2.pyi +12 -3
  16. streamlit/proto/NewSession_pb2.py +24 -24
  17. streamlit/proto/NewSession_pb2.pyi +8 -1
  18. streamlit/proto/PageProfile_pb2.py +6 -6
  19. streamlit/proto/PageProfile_pb2.pyi +4 -1
  20. streamlit/runtime/app_session.py +67 -24
  21. streamlit/runtime/caching/cache_data_api.py +3 -3
  22. streamlit/runtime/caching/cache_errors.py +0 -11
  23. streamlit/runtime/caching/cache_resource_api.py +2 -2
  24. streamlit/runtime/caching/cache_utils.py +1 -43
  25. streamlit/runtime/fragment.py +239 -0
  26. streamlit/runtime/metrics_util.py +17 -9
  27. streamlit/runtime/runtime.py +6 -12
  28. streamlit/runtime/runtime_util.py +54 -2
  29. streamlit/runtime/scriptrunner/script_requests.py +53 -37
  30. streamlit/runtime/scriptrunner/script_run_context.py +15 -2
  31. streamlit/runtime/scriptrunner/script_runner.py +63 -14
  32. streamlit/runtime/state/common.py +2 -0
  33. streamlit/runtime/state/session_state.py +51 -7
  34. streamlit/runtime/state/widgets.py +10 -2
  35. streamlit/static/asset-manifest.json +19 -19
  36. streamlit/static/index.html +1 -1
  37. streamlit/static/static/js/1074.73973756.chunk.js +1 -0
  38. streamlit/static/static/js/1451.3b0a3e31.chunk.js +1 -0
  39. streamlit/static/static/js/1792.b8efa879.chunk.js +1 -0
  40. streamlit/static/static/js/{3092.3d4df25e.chunk.js → 3092.ad569cc8.chunk.js} +1 -1
  41. streamlit/static/static/js/3513.e3e7300a.chunk.js +1 -0
  42. streamlit/static/static/js/4177.69f9f18d.chunk.js +1 -0
  43. streamlit/static/static/js/4319.a6745434.chunk.js +1 -0
  44. streamlit/static/static/js/{4477.2555c11a.chunk.js → 4477.e10e4373.chunk.js} +1 -1
  45. streamlit/static/static/js/{4666.99f3abc3.chunk.js → 4666.b694c5a9.chunk.js} +1 -1
  46. streamlit/static/static/js/5106.44f0ff51.chunk.js +1 -0
  47. streamlit/static/static/js/5379.6571574f.chunk.js +1 -0
  48. streamlit/static/static/js/6013.8e80e091.chunk.js +1 -0
  49. streamlit/static/static/js/6718.802da17e.chunk.js +1 -0
  50. streamlit/static/static/js/7175.be4076bc.chunk.js +1 -0
  51. streamlit/static/static/js/{7602.f0420392.chunk.js → 7602.6175e969.chunk.js} +1 -1
  52. streamlit/static/static/js/{8492.e6dab83f.chunk.js → 8492.f56c9d4c.chunk.js} +1 -1
  53. streamlit/static/static/js/8691.9ccf7f89.chunk.js +1 -0
  54. streamlit/static/static/js/main.722453f0.js +2 -0
  55. streamlit/testing/v1/local_script_runner.py +2 -0
  56. streamlit/time_util.py +88 -0
  57. streamlit/watcher/local_sources_watcher.py +2 -1
  58. streamlit/web/server/component_request_handler.py +2 -2
  59. streamlit/web/server/server.py +2 -1
  60. {streamlit_nightly-1.32.3.dev20240325.dist-info → streamlit_nightly-1.32.3.dev20240328.dist-info}/METADATA +1 -1
  61. {streamlit_nightly-1.32.3.dev20240325.dist-info → streamlit_nightly-1.32.3.dev20240328.dist-info}/RECORD +66 -68
  62. streamlit/components/lib/__init__.py +0 -13
  63. streamlit/components/lib/local_component_registry.py +0 -82
  64. streamlit/components/types/__init__.py +0 -13
  65. streamlit/components/types/base_component_registry.py +0 -98
  66. streamlit/components/types/base_custom_component.py +0 -137
  67. streamlit/components/v1/component_registry.py +0 -103
  68. streamlit/static/static/js/1074.71719df6.chunk.js +0 -1
  69. streamlit/static/static/js/1451.e3be1711.chunk.js +0 -1
  70. streamlit/static/static/js/1792.16c16498.chunk.js +0 -1
  71. streamlit/static/static/js/3513.57cff89c.chunk.js +0 -1
  72. streamlit/static/static/js/4177.ab9a7aa1.chunk.js +0 -1
  73. streamlit/static/static/js/4319.213fc321.chunk.js +0 -1
  74. streamlit/static/static/js/5106.22187bfc.chunk.js +0 -1
  75. streamlit/static/static/js/5379.e466522d.chunk.js +0 -1
  76. streamlit/static/static/js/6013.75c92264.chunk.js +0 -1
  77. streamlit/static/static/js/6718.97945fc6.chunk.js +0 -1
  78. streamlit/static/static/js/7175.8c1b4d38.chunk.js +0 -1
  79. streamlit/static/static/js/8691.24a5792f.chunk.js +0 -1
  80. streamlit/static/static/js/main.7fde7092.js +0 -2
  81. /streamlit/static/static/js/{main.7fde7092.js.LICENSE.txt → main.722453f0.js.LICENSE.txt} +0 -0
  82. {streamlit_nightly-1.32.3.dev20240325.data → streamlit_nightly-1.32.3.dev20240328.data}/scripts/streamlit.cmd +0 -0
  83. {streamlit_nightly-1.32.3.dev20240325.dist-info → streamlit_nightly-1.32.3.dev20240328.dist-info}/WHEEL +0 -0
  84. {streamlit_nightly-1.32.3.dev20240325.dist-info → streamlit_nightly-1.32.3.dev20240328.dist-info}/entry_points.txt +0 -0
  85. {streamlit_nightly-1.32.3.dev20240325.dist-info → streamlit_nightly-1.32.3.dev20240328.dist-info}/top_level.txt +0 -0
@@ -11,6 +11,7 @@ from google.protobuf import symbol_database as _symbol_database
11
11
  _sym_db = _symbol_database.Default()
12
12
 
13
13
 
14
+ from streamlit.proto import AutoRerun_pb2 as streamlit_dot_proto_dot_AutoRerun__pb2
14
15
  from streamlit.proto import Common_pb2 as streamlit_dot_proto_dot_Common__pb2
15
16
  from streamlit.proto import Delta_pb2 as streamlit_dot_proto_dot_Delta__pb2
16
17
  from streamlit.proto import GitInfo_pb2 as streamlit_dot_proto_dot_GitInfo__pb2
@@ -25,7 +26,7 @@ from streamlit.proto import SessionEvent_pb2 as streamlit_dot_proto_dot_SessionE
25
26
  from streamlit.proto import SessionStatus_pb2 as streamlit_dot_proto_dot_SessionStatus__pb2
26
27
 
27
28
 
28
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n streamlit/proto/ForwardMsg.proto\x1a\x1cstreamlit/proto/Common.proto\x1a\x1bstreamlit/proto/Delta.proto\x1a\x1dstreamlit/proto/GitInfo.proto\x1a streamlit/proto/NewSession.proto\x1a streamlit/proto/PageConfig.proto\x1a\x1estreamlit/proto/PageInfo.proto\x1a!streamlit/proto/PageProfile.proto\x1a\"streamlit/proto/PageNotFound.proto\x1a\"streamlit/proto/PagesChanged.proto\x1a#streamlit/proto/ParentMessage.proto\x1a\"streamlit/proto/SessionEvent.proto\x1a#streamlit/proto/SessionStatus.proto\"\x9a\x06\n\nForwardMsg\x12\x0c\n\x04hash\x18\x01 \x01(\t\x12%\n\x08metadata\x18\x02 \x01(\x0b\x32\x13.ForwardMsgMetadata\x12\"\n\x0bnew_session\x18\x04 \x01(\x0b\x32\x0b.NewSessionH\x00\x12\x17\n\x05\x64\x65lta\x18\x05 \x01(\x0b\x32\x06.DeltaH\x00\x12&\n\x11page_info_changed\x18\x0c \x01(\x0b\x32\t.PageInfoH\x00\x12*\n\x13page_config_changed\x18\r \x01(\x0b\x32\x0b.PageConfigH\x00\x12;\n\x0fscript_finished\x18\x06 \x01(\x0e\x32 .ForwardMsg.ScriptFinishedStatusH\x00\x12$\n\x10git_info_changed\x18\x0e \x01(\x0b\x32\x08.GitInfoH\x00\x12$\n\x0cpage_profile\x18\x12 \x01(\x0b\x32\x0c.PageProfileH\x00\x12\x30\n\x16session_status_changed\x18\t \x01(\x0b\x32\x0e.SessionStatusH\x00\x12&\n\rsession_event\x18\n \x01(\x0b\x32\r.SessionEventH\x00\x12\'\n\x0epage_not_found\x18\x0f \x01(\x0b\x32\r.PageNotFoundH\x00\x12&\n\rpages_changed\x18\x10 \x01(\x0b\x32\r.PagesChangedH\x00\x12/\n\x12\x66ile_urls_response\x18\x13 \x01(\x0b\x32\x11.FileURLsResponseH\x00\x12(\n\x0eparent_message\x18\x14 \x01(\x0b\x32\x0e.ParentMessageH\x00\x12\x12\n\x08ref_hash\x18\x0b \x01(\tH\x00\x12\x1d\n\x15\x64\x65\x62ug_last_backmsg_id\x18\x11 \x01(\t\"p\n\x14ScriptFinishedStatus\x12\x19\n\x15\x46INISHED_SUCCESSFULLY\x10\x00\x12\x1f\n\x1b\x46INISHED_WITH_COMPILE_ERROR\x10\x01\x12\x1c\n\x18\x46INISHED_EARLY_FOR_RERUN\x10\x02\x42\x06\n\x04typeJ\x04\x08\x07\x10\x08J\x04\x08\x08\x10\t\"r\n\x12\x46orwardMsgMetadata\x12\x11\n\tcacheable\x18\x01 \x01(\x08\x12\x12\n\ndelta_path\x18\x02 \x03(\r\x12\x35\n\x16\x65lement_dimension_spec\x18\x03 \x01(\x0b\x32\x15.ElementDimensionSpec\"5\n\x14\x45lementDimensionSpec\x12\r\n\x05width\x18\x01 \x01(\r\x12\x0e\n\x06height\x18\x02 \x01(\rB/\n\x1c\x63om.snowflake.apps.streamlitB\x0f\x46orwardMsgProtob\x06proto3')
29
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n streamlit/proto/ForwardMsg.proto\x1a\x1fstreamlit/proto/AutoRerun.proto\x1a\x1cstreamlit/proto/Common.proto\x1a\x1bstreamlit/proto/Delta.proto\x1a\x1dstreamlit/proto/GitInfo.proto\x1a streamlit/proto/NewSession.proto\x1a streamlit/proto/PageConfig.proto\x1a\x1estreamlit/proto/PageInfo.proto\x1a!streamlit/proto/PageProfile.proto\x1a\"streamlit/proto/PageNotFound.proto\x1a\"streamlit/proto/PagesChanged.proto\x1a#streamlit/proto/ParentMessage.proto\x1a\"streamlit/proto/SessionEvent.proto\x1a#streamlit/proto/SessionStatus.proto\"\xe5\x06\n\nForwardMsg\x12\x0c\n\x04hash\x18\x01 \x01(\t\x12%\n\x08metadata\x18\x02 \x01(\x0b\x32\x13.ForwardMsgMetadata\x12\"\n\x0bnew_session\x18\x04 \x01(\x0b\x32\x0b.NewSessionH\x00\x12\x17\n\x05\x64\x65lta\x18\x05 \x01(\x0b\x32\x06.DeltaH\x00\x12&\n\x11page_info_changed\x18\x0c \x01(\x0b\x32\t.PageInfoH\x00\x12*\n\x13page_config_changed\x18\r \x01(\x0b\x32\x0b.PageConfigH\x00\x12;\n\x0fscript_finished\x18\x06 \x01(\x0e\x32 .ForwardMsg.ScriptFinishedStatusH\x00\x12$\n\x10git_info_changed\x18\x0e \x01(\x0b\x32\x08.GitInfoH\x00\x12$\n\x0cpage_profile\x18\x12 \x01(\x0b\x32\x0c.PageProfileH\x00\x12\x30\n\x16session_status_changed\x18\t \x01(\x0b\x32\x0e.SessionStatusH\x00\x12&\n\rsession_event\x18\n \x01(\x0b\x32\r.SessionEventH\x00\x12\'\n\x0epage_not_found\x18\x0f \x01(\x0b\x32\r.PageNotFoundH\x00\x12&\n\rpages_changed\x18\x10 \x01(\x0b\x32\r.PagesChangedH\x00\x12/\n\x12\x66ile_urls_response\x18\x13 \x01(\x0b\x32\x11.FileURLsResponseH\x00\x12 \n\nauto_rerun\x18\x15 \x01(\x0b\x32\n.AutoRerunH\x00\x12(\n\x0eparent_message\x18\x14 \x01(\x0b\x32\x0e.ParentMessageH\x00\x12\x12\n\x08ref_hash\x18\x0b \x01(\tH\x00\x12\x1d\n\x15\x64\x65\x62ug_last_backmsg_id\x18\x11 \x01(\t\"\x98\x01\n\x14ScriptFinishedStatus\x12\x19\n\x15\x46INISHED_SUCCESSFULLY\x10\x00\x12\x1f\n\x1b\x46INISHED_WITH_COMPILE_ERROR\x10\x01\x12\x1c\n\x18\x46INISHED_EARLY_FOR_RERUN\x10\x02\x12&\n\"FINISHED_FRAGMENT_RUN_SUCCESSFULLY\x10\x03\x42\x06\n\x04typeJ\x04\x08\x07\x10\x08J\x04\x08\x08\x10\t\"r\n\x12\x46orwardMsgMetadata\x12\x11\n\tcacheable\x18\x01 \x01(\x08\x12\x12\n\ndelta_path\x18\x02 \x03(\r\x12\x35\n\x16\x65lement_dimension_spec\x18\x03 \x01(\x0b\x32\x15.ElementDimensionSpec\"5\n\x14\x45lementDimensionSpec\x12\r\n\x05width\x18\x01 \x01(\r\x12\x0e\n\x06height\x18\x02 \x01(\rB/\n\x1c\x63om.snowflake.apps.streamlitB\x0f\x46orwardMsgProtob\x06proto3')
29
30
 
30
31
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
31
32
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.ForwardMsg_pb2', globals())
@@ -33,12 +34,12 @@ if _descriptor._USE_C_DESCRIPTORS == False:
33
34
 
34
35
  DESCRIPTOR._options = None
35
36
  DESCRIPTOR._serialized_options = b'\n\034com.snowflake.apps.streamlitB\017ForwardMsgProto'
36
- _FORWARDMSG._serialized_start=444
37
- _FORWARDMSG._serialized_end=1238
38
- _FORWARDMSG_SCRIPTFINISHEDSTATUS._serialized_start=1106
39
- _FORWARDMSG_SCRIPTFINISHEDSTATUS._serialized_end=1218
40
- _FORWARDMSGMETADATA._serialized_start=1240
41
- _FORWARDMSGMETADATA._serialized_end=1354
42
- _ELEMENTDIMENSIONSPEC._serialized_start=1356
43
- _ELEMENTDIMENSIONSPEC._serialized_end=1409
37
+ _FORWARDMSG._serialized_start=477
38
+ _FORWARDMSG._serialized_end=1346
39
+ _FORWARDMSG_SCRIPTFINISHEDSTATUS._serialized_start=1174
40
+ _FORWARDMSG_SCRIPTFINISHEDSTATUS._serialized_end=1326
41
+ _FORWARDMSGMETADATA._serialized_start=1348
42
+ _FORWARDMSGMETADATA._serialized_end=1462
43
+ _ELEMENTDIMENSIONSPEC._serialized_start=1464
44
+ _ELEMENTDIMENSIONSPEC._serialized_end=1517
44
45
  # @@protoc_insertion_point(module_scope)
@@ -22,6 +22,7 @@ import google.protobuf.descriptor
22
22
  import google.protobuf.internal.containers
23
23
  import google.protobuf.internal.enum_type_wrapper
24
24
  import google.protobuf.message
25
+ import streamlit.proto.AutoRerun_pb2
25
26
  import streamlit.proto.Common_pb2
26
27
  import streamlit.proto.Delta_pb2
27
28
  import streamlit.proto.GitInfo_pb2
@@ -61,6 +62,8 @@ class ForwardMsg(google.protobuf.message.Message):
61
62
  """The script failed to compile"""
62
63
  FINISHED_EARLY_FOR_RERUN: ForwardMsg._ScriptFinishedStatus.ValueType # 2
63
64
  """Script was interrupted by rerun"""
65
+ FINISHED_FRAGMENT_RUN_SUCCESSFULLY: ForwardMsg._ScriptFinishedStatus.ValueType # 3
66
+ """A fragment of the script ran successfully."""
64
67
 
65
68
  class ScriptFinishedStatus(_ScriptFinishedStatus, metaclass=_ScriptFinishedStatusEnumTypeWrapper):
66
69
  """Values for the 'script_finished` type"""
@@ -71,6 +74,8 @@ class ForwardMsg(google.protobuf.message.Message):
71
74
  """The script failed to compile"""
72
75
  FINISHED_EARLY_FOR_RERUN: ForwardMsg.ScriptFinishedStatus.ValueType # 2
73
76
  """Script was interrupted by rerun"""
77
+ FINISHED_FRAGMENT_RUN_SUCCESSFULLY: ForwardMsg.ScriptFinishedStatus.ValueType # 3
78
+ """A fragment of the script ran successfully."""
74
79
 
75
80
  HASH_FIELD_NUMBER: builtins.int
76
81
  METADATA_FIELD_NUMBER: builtins.int
@@ -86,6 +91,7 @@ class ForwardMsg(google.protobuf.message.Message):
86
91
  PAGE_NOT_FOUND_FIELD_NUMBER: builtins.int
87
92
  PAGES_CHANGED_FIELD_NUMBER: builtins.int
88
93
  FILE_URLS_RESPONSE_FIELD_NUMBER: builtins.int
94
+ AUTO_RERUN_FIELD_NUMBER: builtins.int
89
95
  PARENT_MESSAGE_FIELD_NUMBER: builtins.int
90
96
  REF_HASH_FIELD_NUMBER: builtins.int
91
97
  DEBUG_LAST_BACKMSG_ID_FIELD_NUMBER: builtins.int
@@ -123,6 +129,8 @@ class ForwardMsg(google.protobuf.message.Message):
123
129
  @property
124
130
  def file_urls_response(self) -> streamlit.proto.Common_pb2.FileURLsResponse: ...
125
131
  @property
132
+ def auto_rerun(self) -> streamlit.proto.AutoRerun_pb2.AutoRerun: ...
133
+ @property
126
134
  def parent_message(self) -> streamlit.proto.ParentMessage_pb2.ParentMessage:
127
135
  """Platform - message to host"""
128
136
  ref_hash: builtins.str
@@ -153,13 +161,14 @@ class ForwardMsg(google.protobuf.message.Message):
153
161
  page_not_found: streamlit.proto.PageNotFound_pb2.PageNotFound | None = ...,
154
162
  pages_changed: streamlit.proto.PagesChanged_pb2.PagesChanged | None = ...,
155
163
  file_urls_response: streamlit.proto.Common_pb2.FileURLsResponse | None = ...,
164
+ auto_rerun: streamlit.proto.AutoRerun_pb2.AutoRerun | None = ...,
156
165
  parent_message: streamlit.proto.ParentMessage_pb2.ParentMessage | None = ...,
157
166
  ref_hash: builtins.str = ...,
158
167
  debug_last_backmsg_id: builtins.str = ...,
159
168
  ) -> None: ...
160
- def HasField(self, field_name: typing_extensions.Literal["delta", b"delta", "file_urls_response", b"file_urls_response", "git_info_changed", b"git_info_changed", "metadata", b"metadata", "new_session", b"new_session", "page_config_changed", b"page_config_changed", "page_info_changed", b"page_info_changed", "page_not_found", b"page_not_found", "page_profile", b"page_profile", "pages_changed", b"pages_changed", "parent_message", b"parent_message", "ref_hash", b"ref_hash", "script_finished", b"script_finished", "session_event", b"session_event", "session_status_changed", b"session_status_changed", "type", b"type"]) -> builtins.bool: ...
161
- def ClearField(self, field_name: typing_extensions.Literal["debug_last_backmsg_id", b"debug_last_backmsg_id", "delta", b"delta", "file_urls_response", b"file_urls_response", "git_info_changed", b"git_info_changed", "hash", b"hash", "metadata", b"metadata", "new_session", b"new_session", "page_config_changed", b"page_config_changed", "page_info_changed", b"page_info_changed", "page_not_found", b"page_not_found", "page_profile", b"page_profile", "pages_changed", b"pages_changed", "parent_message", b"parent_message", "ref_hash", b"ref_hash", "script_finished", b"script_finished", "session_event", b"session_event", "session_status_changed", b"session_status_changed", "type", b"type"]) -> None: ...
162
- def WhichOneof(self, oneof_group: typing_extensions.Literal["type", b"type"]) -> typing_extensions.Literal["new_session", "delta", "page_info_changed", "page_config_changed", "script_finished", "git_info_changed", "page_profile", "session_status_changed", "session_event", "page_not_found", "pages_changed", "file_urls_response", "parent_message", "ref_hash"] | None: ...
169
+ def HasField(self, field_name: typing_extensions.Literal["auto_rerun", b"auto_rerun", "delta", b"delta", "file_urls_response", b"file_urls_response", "git_info_changed", b"git_info_changed", "metadata", b"metadata", "new_session", b"new_session", "page_config_changed", b"page_config_changed", "page_info_changed", b"page_info_changed", "page_not_found", b"page_not_found", "page_profile", b"page_profile", "pages_changed", b"pages_changed", "parent_message", b"parent_message", "ref_hash", b"ref_hash", "script_finished", b"script_finished", "session_event", b"session_event", "session_status_changed", b"session_status_changed", "type", b"type"]) -> builtins.bool: ...
170
+ def ClearField(self, field_name: typing_extensions.Literal["auto_rerun", b"auto_rerun", "debug_last_backmsg_id", b"debug_last_backmsg_id", "delta", b"delta", "file_urls_response", b"file_urls_response", "git_info_changed", b"git_info_changed", "hash", b"hash", "metadata", b"metadata", "new_session", b"new_session", "page_config_changed", b"page_config_changed", "page_info_changed", b"page_info_changed", "page_not_found", b"page_not_found", "page_profile", b"page_profile", "pages_changed", b"pages_changed", "parent_message", b"parent_message", "ref_hash", b"ref_hash", "script_finished", b"script_finished", "session_event", b"session_event", "session_status_changed", b"session_status_changed", "type", b"type"]) -> None: ...
171
+ def WhichOneof(self, oneof_group: typing_extensions.Literal["type", b"type"]) -> typing_extensions.Literal["new_session", "delta", "page_info_changed", "page_config_changed", "script_finished", "git_info_changed", "page_profile", "session_status_changed", "session_event", "page_not_found", "pages_changed", "file_urls_response", "auto_rerun", "parent_message", "ref_hash"] | None: ...
163
172
 
164
173
  global___ForwardMsg = ForwardMsg
165
174
 
@@ -15,7 +15,7 @@ from streamlit.proto import AppPage_pb2 as streamlit_dot_proto_dot_AppPage__pb2
15
15
  from streamlit.proto import SessionStatus_pb2 as streamlit_dot_proto_dot_SessionStatus__pb2
16
16
 
17
17
 
18
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n streamlit/proto/NewSession.proto\x1a\x1dstreamlit/proto/AppPage.proto\x1a#streamlit/proto/SessionStatus.proto\"\xec\x01\n\nNewSession\x12\x1f\n\ninitialize\x18\x01 \x01(\x0b\x32\x0b.Initialize\x12\x15\n\rscript_run_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x18\n\x10main_script_path\x18\x04 \x01(\t\x12\x17\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x07.Config\x12(\n\x0c\x63ustom_theme\x18\x07 \x01(\x0b\x32\x12.CustomThemeConfig\x12\x1b\n\tapp_pages\x18\x08 \x03(\x0b\x32\x08.AppPage\x12\x18\n\x10page_script_hash\x18\t \x01(\tJ\x04\x08\x05\x10\x06\"\xba\x01\n\nInitialize\x12\x1c\n\tuser_info\x18\x01 \x01(\x0b\x32\t.UserInfo\x12*\n\x10\x65nvironment_info\x18\x03 \x01(\x0b\x32\x10.EnvironmentInfo\x12&\n\x0esession_status\x18\x04 \x01(\x0b\x32\x0e.SessionStatus\x12\x14\n\x0c\x63ommand_line\x18\x05 \x01(\t\x12\x12\n\nsession_id\x18\x06 \x01(\t\x12\x10\n\x08is_hello\x18\x07 \x01(\x08\"\x97\x02\n\x06\x43onfig\x12\x1a\n\x12gather_usage_stats\x18\x02 \x01(\x08\x12\x1e\n\x16max_cached_message_age\x18\x03 \x01(\x05\x12\x14\n\x0cmapbox_token\x18\x04 \x01(\t\x12\x19\n\x11\x61llow_run_on_save\x18\x05 \x01(\x08\x12\x14\n\x0chide_top_bar\x18\x06 \x01(\x08\x12\x18\n\x10hide_sidebar_nav\x18\x07 \x01(\x08\x12)\n\x0ctoolbar_mode\x18\x08 \x01(\x0e\x32\x13.Config.ToolbarMode\"?\n\x0bToolbarMode\x12\x08\n\x04\x41UTO\x10\x00\x12\r\n\tDEVELOPER\x10\x01\x12\n\n\x06VIEWER\x10\x02\x12\x0b\n\x07MINIMAL\x10\x03J\x04\x08\x01\x10\x02\"\x8c\x04\n\x11\x43ustomThemeConfig\x12\x15\n\rprimary_color\x18\x01 \x01(\t\x12\"\n\x1asecondary_background_color\x18\x02 \x01(\t\x12\x18\n\x10\x62\x61\x63kground_color\x18\x03 \x01(\t\x12\x12\n\ntext_color\x18\x04 \x01(\t\x12+\n\x04\x66ont\x18\x05 \x01(\x0e\x32\x1d.CustomThemeConfig.FontFamily\x12*\n\x04\x62\x61se\x18\x06 \x01(\x0e\x32\x1c.CustomThemeConfig.BaseTheme\x12\x1f\n\x17widget_background_color\x18\x07 \x01(\t\x12\x1b\n\x13widget_border_color\x18\x08 \x01(\t\x12\x15\n\x05radii\x18\t \x01(\x0b\x32\x06.Radii\x12\x11\n\tbody_font\x18\r \x01(\t\x12\x11\n\tcode_font\x18\x0e \x01(\t\x12\x1d\n\nfont_faces\x18\x0f \x03(\x0b\x32\t.FontFace\x12\x1e\n\nfont_sizes\x18\x10 \x01(\x0b\x32\n.FontSizes\x12!\n\x19skeleton_background_color\x18\x11 \x01(\t\" \n\tBaseTheme\x12\t\n\x05LIGHT\x10\x00\x12\x08\n\x04\x44\x41RK\x10\x01\"6\n\nFontFamily\x12\x0e\n\nSANS_SERIF\x10\x00\x12\t\n\x05SERIF\x10\x01\x12\r\n\tMONOSPACE\x10\x02\"F\n\x08\x46ontFace\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x0e\n\x06\x66\x61mily\x18\x02 \x01(\t\x12\x0e\n\x06weight\x18\x03 \x01(\x05\x12\r\n\x05style\x18\x04 \x01(\t\"<\n\x05Radii\x12\x1a\n\x12\x62\x61se_widget_radius\x18\x01 \x01(\x05\x12\x17\n\x0f\x63heckbox_radius\x18\x02 \x01(\x05\"T\n\tFontSizes\x12\x16\n\x0etiny_font_size\x18\x01 \x01(\x05\x12\x17\n\x0fsmall_font_size\x18\x02 \x01(\x05\x12\x16\n\x0e\x62\x61se_font_size\x18\x03 \x01(\x05\"E\n\x08UserInfo\x12\x17\n\x0finstallation_id\x18\x01 \x01(\t\x12\x1a\n\x12installation_id_v3\x18\x05 \x01(\tJ\x04\x08\x02\x10\x03\"D\n\x0f\x45nvironmentInfo\x12\x19\n\x11streamlit_version\x18\x01 \x01(\t\x12\x16\n\x0epython_version\x18\x02 \x01(\tB/\n\x1c\x63om.snowflake.apps.streamlitB\x0fNewSessionProtob\x06proto3')
18
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n streamlit/proto/NewSession.proto\x1a\x1dstreamlit/proto/AppPage.proto\x1a#streamlit/proto/SessionStatus.proto\"\x8b\x02\n\nNewSession\x12\x1f\n\ninitialize\x18\x01 \x01(\x0b\x32\x0b.Initialize\x12\x15\n\rscript_run_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x18\n\x10main_script_path\x18\x04 \x01(\t\x12\x17\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x07.Config\x12(\n\x0c\x63ustom_theme\x18\x07 \x01(\x0b\x32\x12.CustomThemeConfig\x12\x1b\n\tapp_pages\x18\x08 \x03(\x0b\x32\x08.AppPage\x12\x18\n\x10page_script_hash\x18\t \x01(\t\x12\x1d\n\x15\x66ragment_ids_this_run\x18\n \x03(\tJ\x04\x08\x05\x10\x06\"\xba\x01\n\nInitialize\x12\x1c\n\tuser_info\x18\x01 \x01(\x0b\x32\t.UserInfo\x12*\n\x10\x65nvironment_info\x18\x03 \x01(\x0b\x32\x10.EnvironmentInfo\x12&\n\x0esession_status\x18\x04 \x01(\x0b\x32\x0e.SessionStatus\x12\x14\n\x0c\x63ommand_line\x18\x05 \x01(\t\x12\x12\n\nsession_id\x18\x06 \x01(\t\x12\x10\n\x08is_hello\x18\x07 \x01(\x08\"\x97\x02\n\x06\x43onfig\x12\x1a\n\x12gather_usage_stats\x18\x02 \x01(\x08\x12\x1e\n\x16max_cached_message_age\x18\x03 \x01(\x05\x12\x14\n\x0cmapbox_token\x18\x04 \x01(\t\x12\x19\n\x11\x61llow_run_on_save\x18\x05 \x01(\x08\x12\x14\n\x0chide_top_bar\x18\x06 \x01(\x08\x12\x18\n\x10hide_sidebar_nav\x18\x07 \x01(\x08\x12)\n\x0ctoolbar_mode\x18\x08 \x01(\x0e\x32\x13.Config.ToolbarMode\"?\n\x0bToolbarMode\x12\x08\n\x04\x41UTO\x10\x00\x12\r\n\tDEVELOPER\x10\x01\x12\n\n\x06VIEWER\x10\x02\x12\x0b\n\x07MINIMAL\x10\x03J\x04\x08\x01\x10\x02\"\x8c\x04\n\x11\x43ustomThemeConfig\x12\x15\n\rprimary_color\x18\x01 \x01(\t\x12\"\n\x1asecondary_background_color\x18\x02 \x01(\t\x12\x18\n\x10\x62\x61\x63kground_color\x18\x03 \x01(\t\x12\x12\n\ntext_color\x18\x04 \x01(\t\x12+\n\x04\x66ont\x18\x05 \x01(\x0e\x32\x1d.CustomThemeConfig.FontFamily\x12*\n\x04\x62\x61se\x18\x06 \x01(\x0e\x32\x1c.CustomThemeConfig.BaseTheme\x12\x1f\n\x17widget_background_color\x18\x07 \x01(\t\x12\x1b\n\x13widget_border_color\x18\x08 \x01(\t\x12\x15\n\x05radii\x18\t \x01(\x0b\x32\x06.Radii\x12\x11\n\tbody_font\x18\r \x01(\t\x12\x11\n\tcode_font\x18\x0e \x01(\t\x12\x1d\n\nfont_faces\x18\x0f \x03(\x0b\x32\t.FontFace\x12\x1e\n\nfont_sizes\x18\x10 \x01(\x0b\x32\n.FontSizes\x12!\n\x19skeleton_background_color\x18\x11 \x01(\t\" \n\tBaseTheme\x12\t\n\x05LIGHT\x10\x00\x12\x08\n\x04\x44\x41RK\x10\x01\"6\n\nFontFamily\x12\x0e\n\nSANS_SERIF\x10\x00\x12\t\n\x05SERIF\x10\x01\x12\r\n\tMONOSPACE\x10\x02\"F\n\x08\x46ontFace\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x0e\n\x06\x66\x61mily\x18\x02 \x01(\t\x12\x0e\n\x06weight\x18\x03 \x01(\x05\x12\r\n\x05style\x18\x04 \x01(\t\"<\n\x05Radii\x12\x1a\n\x12\x62\x61se_widget_radius\x18\x01 \x01(\x05\x12\x17\n\x0f\x63heckbox_radius\x18\x02 \x01(\x05\"T\n\tFontSizes\x12\x16\n\x0etiny_font_size\x18\x01 \x01(\x05\x12\x17\n\x0fsmall_font_size\x18\x02 \x01(\x05\x12\x16\n\x0e\x62\x61se_font_size\x18\x03 \x01(\x05\"E\n\x08UserInfo\x12\x17\n\x0finstallation_id\x18\x01 \x01(\t\x12\x1a\n\x12installation_id_v3\x18\x05 \x01(\tJ\x04\x08\x02\x10\x03\"D\n\x0f\x45nvironmentInfo\x12\x19\n\x11streamlit_version\x18\x01 \x01(\t\x12\x16\n\x0epython_version\x18\x02 \x01(\tB/\n\x1c\x63om.snowflake.apps.streamlitB\x0fNewSessionProtob\x06proto3')
19
19
 
20
20
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
21
21
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.NewSession_pb2', globals())
@@ -24,27 +24,27 @@ if _descriptor._USE_C_DESCRIPTORS == False:
24
24
  DESCRIPTOR._options = None
25
25
  DESCRIPTOR._serialized_options = b'\n\034com.snowflake.apps.streamlitB\017NewSessionProto'
26
26
  _NEWSESSION._serialized_start=105
27
- _NEWSESSION._serialized_end=341
28
- _INITIALIZE._serialized_start=344
29
- _INITIALIZE._serialized_end=530
30
- _CONFIG._serialized_start=533
31
- _CONFIG._serialized_end=812
32
- _CONFIG_TOOLBARMODE._serialized_start=743
33
- _CONFIG_TOOLBARMODE._serialized_end=806
34
- _CUSTOMTHEMECONFIG._serialized_start=815
35
- _CUSTOMTHEMECONFIG._serialized_end=1339
36
- _CUSTOMTHEMECONFIG_BASETHEME._serialized_start=1251
37
- _CUSTOMTHEMECONFIG_BASETHEME._serialized_end=1283
38
- _CUSTOMTHEMECONFIG_FONTFAMILY._serialized_start=1285
39
- _CUSTOMTHEMECONFIG_FONTFAMILY._serialized_end=1339
40
- _FONTFACE._serialized_start=1341
41
- _FONTFACE._serialized_end=1411
42
- _RADII._serialized_start=1413
43
- _RADII._serialized_end=1473
44
- _FONTSIZES._serialized_start=1475
45
- _FONTSIZES._serialized_end=1559
46
- _USERINFO._serialized_start=1561
47
- _USERINFO._serialized_end=1630
48
- _ENVIRONMENTINFO._serialized_start=1632
49
- _ENVIRONMENTINFO._serialized_end=1700
27
+ _NEWSESSION._serialized_end=372
28
+ _INITIALIZE._serialized_start=375
29
+ _INITIALIZE._serialized_end=561
30
+ _CONFIG._serialized_start=564
31
+ _CONFIG._serialized_end=843
32
+ _CONFIG_TOOLBARMODE._serialized_start=774
33
+ _CONFIG_TOOLBARMODE._serialized_end=837
34
+ _CUSTOMTHEMECONFIG._serialized_start=846
35
+ _CUSTOMTHEMECONFIG._serialized_end=1370
36
+ _CUSTOMTHEMECONFIG_BASETHEME._serialized_start=1282
37
+ _CUSTOMTHEMECONFIG_BASETHEME._serialized_end=1314
38
+ _CUSTOMTHEMECONFIG_FONTFAMILY._serialized_start=1316
39
+ _CUSTOMTHEMECONFIG_FONTFAMILY._serialized_end=1370
40
+ _FONTFACE._serialized_start=1372
41
+ _FONTFACE._serialized_end=1442
42
+ _RADII._serialized_start=1444
43
+ _RADII._serialized_end=1504
44
+ _FONTSIZES._serialized_start=1506
45
+ _FONTSIZES._serialized_end=1590
46
+ _USERINFO._serialized_start=1592
47
+ _USERINFO._serialized_end=1661
48
+ _ENVIRONMENTINFO._serialized_start=1663
49
+ _ENVIRONMENTINFO._serialized_end=1731
50
50
  # @@protoc_insertion_point(module_scope)
@@ -52,6 +52,7 @@ class NewSession(google.protobuf.message.Message):
52
52
  CUSTOM_THEME_FIELD_NUMBER: builtins.int
53
53
  APP_PAGES_FIELD_NUMBER: builtins.int
54
54
  PAGE_SCRIPT_HASH_FIELD_NUMBER: builtins.int
55
+ FRAGMENT_IDS_THIS_RUN_FIELD_NUMBER: builtins.int
55
56
  @property
56
57
  def initialize(self) -> global___Initialize:
57
58
  """Initialization data. This data does *not* change from rerun to rerun,
@@ -82,6 +83,11 @@ class NewSession(google.protobuf.message.Message):
82
83
  """A list of all of this app's pages, in order and including the main page."""
83
84
  page_script_hash: builtins.str
84
85
  """A hash of the script corresponding to the page currently being viewed."""
86
+ @property
87
+ def fragment_ids_this_run(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]:
88
+ """The fragment IDs being run in this session if it corresponds to a fragment
89
+ script run.
90
+ """
85
91
  def __init__(
86
92
  self,
87
93
  *,
@@ -93,9 +99,10 @@ class NewSession(google.protobuf.message.Message):
93
99
  custom_theme: global___CustomThemeConfig | None = ...,
94
100
  app_pages: collections.abc.Iterable[streamlit.proto.AppPage_pb2.AppPage] | None = ...,
95
101
  page_script_hash: builtins.str = ...,
102
+ fragment_ids_this_run: collections.abc.Iterable[builtins.str] | None = ...,
96
103
  ) -> None: ...
97
104
  def HasField(self, field_name: typing_extensions.Literal["config", b"config", "custom_theme", b"custom_theme", "initialize", b"initialize"]) -> builtins.bool: ...
98
- def ClearField(self, field_name: typing_extensions.Literal["app_pages", b"app_pages", "config", b"config", "custom_theme", b"custom_theme", "initialize", b"initialize", "main_script_path", b"main_script_path", "name", b"name", "page_script_hash", b"page_script_hash", "script_run_id", b"script_run_id"]) -> None: ...
105
+ def ClearField(self, field_name: typing_extensions.Literal["app_pages", b"app_pages", "config", b"config", "custom_theme", b"custom_theme", "fragment_ids_this_run", b"fragment_ids_this_run", "initialize", b"initialize", "main_script_path", b"main_script_path", "name", b"name", "page_script_hash", b"page_script_hash", "script_run_id", b"script_run_id"]) -> None: ...
99
106
 
100
107
  global___NewSession = NewSession
101
108
 
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
13
13
 
14
14
 
15
15
 
16
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!streamlit/proto/PageProfile.proto\"\xc1\x01\n\x0bPageProfile\x12\x1a\n\x08\x63ommands\x18\x01 \x03(\x0b\x32\x08.Command\x12\x11\n\texec_time\x18\x02 \x01(\x03\x12\x11\n\tprep_time\x18\x03 \x01(\x03\x12\x0e\n\x06\x63onfig\x18\x05 \x03(\t\x12\x1a\n\x12uncaught_exception\x18\x06 \x01(\t\x12\x14\n\x0c\x61ttributions\x18\x07 \x03(\t\x12\n\n\x02os\x18\x08 \x01(\t\x12\x10\n\x08timezone\x18\t \x01(\t\x12\x10\n\x08headless\x18\n \x01(\x08\"6\n\x08\x41rgument\x12\t\n\x01k\x18\x01 \x01(\t\x12\t\n\x01t\x18\x02 \x01(\t\x12\t\n\x01m\x18\x03 \x01(\t\x12\t\n\x01p\x18\x05 \x01(\x05\">\n\x07\x43ommand\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\x04\x61rgs\x18\x02 \x03(\x0b\x32\t.Argument\x12\x0c\n\x04time\x18\x04 \x01(\x03\x42\x30\n\x1c\x63om.snowflake.apps.streamlitB\x10PageProfileProtob\x06proto3')
16
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!streamlit/proto/PageProfile.proto\"\xda\x01\n\x0bPageProfile\x12\x1a\n\x08\x63ommands\x18\x01 \x03(\x0b\x32\x08.Command\x12\x11\n\texec_time\x18\x02 \x01(\x03\x12\x11\n\tprep_time\x18\x03 \x01(\x03\x12\x0e\n\x06\x63onfig\x18\x05 \x03(\t\x12\x1a\n\x12uncaught_exception\x18\x06 \x01(\t\x12\x14\n\x0c\x61ttributions\x18\x07 \x03(\t\x12\n\n\x02os\x18\x08 \x01(\t\x12\x10\n\x08timezone\x18\t \x01(\t\x12\x10\n\x08headless\x18\n \x01(\x08\x12\x17\n\x0fis_fragment_run\x18\x0b \x01(\x08\"6\n\x08\x41rgument\x12\t\n\x01k\x18\x01 \x01(\t\x12\t\n\x01t\x18\x02 \x01(\t\x12\t\n\x01m\x18\x03 \x01(\t\x12\t\n\x01p\x18\x05 \x01(\x05\">\n\x07\x43ommand\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\x04\x61rgs\x18\x02 \x03(\x0b\x32\t.Argument\x12\x0c\n\x04time\x18\x04 \x01(\x03\x42\x30\n\x1c\x63om.snowflake.apps.streamlitB\x10PageProfileProtob\x06proto3')
17
17
 
18
18
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
19
19
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.PageProfile_pb2', globals())
@@ -22,9 +22,9 @@ if _descriptor._USE_C_DESCRIPTORS == False:
22
22
  DESCRIPTOR._options = None
23
23
  DESCRIPTOR._serialized_options = b'\n\034com.snowflake.apps.streamlitB\020PageProfileProto'
24
24
  _PAGEPROFILE._serialized_start=38
25
- _PAGEPROFILE._serialized_end=231
26
- _ARGUMENT._serialized_start=233
27
- _ARGUMENT._serialized_end=287
28
- _COMMAND._serialized_start=289
29
- _COMMAND._serialized_end=351
25
+ _PAGEPROFILE._serialized_end=256
26
+ _ARGUMENT._serialized_start=258
27
+ _ARGUMENT._serialized_end=312
28
+ _COMMAND._serialized_start=314
29
+ _COMMAND._serialized_end=376
30
30
  # @@protoc_insertion_point(module_scope)
@@ -42,6 +42,7 @@ class PageProfile(google.protobuf.message.Message):
42
42
  OS_FIELD_NUMBER: builtins.int
43
43
  TIMEZONE_FIELD_NUMBER: builtins.int
44
44
  HEADLESS_FIELD_NUMBER: builtins.int
45
+ IS_FRAGMENT_RUN_FIELD_NUMBER: builtins.int
45
46
  @property
46
47
  def commands(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Command]: ...
47
48
  exec_time: builtins.int
@@ -54,6 +55,7 @@ class PageProfile(google.protobuf.message.Message):
54
55
  os: builtins.str
55
56
  timezone: builtins.str
56
57
  headless: builtins.bool
58
+ is_fragment_run: builtins.bool
57
59
  def __init__(
58
60
  self,
59
61
  *,
@@ -66,8 +68,9 @@ class PageProfile(google.protobuf.message.Message):
66
68
  os: builtins.str = ...,
67
69
  timezone: builtins.str = ...,
68
70
  headless: builtins.bool = ...,
71
+ is_fragment_run: builtins.bool = ...,
69
72
  ) -> None: ...
70
- def ClearField(self, field_name: typing_extensions.Literal["attributions", b"attributions", "commands", b"commands", "config", b"config", "exec_time", b"exec_time", "headless", b"headless", "os", b"os", "prep_time", b"prep_time", "timezone", b"timezone", "uncaught_exception", b"uncaught_exception"]) -> None: ...
73
+ def ClearField(self, field_name: typing_extensions.Literal["attributions", b"attributions", "commands", b"commands", "config", b"config", "exec_time", b"exec_time", "headless", b"headless", "is_fragment_run", b"is_fragment_run", "os", b"os", "prep_time", b"prep_time", "timezone", b"timezone", "uncaught_exception", b"uncaught_exception"]) -> None: ...
71
74
 
72
75
  global___PageProfile = PageProfile
73
76
 
@@ -38,6 +38,7 @@ from streamlit.proto.NewSession_pb2 import (
38
38
  from streamlit.proto.PagesChanged_pb2 import PagesChanged
39
39
  from streamlit.runtime import caching, legacy_caching
40
40
  from streamlit.runtime.forward_msg_queue import ForwardMsgQueue
41
+ from streamlit.runtime.fragment import FragmentStorage, MemoryFragmentStorage
41
42
  from streamlit.runtime.metrics_util import Installation
42
43
  from streamlit.runtime.script_data import ScriptData
43
44
  from streamlit.runtime.scriptrunner import RerunData, ScriptRunner, ScriptRunnerEvent
@@ -161,6 +162,8 @@ class AppSession:
161
162
 
162
163
  self._debug_last_backmsg_id: str | None = None
163
164
 
165
+ self._fragment_storage: FragmentStorage = MemoryFragmentStorage()
166
+
164
167
  _LOGGER.debug("AppSession initialized (id=%s)", self.id)
165
168
 
166
169
  def __del__(self) -> None:
@@ -353,26 +356,33 @@ class AppSession:
353
356
  return
354
357
 
355
358
  if client_state:
359
+ fragment_id = client_state.fragment_id
360
+
356
361
  rerun_data = RerunData(
357
362
  client_state.query_string,
358
363
  client_state.widget_states,
359
364
  client_state.page_script_hash,
360
365
  client_state.page_name,
366
+ fragment_id_queue=[fragment_id] if fragment_id else [],
361
367
  )
362
368
  else:
363
369
  rerun_data = RerunData()
364
370
 
365
371
  if self._scriptrunner is not None:
366
- if bool(config.get_option("runner.fastReruns")):
367
- # If fastReruns is enabled, we don't send rerun requests to our
368
- # existing ScriptRunner. Instead, we tell it to shut down. We'll
369
- # then spin up a new ScriptRunner, below, to handle the rerun
370
- # immediately.
372
+ if (
373
+ bool(config.get_option("runner.fastReruns"))
374
+ and not rerun_data.fragment_id_queue
375
+ ):
376
+ # If fastReruns is enabled and this is *not* a rerun of a fragment,
377
+ # we don't send rerun requests to our existing ScriptRunner. Instead, we
378
+ # tell it to shut down. We'll then spin up a new ScriptRunner, below, to
379
+ # handle the rerun immediately.
371
380
  self._scriptrunner.request_stop()
372
381
  self._scriptrunner = None
373
382
  else:
374
- # fastReruns is not enabled. Send our ScriptRunner a rerun
375
- # request. If the request is accepted, we're done.
383
+ # Either fastReruns is not enabled or this RERUN request is a request to
384
+ # run a fragment. We send our current ScriptRunner a rerun request, and
385
+ # if it's accepted, we're done.
376
386
  success = self._scriptrunner.request_rerun(rerun_data)
377
387
  if success:
378
388
  return
@@ -400,6 +410,7 @@ class AppSession:
400
410
  script_cache=self._script_cache,
401
411
  initial_rerun_data=initial_rerun_data,
402
412
  user_info=self._user_info,
413
+ fragment_storage=self._fragment_storage,
403
414
  )
404
415
  self._scriptrunner.on_event.connect(self._on_scriptrunner_event)
405
416
  self._scriptrunner.start()
@@ -464,6 +475,7 @@ class AppSession:
464
475
  exception: BaseException | None = None,
465
476
  client_state: ClientState | None = None,
466
477
  page_script_hash: str | None = None,
478
+ fragment_ids_this_run: set[str] | None = None,
467
479
  ) -> None:
468
480
  """Called when our ScriptRunner emits an event.
469
481
 
@@ -473,7 +485,13 @@ class AppSession:
473
485
  """
474
486
  self._event_loop.call_soon_threadsafe(
475
487
  lambda: self._handle_scriptrunner_event_on_event_loop(
476
- sender, event, forward_msg, exception, client_state, page_script_hash
488
+ sender,
489
+ event,
490
+ forward_msg,
491
+ exception,
492
+ client_state,
493
+ page_script_hash,
494
+ fragment_ids_this_run,
477
495
  )
478
496
  )
479
497
 
@@ -485,6 +503,7 @@ class AppSession:
485
503
  exception: BaseException | None = None,
486
504
  client_state: ClientState | None = None,
487
505
  page_script_hash: str | None = None,
506
+ fragment_ids_this_run: set[str] | None = None,
488
507
  ) -> None:
489
508
  """Handle a ScriptRunner event.
490
509
 
@@ -515,6 +534,11 @@ class AppSession:
515
534
  page_script_hash : str | None
516
535
  A hash of the script path corresponding to the page currently being
517
536
  run. Set only for the SCRIPT_STARTED event.
537
+
538
+ fragment_ids_this_run : set[str] | None
539
+ The fragment IDs of the fragments being executed in this script run. Only
540
+ set for the SCRIPT_STARTED event. If this value is falsy, this script run
541
+ must be for the full script.
518
542
  """
519
543
 
520
544
  assert (
@@ -540,30 +564,43 @@ class AppSession:
540
564
  page_script_hash is not None
541
565
  ), "page_script_hash must be set for the SCRIPT_STARTED event"
542
566
 
543
- self._clear_queue()
567
+ # When running the full script, we clear the browser ForwardMsg queue since
568
+ # anything from a previous script run that has yet to be sent to the browser
569
+ # will be overwritten. For fragment runs, however, we don't want to do this
570
+ # as the ForwardMsgs in the queue may not correspond to the running
571
+ # fragment, so dropping the messages may result in the app missing
572
+ # information.
573
+ if not fragment_ids_this_run:
574
+ self._clear_queue()
575
+
544
576
  self._enqueue_forward_msg(
545
- self._create_new_session_message(page_script_hash)
577
+ self._create_new_session_message(
578
+ page_script_hash, fragment_ids_this_run
579
+ )
546
580
  )
547
581
 
548
582
  elif (
549
583
  event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS
550
584
  or event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_COMPILE_ERROR
585
+ or event == ScriptRunnerEvent.FRAGMENT_STOPPED_WITH_SUCCESS
551
586
  ):
552
587
  if self._state != AppSessionState.SHUTDOWN_REQUESTED:
553
588
  self._state = AppSessionState.APP_NOT_RUNNING
554
589
 
555
- script_succeeded = event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS
556
-
557
- script_finished_msg = self._create_script_finished_message(
558
- ForwardMsg.FINISHED_SUCCESSFULLY
559
- if script_succeeded
560
- else ForwardMsg.FINISHED_WITH_COMPILE_ERROR
561
- )
562
- self._enqueue_forward_msg(script_finished_msg)
590
+ if event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS:
591
+ status = ForwardMsg.FINISHED_SUCCESSFULLY
592
+ elif event == ScriptRunnerEvent.FRAGMENT_STOPPED_WITH_SUCCESS:
593
+ status = ForwardMsg.FINISHED_FRAGMENT_RUN_SUCCESSFULLY
594
+ else:
595
+ status = ForwardMsg.FINISHED_WITH_COMPILE_ERROR
563
596
 
597
+ self._enqueue_forward_msg(self._create_script_finished_message(status))
564
598
  self._debug_last_backmsg_id = None
565
599
 
566
- if script_succeeded:
600
+ if (
601
+ event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS
602
+ or event == ScriptRunnerEvent.FRAGMENT_STOPPED_WITH_SUCCESS
603
+ ):
567
604
  # The script completed successfully: update our
568
605
  # LocalSourcesWatcher to account for any source code changes
569
606
  # that change which modules should be watched.
@@ -582,11 +619,12 @@ class AppSession:
582
619
  self._enqueue_forward_msg(msg)
583
620
 
584
621
  elif event == ScriptRunnerEvent.SCRIPT_STOPPED_FOR_RERUN:
585
- script_finished_msg = self._create_script_finished_message(
586
- ForwardMsg.FINISHED_EARLY_FOR_RERUN
587
- )
588
622
  self._state = AppSessionState.APP_NOT_RUNNING
589
- self._enqueue_forward_msg(script_finished_msg)
623
+ self._enqueue_forward_msg(
624
+ self._create_script_finished_message(
625
+ ForwardMsg.FINISHED_EARLY_FOR_RERUN
626
+ )
627
+ )
590
628
  if self._local_sources_watcher:
591
629
  self._local_sources_watcher.update_watched_modules()
592
630
 
@@ -630,7 +668,9 @@ class AppSession:
630
668
  msg.session_event.script_changed_on_disk = True
631
669
  return msg
632
670
 
633
- def _create_new_session_message(self, page_script_hash: str) -> ForwardMsg:
671
+ def _create_new_session_message(
672
+ self, page_script_hash: str, fragment_ids_this_run: set[str] | None = None
673
+ ) -> ForwardMsg:
634
674
  """Create and return a new_session ForwardMsg."""
635
675
  msg = ForwardMsg()
636
676
 
@@ -639,6 +679,9 @@ class AppSession:
639
679
  msg.new_session.main_script_path = self._script_data.main_script_path
640
680
  msg.new_session.page_script_hash = page_script_hash
641
681
 
682
+ if fragment_ids_this_run:
683
+ msg.new_session.fragment_ids_this_run.extend(fragment_ids_this_run)
684
+
642
685
  _populate_app_pages(msg.new_session, self._script_data.main_script_path)
643
686
  _populate_config_msg(msg.new_session.config)
644
687
  _populate_theme_msg(msg.new_session.custom_theme)
@@ -35,7 +35,6 @@ from streamlit.runtime.caching.cache_utils import (
35
35
  Cache,
36
36
  CachedFuncInfo,
37
37
  make_cached_func_wrapper,
38
- ttl_to_seconds,
39
38
  )
40
39
  from streamlit.runtime.caching.cached_message_replay import (
41
40
  CachedMessageReplayContext,
@@ -61,6 +60,7 @@ from streamlit.runtime.caching.storage.dummy_cache_storage import (
61
60
  from streamlit.runtime.metrics_util import gather_metrics
62
61
  from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx
63
62
  from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
63
+ from streamlit.time_util import time_to_seconds
64
64
 
65
65
  _LOGGER: Final = get_logger(__name__)
66
66
 
@@ -154,7 +154,7 @@ class DataCaches(CacheStatsProvider):
154
154
  If it doesn't exist, create a new one with the given params.
155
155
  """
156
156
 
157
- ttl_seconds = ttl_to_seconds(ttl, coerce_none_to_inf=False)
157
+ ttl_seconds = time_to_seconds(ttl, coerce_none_to_inf=False)
158
158
 
159
159
  # Get the existing cache, if it exists, and validate that its params
160
160
  # haven't changed.
@@ -254,7 +254,7 @@ class DataCaches(CacheStatsProvider):
254
254
  CacheStorageContext.
255
255
  """
256
256
 
257
- ttl_seconds = ttl_to_seconds(ttl, coerce_none_to_inf=False)
257
+ ttl_seconds = time_to_seconds(ttl, coerce_none_to_inf=False)
258
258
 
259
259
  cache_context = self.create_cache_storage_context(
260
260
  function_key="DUMMY_KEY",
@@ -176,14 +176,3 @@ class UnevaluatedDataFrameError(StreamlitAPIException):
176
176
  """Used to display a message about uncollected dataframe being used"""
177
177
 
178
178
  pass
179
-
180
-
181
- class BadTTLStringError(StreamlitAPIException):
182
- """Raised when a bad ttl= argument string is passed."""
183
-
184
- def __init__(self, ttl: str):
185
- MarkdownFormattedException.__init__(
186
- self,
187
- "TTL string doesn't look right. It should be formatted as"
188
- f"`'1d2h34m'` or `2 days`, for example. Got: {ttl}",
189
- )
@@ -35,7 +35,6 @@ from streamlit.runtime.caching.cache_utils import (
35
35
  Cache,
36
36
  CachedFuncInfo,
37
37
  make_cached_func_wrapper,
38
- ttl_to_seconds,
39
38
  )
40
39
  from streamlit.runtime.caching.cached_message_replay import (
41
40
  CachedMessageReplayContext,
@@ -48,6 +47,7 @@ from streamlit.runtime.caching.hashing import HashFuncsDict
48
47
  from streamlit.runtime.metrics_util import gather_metrics
49
48
  from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx
50
49
  from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
50
+ from streamlit.time_util import time_to_seconds
51
51
 
52
52
  _LOGGER: Final = get_logger(__name__)
53
53
 
@@ -89,7 +89,7 @@ class ResourceCaches(CacheStatsProvider):
89
89
  if max_entries is None:
90
90
  max_entries = math.inf
91
91
 
92
- ttl_seconds = ttl_to_seconds(ttl)
92
+ ttl_seconds = time_to_seconds(ttl)
93
93
 
94
94
  # Get the existing cache, if it exists, and validate that its params
95
95
  # haven't changed.
@@ -19,20 +19,17 @@ from __future__ import annotations
19
19
  import functools
20
20
  import hashlib
21
21
  import inspect
22
- import math
23
22
  import threading
24
23
  import time
25
24
  import types
26
25
  from abc import abstractmethod
27
26
  from collections import defaultdict
28
- from datetime import timedelta
29
- from typing import Any, Callable, Final, Literal, overload
27
+ from typing import Any, Callable, Final
30
28
 
31
29
  from streamlit import type_util
32
30
  from streamlit.elements.spinner import spinner
33
31
  from streamlit.logger import get_logger
34
32
  from streamlit.runtime.caching.cache_errors import (
35
- BadTTLStringError,
36
33
  CacheError,
37
34
  CacheKeyNotFoundError,
38
35
  UnevaluatedDataFrameError,
@@ -58,45 +55,6 @@ _LOGGER: Final = get_logger(__name__)
58
55
  TTLCACHE_TIMER = time.monotonic
59
56
 
60
57
 
61
- @overload
62
- def ttl_to_seconds(
63
- ttl: float | timedelta | str | None, *, coerce_none_to_inf: Literal[False]
64
- ) -> float | None:
65
- ...
66
-
67
-
68
- @overload
69
- def ttl_to_seconds(ttl: float | timedelta | str | None) -> float:
70
- ...
71
-
72
-
73
- def ttl_to_seconds(
74
- ttl: float | timedelta | str | None, *, coerce_none_to_inf: bool = True
75
- ) -> float | None:
76
- """
77
- Convert a ttl value to a float representing "number of seconds".
78
- """
79
- if coerce_none_to_inf and ttl is None:
80
- return math.inf
81
- if isinstance(ttl, timedelta):
82
- return ttl.total_seconds()
83
- if isinstance(ttl, str):
84
- import numpy as np
85
- import pandas as pd
86
-
87
- try:
88
- out: float = pd.Timedelta(ttl).total_seconds()
89
- except ValueError as ex:
90
- raise BadTTLStringError(ttl) from ex
91
-
92
- if np.isnan(out):
93
- raise BadTTLStringError(ttl)
94
-
95
- return out
96
-
97
- return ttl
98
-
99
-
100
58
  # We show a special "UnevaluatedDataFrame" warning for cached funcs
101
59
  # that attempt to return one of these unserializable types:
102
60
  UNEVALUATED_DATAFRAME_TYPES = (