streamlit-nightly 1.35.1.dev20240610__py2.py3-none-any.whl → 1.35.1.dev20240611__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.
- streamlit/__init__.py +5 -1
- streamlit/case_converters.py +2 -2
- streamlit/cli_util.py +2 -2
- streamlit/color_util.py +2 -2
- streamlit/commands/experimental_query_params.py +6 -8
- streamlit/commands/logo.py +4 -9
- streamlit/commands/navigation.py +6 -4
- streamlit/components/lib/local_component_registry.py +4 -2
- streamlit/components/types/base_component_registry.py +3 -2
- streamlit/components/v1/component_arrow.py +2 -1
- streamlit/components/v1/component_registry.py +6 -2
- streamlit/components/v1/components.py +4 -2
- streamlit/components/v1/custom_component.py +6 -6
- streamlit/config.py +15 -12
- streamlit/connections/snowflake_connection.py +2 -1
- streamlit/connections/snowpark_connection.py +2 -4
- streamlit/connections/sql_connection.py +2 -1
- streamlit/delta_generator.py +3 -4
- streamlit/elements/arrow.py +3 -6
- streamlit/elements/code.py +1 -1
- streamlit/elements/dialog_decorator.py +10 -8
- streamlit/elements/doc_string.py +1 -1
- streamlit/elements/exception.py +1 -1
- streamlit/elements/form.py +1 -1
- streamlit/elements/heading.py +1 -1
- streamlit/elements/html.py +1 -1
- streamlit/elements/image.py +5 -3
- streamlit/elements/layouts.py +7 -7
- streamlit/elements/lib/built_in_chart_utils.py +24 -12
- streamlit/elements/lib/column_config_utils.py +2 -1
- streamlit/elements/lib/dialog.py +8 -5
- streamlit/elements/lib/dicttools.py +3 -3
- streamlit/elements/lib/mutable_status_container.py +8 -5
- streamlit/elements/lib/pandas_styler_utils.py +2 -1
- streamlit/elements/lib/subtitle_utils.py +0 -1
- streamlit/elements/lib/utils.py +8 -10
- streamlit/elements/plotly_chart.py +5 -10
- streamlit/elements/pyplot.py +0 -1
- streamlit/elements/toast.py +2 -2
- streamlit/elements/vega_charts.py +46 -10
- streamlit/elements/widgets/color_picker.py +6 -4
- streamlit/elements/widgets/file_uploader.py +4 -8
- streamlit/elements/widgets/multiselect.py +2 -4
- streamlit/elements/widgets/number_input.py +4 -8
- streamlit/elements/widgets/select_slider.py +1 -1
- streamlit/elements/widgets/slider.py +2 -5
- streamlit/elements/widgets/time_widgets.py +5 -5
- streamlit/errors.py +1 -6
- streamlit/git_util.py +2 -2
- streamlit/hello/Animation_Demo.py +0 -1
- streamlit/logger.py +1 -1
- streamlit/navigation/page.py +6 -1
- streamlit/net_util.py +2 -5
- streamlit/proto/AutoRerun_pb2.py +3 -2
- streamlit/runtime/app_session.py +7 -7
- streamlit/runtime/caching/__init__.py +9 -13
- streamlit/runtime/caching/cache_data_api.py +18 -7
- streamlit/runtime/caching/cache_errors.py +8 -6
- streamlit/runtime/caching/cache_resource_api.py +10 -9
- streamlit/runtime/caching/cache_utils.py +10 -7
- streamlit/runtime/caching/cached_message_replay.py +10 -9
- streamlit/runtime/caching/hashing.py +3 -3
- streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -1
- streamlit/runtime/connection_factory.py +4 -2
- streamlit/runtime/credentials.py +11 -20
- streamlit/runtime/forward_msg_cache.py +10 -11
- streamlit/runtime/forward_msg_queue.py +6 -4
- streamlit/runtime/fragment.py +7 -9
- streamlit/runtime/media_file_manager.py +4 -4
- streamlit/runtime/memory_media_file_storage.py +7 -8
- streamlit/runtime/metrics_util.py +2 -4
- streamlit/runtime/pages_manager.py +41 -41
- streamlit/runtime/runtime.py +4 -4
- streamlit/runtime/runtime_util.py +7 -12
- streamlit/runtime/scriptrunner/magic.py +1 -1
- streamlit/runtime/scriptrunner/script_requests.py +4 -2
- streamlit/runtime/scriptrunner/script_run_context.py +15 -15
- streamlit/runtime/scriptrunner/script_runner.py +8 -8
- streamlit/runtime/secrets.py +3 -5
- streamlit/runtime/session_manager.py +8 -7
- streamlit/runtime/state/common.py +1 -1
- streamlit/runtime/state/query_params_proxy.py +5 -10
- streamlit/runtime/state/safe_session_state.py +8 -7
- streamlit/runtime/state/widgets.py +27 -27
- streamlit/runtime/stats.py +1 -1
- streamlit/runtime/uploaded_file_manager.py +4 -2
- streamlit/runtime/websocket_session_manager.py +6 -4
- streamlit/string_util.py +1 -1
- streamlit/testing/v1/app_test.py +4 -2
- streamlit/testing/v1/element_tree.py +33 -37
- streamlit/testing/v1/local_script_runner.py +7 -7
- streamlit/time_util.py +2 -4
- streamlit/type_util.py +16 -29
- streamlit/user_info.py +4 -2
- streamlit/util.py +1 -1
- streamlit/watcher/event_based_path_watcher.py +6 -3
- streamlit/watcher/local_sources_watcher.py +11 -7
- streamlit/web/bootstrap.py +1 -1
- streamlit/web/cache_storage_manager_config.py +5 -1
- streamlit/web/cli.py +9 -4
- streamlit/web/server/browser_websocket_handler.py +7 -8
- streamlit/web/server/component_request_handler.py +4 -2
- streamlit/web/server/routes.py +3 -3
- streamlit/web/server/server.py +12 -12
- streamlit/web/server/server_util.py +5 -6
- streamlit/web/server/stats_request_handler.py +1 -1
- streamlit/web/server/upload_file_request_handler.py +5 -3
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/RECORD +113 -113
- {streamlit_nightly-1.35.1.dev20240610.data → streamlit_nightly-1.35.1.dev20240611.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.35.1.dev20240610.dist-info → streamlit_nightly-1.35.1.dev20240611.dist-info}/top_level.txt +0 -0
streamlit/type_util.py
CHANGED
@@ -42,9 +42,7 @@ from typing import (
|
|
42
42
|
from typing_extensions import TypeAlias, TypeGuard
|
43
43
|
|
44
44
|
import streamlit as st
|
45
|
-
from streamlit import config, errors
|
46
|
-
from streamlit import logger as _logger
|
47
|
-
from streamlit import string_util
|
45
|
+
from streamlit import config, errors, logger, string_util
|
48
46
|
from streamlit.errors import StreamlitAPIException
|
49
47
|
|
50
48
|
if TYPE_CHECKING:
|
@@ -65,7 +63,7 @@ if TYPE_CHECKING:
|
|
65
63
|
# Maximum number of rows to request from an unevaluated (out-of-core) dataframe
|
66
64
|
MAX_UNEVALUATED_DF_ROWS = 10000
|
67
65
|
|
68
|
-
_LOGGER =
|
66
|
+
_LOGGER = logger.get_logger(__name__)
|
69
67
|
|
70
68
|
# The array value field names are part of the larger set of possible value
|
71
69
|
# field names. See the explanation for said set below. The message types
|
@@ -129,8 +127,7 @@ class DataFrameGenericAlias(Protocol[V_co]):
|
|
129
127
|
"""
|
130
128
|
|
131
129
|
@property
|
132
|
-
def iloc(self) -> _iLocIndexer:
|
133
|
-
...
|
130
|
+
def iloc(self) -> _iLocIndexer: ...
|
134
131
|
|
135
132
|
|
136
133
|
OptionSequence: TypeAlias = Union[
|
@@ -147,8 +144,7 @@ VegaLiteType = Literal["quantitative", "ordinal", "temporal", "nominal"]
|
|
147
144
|
|
148
145
|
|
149
146
|
class SupportsStr(Protocol):
|
150
|
-
def __str__(self) -> str:
|
151
|
-
...
|
147
|
+
def __str__(self) -> str: ...
|
152
148
|
|
153
149
|
|
154
150
|
def is_array_value_field_name(obj: object) -> TypeGuard[ArrayValueFieldName]:
|
@@ -158,20 +154,17 @@ def is_array_value_field_name(obj: object) -> TypeGuard[ArrayValueFieldName]:
|
|
158
154
|
@overload
|
159
155
|
def is_type(
|
160
156
|
obj: object, fqn_type_pattern: Literal["pydeck.bindings.deck.Deck"]
|
161
|
-
) -> TypeGuard[Deck]:
|
162
|
-
...
|
157
|
+
) -> TypeGuard[Deck]: ...
|
163
158
|
|
164
159
|
|
165
160
|
@overload
|
166
161
|
def is_type(
|
167
162
|
obj: object, fqn_type_pattern: Literal["plotly.graph_objs._figure.Figure"]
|
168
|
-
) -> TypeGuard[Figure]:
|
169
|
-
...
|
163
|
+
) -> TypeGuard[Figure]: ...
|
170
164
|
|
171
165
|
|
172
166
|
@overload
|
173
|
-
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool:
|
174
|
-
...
|
167
|
+
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool: ...
|
175
168
|
|
176
169
|
|
177
170
|
def is_type(obj: object, fqn_type_pattern: str | re.Pattern[str]) -> bool:
|
@@ -344,7 +337,7 @@ def is_pyspark_data_object(obj: object) -> bool:
|
|
344
337
|
return (
|
345
338
|
is_type(obj, _PYSPARK_DF_TYPE_STR)
|
346
339
|
and hasattr(obj, "toPandas")
|
347
|
-
and callable(
|
340
|
+
and callable(obj.toPandas)
|
348
341
|
)
|
349
342
|
|
350
343
|
|
@@ -510,7 +503,7 @@ def is_function(x: object) -> TypeGuard[types.FunctionType]:
|
|
510
503
|
def is_namedtuple(x: object) -> TypeGuard[NamedTuple]:
|
511
504
|
t = type(x)
|
512
505
|
b = t.__bases__
|
513
|
-
if len(b) != 1 or b[0]
|
506
|
+
if len(b) != 1 or b[0] is not tuple:
|
514
507
|
return False
|
515
508
|
f = getattr(t, "_fields", None)
|
516
509
|
if not isinstance(f, tuple):
|
@@ -558,8 +551,7 @@ def convert_anything_to_df(
|
|
558
551
|
data: Any,
|
559
552
|
max_unevaluated_rows: int = MAX_UNEVALUATED_DF_ROWS,
|
560
553
|
ensure_copy: bool = False,
|
561
|
-
) -> DataFrame:
|
562
|
-
...
|
554
|
+
) -> DataFrame: ...
|
563
555
|
|
564
556
|
|
565
557
|
@overload
|
@@ -568,8 +560,7 @@ def convert_anything_to_df(
|
|
568
560
|
max_unevaluated_rows: int = MAX_UNEVALUATED_DF_ROWS,
|
569
561
|
ensure_copy: bool = False,
|
570
562
|
allow_styler: bool = False,
|
571
|
-
) -> DataFrame | Styler:
|
572
|
-
...
|
563
|
+
) -> DataFrame | Styler: ...
|
573
564
|
|
574
565
|
|
575
566
|
def convert_anything_to_df(
|
@@ -698,13 +689,11 @@ Offending object:
|
|
698
689
|
|
699
690
|
|
700
691
|
@overload
|
701
|
-
def ensure_iterable(obj: Iterable[V_co]) -> Iterable[V_co]:
|
702
|
-
...
|
692
|
+
def ensure_iterable(obj: Iterable[V_co]) -> Iterable[V_co]: ...
|
703
693
|
|
704
694
|
|
705
695
|
@overload
|
706
|
-
def ensure_iterable(obj: OptionSequence[V_co]) -> Iterable[Any]:
|
707
|
-
...
|
696
|
+
def ensure_iterable(obj: OptionSequence[V_co]) -> Iterable[Any]: ...
|
708
697
|
|
709
698
|
|
710
699
|
def ensure_iterable(obj: OptionSequence[V_co] | Iterable[V_co]) -> Iterable[Any]:
|
@@ -1304,19 +1293,17 @@ def convert_df_to_data_format(
|
|
1304
1293
|
df = _unify_missing_values(df)
|
1305
1294
|
# The key is expected to be the index -> this will return the first column
|
1306
1295
|
# as a dict with index as key.
|
1307
|
-
return
|
1296
|
+
return {} if df.empty else df.iloc[:, 0].to_dict()
|
1308
1297
|
|
1309
1298
|
raise ValueError(f"Unsupported input data format: {data_format}")
|
1310
1299
|
|
1311
1300
|
|
1312
1301
|
@overload
|
1313
|
-
def to_key(key: None) -> None:
|
1314
|
-
...
|
1302
|
+
def to_key(key: None) -> None: ...
|
1315
1303
|
|
1316
1304
|
|
1317
1305
|
@overload
|
1318
|
-
def to_key(key: Key) -> str:
|
1319
|
-
...
|
1306
|
+
def to_key(key: Key) -> str: ...
|
1320
1307
|
|
1321
1308
|
|
1322
1309
|
def to_key(key: Key | None) -> str | None:
|
streamlit/user_info.py
CHANGED
@@ -14,11 +14,13 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from typing import Iterator, Mapping, NoReturn, Union
|
17
|
+
from typing import TYPE_CHECKING, Iterator, Mapping, NoReturn, Union
|
18
18
|
|
19
19
|
from streamlit.errors import StreamlitAPIException
|
20
20
|
from streamlit.runtime.scriptrunner import get_script_run_ctx as _get_script_run_ctx
|
21
|
-
|
21
|
+
|
22
|
+
if TYPE_CHECKING:
|
23
|
+
from streamlit.runtime.scriptrunner.script_run_context import UserInfo
|
22
24
|
|
23
25
|
|
24
26
|
def _get_user_info() -> UserInfo:
|
streamlit/util.py
CHANGED
@@ -111,7 +111,7 @@ def repr_(self: Any) -> str:
|
|
111
111
|
classname = self.__class__.__name__
|
112
112
|
# Most of the falsey value, but excluding 0 and 0.0, since those often have
|
113
113
|
# semantic meaning within streamlit.
|
114
|
-
defaults: list[Any] = [None, "", False, [], set(),
|
114
|
+
defaults: list[Any] = [None, "", False, [], set(), {}]
|
115
115
|
if dataclasses.is_dataclass(self):
|
116
116
|
fields_vals = (
|
117
117
|
(f.name, getattr(self, f.name))
|
@@ -39,17 +39,20 @@ from __future__ import annotations
|
|
39
39
|
|
40
40
|
import os
|
41
41
|
import threading
|
42
|
-
from typing import Callable, Final, cast
|
42
|
+
from typing import TYPE_CHECKING, Callable, Final, cast
|
43
43
|
|
44
44
|
from blinker import ANY, Signal
|
45
|
+
from typing_extensions import Self
|
45
46
|
from watchdog import events
|
46
47
|
from watchdog.observers import Observer
|
47
|
-
from watchdog.observers.api import ObservedWatch
|
48
48
|
|
49
49
|
from streamlit.logger import get_logger
|
50
50
|
from streamlit.util import repr_
|
51
51
|
from streamlit.watcher import util
|
52
52
|
|
53
|
+
if TYPE_CHECKING:
|
54
|
+
from watchdog.observers.api import ObservedWatch
|
55
|
+
|
53
56
|
_LOGGER: Final = get_logger(__name__)
|
54
57
|
|
55
58
|
|
@@ -127,7 +130,7 @@ class _MultiPathWatcher:
|
|
127
130
|
return cast("_MultiPathWatcher", _MultiPathWatcher._singleton)
|
128
131
|
|
129
132
|
# Don't allow constructor to be called more than once.
|
130
|
-
def __new__(cls) ->
|
133
|
+
def __new__(cls) -> Self:
|
131
134
|
"""Constructor."""
|
132
135
|
if _MultiPathWatcher._singleton is not None:
|
133
136
|
raise RuntimeError("Use .get_singleton() instead")
|
@@ -14,12 +14,10 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
import collections
|
18
17
|
import os
|
19
18
|
import sys
|
20
|
-
import types
|
21
19
|
from pathlib import Path
|
22
|
-
from typing import TYPE_CHECKING, Callable, Final
|
20
|
+
from typing import TYPE_CHECKING, Any, Callable, Final, NamedTuple
|
23
21
|
|
24
22
|
from streamlit import config, file_util
|
25
23
|
from streamlit.folder_black_list import FolderBlackList
|
@@ -30,11 +28,17 @@ from streamlit.watcher.path_watcher import (
|
|
30
28
|
)
|
31
29
|
|
32
30
|
if TYPE_CHECKING:
|
31
|
+
from types import ModuleType
|
32
|
+
|
33
33
|
from streamlit.runtime.pages_manager import PagesManager
|
34
34
|
|
35
35
|
_LOGGER: Final = get_logger(__name__)
|
36
36
|
|
37
|
-
|
37
|
+
|
38
|
+
class WatchedModule(NamedTuple):
|
39
|
+
watcher: Any
|
40
|
+
module_name: Any
|
41
|
+
|
38
42
|
|
39
43
|
# This needs to be initialized lazily to avoid calling config.get_option() and
|
40
44
|
# thus initializing config options when this file is first imported.
|
@@ -42,7 +46,7 @@ PathWatcher = None
|
|
42
46
|
|
43
47
|
|
44
48
|
class LocalSourcesWatcher:
|
45
|
-
def __init__(self, pages_manager:
|
49
|
+
def __init__(self, pages_manager: PagesManager):
|
46
50
|
self._pages_manager = pages_manager
|
47
51
|
self._main_script_path = os.path.abspath(self._pages_manager.main_script_path)
|
48
52
|
self._script_folder = os.path.dirname(self._main_script_path)
|
@@ -182,7 +186,7 @@ class LocalSourcesWatcher:
|
|
182
186
|
return {p for p in paths if not self._folder_black_list.is_blacklisted(p)}
|
183
187
|
|
184
188
|
|
185
|
-
def get_module_paths(module:
|
189
|
+
def get_module_paths(module: ModuleType) -> set[str]:
|
186
190
|
paths_extractors = [
|
187
191
|
# https://docs.python.org/3/reference/datamodel.html
|
188
192
|
# __file__ is the pathname of the file from which the module was loaded
|
@@ -203,7 +207,7 @@ def get_module_paths(module: types.ModuleType) -> set[str]:
|
|
203
207
|
# Handling of "namespace packages" in which the __path__ attribute
|
204
208
|
# is a _NamespacePath object with a _path attribute containing
|
205
209
|
# the various paths of the package.
|
206
|
-
lambda m:
|
210
|
+
lambda m: list(m.__path__._path),
|
207
211
|
]
|
208
212
|
|
209
213
|
all_paths = set()
|
streamlit/web/bootstrap.py
CHANGED
@@ -113,7 +113,7 @@ def _on_server_start(server: Server) -> None:
|
|
113
113
|
try:
|
114
114
|
secrets.load_if_toml_exists()
|
115
115
|
except Exception as ex:
|
116
|
-
_LOGGER.error(
|
116
|
+
_LOGGER.error("Failed to load secrets.toml file", exc_info=ex)
|
117
117
|
|
118
118
|
def maybe_open_browser():
|
119
119
|
if config.get_option("server.headless"):
|
@@ -14,11 +14,15 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from
|
17
|
+
from typing import TYPE_CHECKING
|
18
|
+
|
18
19
|
from streamlit.runtime.caching.storage.local_disk_cache_storage import (
|
19
20
|
LocalDiskCacheStorageManager,
|
20
21
|
)
|
21
22
|
|
23
|
+
if TYPE_CHECKING:
|
24
|
+
from streamlit.runtime.caching.storage import CacheStorageManager
|
25
|
+
|
22
26
|
|
23
27
|
def create_default_cache_storage_manager() -> CacheStorageManager:
|
24
28
|
"""
|
streamlit/web/cli.py
CHANGED
@@ -18,7 +18,7 @@ from __future__ import annotations
|
|
18
18
|
|
19
19
|
import os
|
20
20
|
import sys
|
21
|
-
from typing import Any
|
21
|
+
from typing import TYPE_CHECKING, Any, Callable, TypeVar
|
22
22
|
|
23
23
|
# We cannot lazy-load click here because its used via decorators.
|
24
24
|
import click
|
@@ -26,12 +26,14 @@ import click
|
|
26
26
|
import streamlit.runtime.caching as caching
|
27
27
|
import streamlit.web.bootstrap as bootstrap
|
28
28
|
from streamlit import config as _config
|
29
|
-
from streamlit.config_option import ConfigOption
|
30
29
|
from streamlit.runtime.credentials import Credentials, check_credentials
|
31
30
|
from streamlit.web.cache_storage_manager_config import (
|
32
31
|
create_default_cache_storage_manager,
|
33
32
|
)
|
34
33
|
|
34
|
+
if TYPE_CHECKING:
|
35
|
+
from streamlit.config_option import ConfigOption
|
36
|
+
|
35
37
|
ACCEPTED_FILE_EXTENSIONS = ("py", "py3")
|
36
38
|
|
37
39
|
LOG_LEVELS = ("error", "warning", "info", "debug")
|
@@ -73,7 +75,10 @@ def _make_sensitive_option_callback(config_option: ConfigOption):
|
|
73
75
|
return callback
|
74
76
|
|
75
77
|
|
76
|
-
|
78
|
+
F = TypeVar("F", bound=Callable[..., Any])
|
79
|
+
|
80
|
+
|
81
|
+
def configurator_options(func: F) -> F:
|
77
82
|
"""Decorator that adds config param keys to click dynamically."""
|
78
83
|
for _, value in reversed(_config._config_options_template.items()):
|
79
84
|
parsed_parameter = _convert_config_option_to_click_option(value)
|
@@ -170,7 +175,7 @@ def main_version():
|
|
170
175
|
@main.command("docs")
|
171
176
|
def main_docs():
|
172
177
|
"""Show help in browser."""
|
173
|
-
|
178
|
+
click.echo("Showing help page in browser...")
|
174
179
|
from streamlit import util
|
175
180
|
|
176
181
|
util.open_browser("https://docs.streamlit.io")
|
@@ -17,7 +17,7 @@ from __future__ import annotations
|
|
17
17
|
import base64
|
18
18
|
import binascii
|
19
19
|
import json
|
20
|
-
from typing import Any, Awaitable, Final
|
20
|
+
from typing import TYPE_CHECKING, Any, Awaitable, Final
|
21
21
|
|
22
22
|
import tornado.concurrent
|
23
23
|
import tornado.locks
|
@@ -29,11 +29,13 @@ from tornado.websocket import WebSocketHandler
|
|
29
29
|
from streamlit import config
|
30
30
|
from streamlit.logger import get_logger
|
31
31
|
from streamlit.proto.BackMsg_pb2 import BackMsg
|
32
|
-
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
33
32
|
from streamlit.runtime import Runtime, SessionClient, SessionClientDisconnectedError
|
34
33
|
from streamlit.runtime.runtime_util import serialize_forward_msg
|
35
34
|
from streamlit.web.server.server_util import is_url_from_allowed_origins
|
36
35
|
|
36
|
+
if TYPE_CHECKING:
|
37
|
+
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
38
|
+
|
37
39
|
_LOGGER: Final = get_logger(__name__)
|
38
40
|
|
39
41
|
|
@@ -101,12 +103,9 @@ class BrowserWebSocketHandler(WebSocketHandler, SessionClient):
|
|
101
103
|
except (KeyError, binascii.Error, json.decoder.JSONDecodeError):
|
102
104
|
email = "test@example.com"
|
103
105
|
|
104
|
-
user_info: dict[str, str | None] =
|
105
|
-
|
106
|
-
|
107
|
-
user_info["email"] = None
|
108
|
-
else:
|
109
|
-
user_info["email"] = email
|
106
|
+
user_info: dict[str, str | None] = {
|
107
|
+
"email": None if is_public_cloud_app else email
|
108
|
+
}
|
110
109
|
|
111
110
|
existing_session_id = None
|
112
111
|
try:
|
@@ -16,14 +16,16 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
import mimetypes
|
18
18
|
import os
|
19
|
-
from typing import Final
|
19
|
+
from typing import TYPE_CHECKING, Final
|
20
20
|
|
21
21
|
import tornado.web
|
22
22
|
|
23
23
|
import streamlit.web.server.routes
|
24
|
-
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
25
24
|
from streamlit.logger import get_logger
|
26
25
|
|
26
|
+
if TYPE_CHECKING:
|
27
|
+
from streamlit.components.types.base_component_registry import BaseComponentRegistry
|
28
|
+
|
27
29
|
_LOGGER: Final = get_logger(__name__)
|
28
30
|
|
29
31
|
|
streamlit/web/server/routes.py
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import os
|
18
|
-
from typing import Final
|
18
|
+
from typing import Final, Sequence
|
19
19
|
|
20
20
|
import tornado.web
|
21
21
|
|
@@ -45,7 +45,7 @@ class StaticFileHandler(tornado.web.StaticFileHandler):
|
|
45
45
|
self,
|
46
46
|
path: str,
|
47
47
|
default_filename: str | None = None,
|
48
|
-
reserved_paths:
|
48
|
+
reserved_paths: Sequence[str] = (),
|
49
49
|
):
|
50
50
|
self._reserved_paths = reserved_paths
|
51
51
|
|
@@ -71,7 +71,7 @@ class StaticFileHandler(tornado.web.StaticFileHandler):
|
|
71
71
|
# If the file is not found, and there are no reserved paths,
|
72
72
|
# we try to serve the default file and allow the frontend to handle the issue.
|
73
73
|
if e.status_code == 404:
|
74
|
-
if any(
|
74
|
+
if any(self.path.endswith(x) for x in self._reserved_paths):
|
75
75
|
raise e
|
76
76
|
|
77
77
|
self.path = self.parse_url_path(self.default_filename or "index.html")
|
streamlit/web/server/server.py
CHANGED
@@ -287,22 +287,22 @@ class Server:
|
|
287
287
|
(
|
288
288
|
make_url_path_regex(base, STREAM_ENDPOINT),
|
289
289
|
BrowserWebSocketHandler,
|
290
|
-
|
290
|
+
{"runtime": self._runtime},
|
291
291
|
),
|
292
292
|
(
|
293
293
|
make_url_path_regex(base, HEALTH_ENDPOINT),
|
294
294
|
HealthHandler,
|
295
|
-
|
295
|
+
{"callback": lambda: self._runtime.is_ready_for_browser_connection},
|
296
296
|
),
|
297
297
|
(
|
298
298
|
make_url_path_regex(base, MESSAGE_ENDPOINT),
|
299
299
|
MessageCacheHandler,
|
300
|
-
|
300
|
+
{"cache": self._runtime.message_cache},
|
301
301
|
),
|
302
302
|
(
|
303
303
|
make_url_path_regex(base, METRIC_ENDPOINT),
|
304
304
|
StatsRequestHandler,
|
305
|
-
|
305
|
+
{"stats_manager": self._runtime.stats_mgr},
|
306
306
|
),
|
307
307
|
(
|
308
308
|
make_url_path_regex(base, HOST_CONFIG_ENDPOINT),
|
@@ -314,10 +314,10 @@ class Server:
|
|
314
314
|
rf"{UPLOAD_FILE_ENDPOINT}/(?P<session_id>[^/]+)/(?P<file_id>[^/]+)",
|
315
315
|
),
|
316
316
|
UploadFileRequestHandler,
|
317
|
-
|
318
|
-
file_mgr
|
319
|
-
is_active_session
|
320
|
-
|
317
|
+
{
|
318
|
+
"file_mgr": self._runtime.uploaded_file_mgr,
|
319
|
+
"is_active_session": self._runtime.is_active_session,
|
320
|
+
},
|
321
321
|
),
|
322
322
|
(
|
323
323
|
make_url_path_regex(base, f"{MEDIA_ENDPOINT}/(.*)"),
|
@@ -327,7 +327,7 @@ class Server:
|
|
327
327
|
(
|
328
328
|
make_url_path_regex(base, "component/(.*)"),
|
329
329
|
ComponentRequestHandler,
|
330
|
-
|
330
|
+
{"registry": self._runtime.component_registry},
|
331
331
|
),
|
332
332
|
]
|
333
333
|
|
@@ -337,9 +337,9 @@ class Server:
|
|
337
337
|
(
|
338
338
|
make_url_path_regex(base, SCRIPT_HEALTH_CHECK_ENDPOINT),
|
339
339
|
HealthHandler,
|
340
|
-
|
341
|
-
callback
|
342
|
-
|
340
|
+
{
|
341
|
+
"callback": lambda: self._runtime.does_script_run_without_error()
|
342
|
+
},
|
343
343
|
)
|
344
344
|
]
|
345
345
|
)
|
@@ -16,13 +16,14 @@
|
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
|
-
from typing import Final
|
19
|
+
from typing import TYPE_CHECKING, Final
|
20
20
|
from urllib.parse import urljoin
|
21
21
|
|
22
|
-
import tornado.web
|
23
|
-
|
24
22
|
from streamlit import config, net_util, url_util
|
25
23
|
|
24
|
+
if TYPE_CHECKING:
|
25
|
+
from tornado.web import RequestHandler
|
26
|
+
|
26
27
|
# The port reserved for internal development.
|
27
28
|
DEVELOPMENT_PORT: Final = 3000
|
28
29
|
|
@@ -120,9 +121,7 @@ def _get_browser_address_bar_port() -> int:
|
|
120
121
|
return int(config.get_option("browser.serverPort"))
|
121
122
|
|
122
123
|
|
123
|
-
def emit_endpoint_deprecation_notice(
|
124
|
-
handler: tornado.web.RequestHandler, new_path: str
|
125
|
-
) -> None:
|
124
|
+
def emit_endpoint_deprecation_notice(handler: RequestHandler, new_path: str) -> None:
|
126
125
|
"""
|
127
126
|
Emits the warning about deprecation of HTTP endpoint in the HTTP header.
|
128
127
|
"""
|
@@ -18,11 +18,11 @@ from typing import TYPE_CHECKING
|
|
18
18
|
|
19
19
|
import tornado.web
|
20
20
|
|
21
|
-
from streamlit.runtime.stats import CacheStat, StatsManager
|
22
21
|
from streamlit.web.server.server_util import emit_endpoint_deprecation_notice
|
23
22
|
|
24
23
|
if TYPE_CHECKING:
|
25
24
|
from streamlit.proto.openmetrics_data_model_pb2 import MetricSet as MetricSetProto
|
25
|
+
from streamlit.runtime.stats import CacheStat, StatsManager
|
26
26
|
|
27
27
|
|
28
28
|
class StatsRequestHandler(tornado.web.RequestHandler):
|
@@ -14,16 +14,18 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from typing import Any, Callable
|
17
|
+
from typing import TYPE_CHECKING, Any, Callable
|
18
18
|
|
19
19
|
import tornado.httputil
|
20
20
|
import tornado.web
|
21
21
|
|
22
22
|
from streamlit import config
|
23
|
-
from streamlit.runtime.memory_uploaded_file_manager import MemoryUploadedFileManager
|
24
23
|
from streamlit.runtime.uploaded_file_manager import UploadedFileRec
|
25
24
|
from streamlit.web.server import routes, server_util
|
26
25
|
|
26
|
+
if TYPE_CHECKING:
|
27
|
+
from streamlit.runtime.memory_uploaded_file_manager import MemoryUploadedFileManager
|
28
|
+
|
27
29
|
|
28
30
|
class UploadFileRequestHandler(tornado.web.RequestHandler):
|
29
31
|
"""Implements the POST /upload_file endpoint."""
|
@@ -98,7 +100,7 @@ class UploadFileRequestHandler(tornado.web.RequestHandler):
|
|
98
100
|
|
99
101
|
try:
|
100
102
|
if not self._is_active_session(session_id):
|
101
|
-
raise Exception(
|
103
|
+
raise Exception("Invalid session_id")
|
102
104
|
except Exception as e:
|
103
105
|
self.send_error(400, reason=str(e))
|
104
106
|
return
|