streamlit-nightly 1.35.1.dev20240605__py2.py3-none-any.whl → 1.35.1.dev20240606__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.
@@ -40,15 +40,16 @@ from typing import TYPE_CHECKING, Any, NamedTuple
40
40
  from langchain.callbacks.base import ( # type: ignore[import-not-found, unused-ignore]
41
41
  BaseCallbackHandler,
42
42
  )
43
- from langchain.schema import ( # type: ignore[import-not-found, unused-ignore]
44
- AgentAction,
45
- AgentFinish,
46
- LLMResult,
47
- )
48
43
 
49
44
  from streamlit.runtime.metrics_util import gather_metrics
50
45
 
51
46
  if TYPE_CHECKING:
47
+ from langchain.schema import ( # type: ignore[import-not-found, unused-ignore]
48
+ AgentAction,
49
+ AgentFinish,
50
+ LLMResult,
51
+ )
52
+
52
53
  from streamlit.delta_generator import DeltaGenerator
53
54
  from streamlit.elements.lib.mutable_status_container import StatusContainer
54
55
 
@@ -377,6 +377,11 @@ def gather_metrics(name: str, func: F | None = None) -> Callable[[F], F] | F:
377
377
  )
378
378
 
379
379
  command_telemetry: Command | None = None
380
+ # This flag is needed to make sure that only the command (the outermost command)
381
+ # that deactivated tracking (via ctx.command_tracking_deactivated) is able to reset it
382
+ # again. This is important to prevent nested commands from reactivating tracking.
383
+ # At this point, we don't know yet if the command will deactivated tracking.
384
+ has_set_command_tracking_deactivated = False
380
385
 
381
386
  if ctx and tracking_activated:
382
387
  try:
@@ -393,6 +398,10 @@ def gather_metrics(name: str, func: F | None = None) -> Callable[[F], F] | F:
393
398
  ctx.tracked_commands_counter.update([command_telemetry.name])
394
399
  # Deactivate tracking to prevent calls inside already tracked commands
395
400
  ctx.command_tracking_deactivated = True
401
+ # The ctx.command_tracking_deactivated flag was set to True,
402
+ # we also need to set has_set_command_tracking_deactivated to True
403
+ # to make sure that this command is able to reset it again.
404
+ has_set_command_tracking_deactivated = True
396
405
  except Exception as ex:
397
406
  # Always capture all exceptions since we want to make sure that
398
407
  # the telemetry never causes any issues.
@@ -407,7 +416,9 @@ def gather_metrics(name: str, func: F | None = None) -> Callable[[F], F] | F:
407
416
  raise ex
408
417
  finally:
409
418
  # Activate tracking again if command executes without any exceptions
410
- if ctx:
419
+ # we only want to do that if this command has set the
420
+ # flag to deactivate tracking.
421
+ if ctx and has_set_command_tracking_deactivated:
411
422
  ctx.command_tracking_deactivated = False
412
423
 
413
424
  if tracking_activated and command_telemetry:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.3aaaea00.css",
4
- "main.js": "./static/js/main.343fe878.js",
4
+ "main.js": "./static/js/main.61618be0.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.343fe878.js"
154
+ "static/js/main.61618be0.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.343fe878.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.61618be0.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>