streamlit-nightly 1.35.1.dev20240617__py2.py3-none-any.whl → 1.36.1.dev20240620__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.
@@ -435,7 +435,9 @@ class AppSession:
435
435
  return True
436
436
 
437
437
  def _on_source_file_changed(self, filepath: str | None = None) -> None:
438
- """One of our source files changed. Clear the cache and schedule a rerun if appropriate."""
438
+ """One of our source files changed. Clear the cache and schedule a rerun if
439
+ appropriate.
440
+ """
439
441
  self._script_cache.clear()
440
442
 
441
443
  if filepath is not None and not self._should_rerun_on_file_change(filepath):
@@ -449,11 +451,13 @@ class AppSession:
449
451
  def _on_secrets_file_changed(self, _) -> None:
450
452
  """Called when `secrets.file_change_listener` emits a Signal."""
451
453
 
452
- # NOTE: At the time of writing, this function only calls `_on_source_file_changed`.
453
- # The reason behind creating this function instead of just passing `_on_source_file_changed`
454
- # to `connect` / `disconnect` directly is that every function that is passed to `connect` / `disconnect`
455
- # must have at least one argument for `sender` (in this case we don't really care about it, thus `_`),
456
- # and introducing an unnecessary argument to `_on_source_file_changed` just for this purpose sounded finicky.
454
+ # NOTE: At the time of writing, this function only calls
455
+ # `_on_source_file_changed`. The reason behind creating this function instead of
456
+ # just passing `_on_source_file_changed` to `connect` / `disconnect` directly is
457
+ # that every function that is passed to `connect` / `disconnect` must have at
458
+ # least one argument for `sender` (in this case we don't really care about it,
459
+ # thus `_`), and introducing an unnecessary argument to
460
+ # `_on_source_file_changed` just for this purpose sounded finicky.
457
461
  self._on_source_file_changed()
458
462
 
459
463
  def _on_pages_changed(self, _) -> None:
@@ -62,7 +62,7 @@ def exec_func_with_error_handling(
62
62
  """
63
63
 
64
64
  # Avoid circular imports
65
- from streamlit.delta_generator import dg_stack
65
+ from streamlit.delta_generator import dg_stack, get_default_dg_stack
66
66
 
67
67
  run_without_errors = True
68
68
 
@@ -94,8 +94,18 @@ def exec_func_with_error_handling(
94
94
  raise e
95
95
 
96
96
  rerun_exception_data = e.rerun_data
97
- ctx.cursors = original_cursors
98
- dg_stack.set(original_dg_stack)
97
+ if rerun_exception_data.fragment_id_queue:
98
+ # This is a fragment-specific rerun, so we need to restore the stack
99
+ ctx.cursors = original_cursors
100
+ dg_stack.set(original_dg_stack)
101
+ else:
102
+ # If it is a full-app rerun, the stack needs to be refreshed.
103
+ # We should land here when `st.rerun` is called from within a
104
+ # fragment. Since we re-use the same thread, we have to clear the
105
+ # stack or otherwise we might render the main app in the old
106
+ # fragment's dg_stack.
107
+ ctx.cursors.clear()
108
+ dg_stack.set(get_default_dg_stack())
99
109
  # Interruption due to a rerun is usually from `st.rerun()`, which
100
110
  # we want to count as a script completion so triggers reset.
101
111
  # It is also possible for this to happen if fast reruns is off,
@@ -269,7 +269,8 @@ class ScriptRunner:
269
269
  if ctx is None:
270
270
  # This should never be possible on the script_runner thread.
271
271
  raise RuntimeError(
272
- "ScriptRunner thread has a null ScriptRunContext. Something has gone very wrong!"
272
+ "ScriptRunner thread has a null ScriptRunContext. "
273
+ "Something has gone very wrong!"
273
274
  )
274
275
  return ctx
275
276
 
@@ -570,6 +571,8 @@ class ScriptRunner:
570
571
  exec(code, module.__dict__)
571
572
 
572
573
  self._session_state.maybe_check_serializable()
574
+ # check for control requests, e.g. rerun requests have arrived
575
+ self._maybe_handle_execution_control_request()
573
576
 
574
577
  prep_time = timer() - start_time
575
578
  (
@@ -578,6 +581,8 @@ class ScriptRunner:
578
581
  rerun_exception_data,
579
582
  premature_stop,
580
583
  ) = exec_func_with_error_handling(code_to_exec, ctx)
584
+ # setting the session state here triggers a yield-callback call
585
+ # which reads self._requests and checks for rerun data
581
586
  self._session_state[SCRIPT_RUN_WITHOUT_ERRORS_KEY] = run_without_errors
582
587
 
583
588
  if rerun_exception_data:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.3aaaea00.css",
4
- "main.js": "./static/js/main.7994a814.js",
4
+ "main.js": "./static/js/main.ba32d829.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.3aaaea00.css",
154
- "static/js/main.7994a814.js"
154
+ "static/js/main.ba32d829.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.7994a814.js"></script><link href="./static/css/main.3aaaea00.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.ba32d829.js"></script><link href="./static/css/main.3aaaea00.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>