streamlit-nightly 1.29.1.dev20240108__py2.py3-none-any.whl → 1.29.1.dev20240109__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/commands/execution_control.py +1 -1
- streamlit/commands/experimental_query_params.py +5 -4
- streamlit/constants.py +17 -0
- streamlit/runtime/state/query_params.py +34 -14
- streamlit/static/asset-manifest.json +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{main.cbbf0bd5.js → main.3ab8e8d9.js} +2 -2
- {streamlit_nightly-1.29.1.dev20240108.dist-info → streamlit_nightly-1.29.1.dev20240109.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.29.1.dev20240108.dist-info → streamlit_nightly-1.29.1.dev20240109.dist-info}/RECORD +14 -13
- /streamlit/static/static/js/{main.cbbf0bd5.js.LICENSE.txt → main.3ab8e8d9.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.29.1.dev20240108.data → streamlit_nightly-1.29.1.dev20240109.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.29.1.dev20240108.dist-info → streamlit_nightly-1.29.1.dev20240109.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.29.1.dev20240108.dist-info → streamlit_nightly-1.29.1.dev20240109.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.29.1.dev20240108.dist-info → streamlit_nightly-1.29.1.dev20240109.dist-info}/top_level.txt +0 -0
@@ -16,15 +16,16 @@ import urllib.parse as parse
|
|
16
16
|
from typing import Any, Dict, List, Union
|
17
17
|
|
18
18
|
from streamlit import util
|
19
|
+
from streamlit.constants import (
|
20
|
+
EMBED_OPTIONS_QUERY_PARAM,
|
21
|
+
EMBED_QUERY_PARAM,
|
22
|
+
EMBED_QUERY_PARAMS_KEYS,
|
23
|
+
)
|
19
24
|
from streamlit.errors import StreamlitAPIException
|
20
25
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
21
26
|
from streamlit.runtime.metrics_util import gather_metrics
|
22
27
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
23
28
|
|
24
|
-
EMBED_QUERY_PARAM = "embed"
|
25
|
-
EMBED_OPTIONS_QUERY_PARAM = "embed_options"
|
26
|
-
EMBED_QUERY_PARAMS_KEYS = [EMBED_QUERY_PARAM, EMBED_OPTIONS_QUERY_PARAM]
|
27
|
-
|
28
29
|
|
29
30
|
@gather_metrics("experimental_get_query_params")
|
30
31
|
def get_query_params() -> Dict[str, List[str]]:
|
streamlit/constants.py
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
EMBED_QUERY_PARAM = "embed"
|
16
|
+
EMBED_OPTIONS_QUERY_PARAM = "embed_options"
|
17
|
+
EMBED_QUERY_PARAMS_KEYS = [EMBED_QUERY_PARAM, EMBED_OPTIONS_QUERY_PARAM]
|
@@ -14,7 +14,9 @@
|
|
14
14
|
|
15
15
|
from dataclasses import dataclass, field
|
16
16
|
from typing import Dict, Iterable, Iterator, List, MutableMapping, Union
|
17
|
+
from urllib import parse
|
17
18
|
|
19
|
+
from streamlit.constants import EMBED_QUERY_PARAMS_KEYS
|
18
20
|
from streamlit.errors import StreamlitAPIException
|
19
21
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
20
22
|
|
@@ -29,7 +31,12 @@ class QueryParams(MutableMapping[str, str]):
|
|
29
31
|
|
30
32
|
def __iter__(self) -> Iterator[str]:
|
31
33
|
self._ensure_single_query_api_used()
|
32
|
-
|
34
|
+
|
35
|
+
return iter(
|
36
|
+
key
|
37
|
+
for key in self._query_params.keys()
|
38
|
+
if key not in EMBED_QUERY_PARAMS_KEYS
|
39
|
+
)
|
33
40
|
|
34
41
|
def __getitem__(self, key: str) -> str:
|
35
42
|
"""Retrieves a value for a given key in query parameters.
|
@@ -38,6 +45,8 @@ class QueryParams(MutableMapping[str, str]):
|
|
38
45
|
"""
|
39
46
|
self._ensure_single_query_api_used()
|
40
47
|
try:
|
48
|
+
if key in EMBED_QUERY_PARAMS_KEYS:
|
49
|
+
raise KeyError(missing_key_error_message(key))
|
41
50
|
value = self._query_params[key]
|
42
51
|
if isinstance(value, list):
|
43
52
|
if len(value) == 0:
|
@@ -56,6 +65,10 @@ class QueryParams(MutableMapping[str, str]):
|
|
56
65
|
f"You cannot set a query params key `{key}` to a dictionary."
|
57
66
|
)
|
58
67
|
|
68
|
+
if key in EMBED_QUERY_PARAMS_KEYS:
|
69
|
+
raise StreamlitAPIException(
|
70
|
+
"Query param embed and embed_options (case-insensitive) cannot be set programmatically."
|
71
|
+
)
|
59
72
|
# Type checking users should handle the string serialization themselves
|
60
73
|
# We will accept any type for the list and serialize to str just in case
|
61
74
|
if isinstance(value, Iterable) and not isinstance(value, str):
|
@@ -66,6 +79,8 @@ class QueryParams(MutableMapping[str, str]):
|
|
66
79
|
|
67
80
|
def __delitem__(self, key: str) -> None:
|
68
81
|
try:
|
82
|
+
if key in EMBED_QUERY_PARAMS_KEYS:
|
83
|
+
raise KeyError(missing_key_error_message(key))
|
69
84
|
del self._query_params[key]
|
70
85
|
self._send_query_param_msg()
|
71
86
|
except KeyError:
|
@@ -73,18 +88,19 @@ class QueryParams(MutableMapping[str, str]):
|
|
73
88
|
|
74
89
|
def get_all(self, key: str) -> List[str]:
|
75
90
|
self._ensure_single_query_api_used()
|
76
|
-
if key not in self._query_params:
|
91
|
+
if key not in self._query_params or key in EMBED_QUERY_PARAMS_KEYS:
|
77
92
|
return []
|
78
93
|
value = self._query_params[key]
|
79
94
|
return value if isinstance(value, list) else [value]
|
80
95
|
|
81
96
|
def __len__(self) -> int:
|
82
97
|
self._ensure_single_query_api_used()
|
83
|
-
return len(
|
98
|
+
return len(
|
99
|
+
{key for key in self._query_params if key not in EMBED_QUERY_PARAMS_KEYS}
|
100
|
+
)
|
84
101
|
|
85
102
|
def _send_query_param_msg(self) -> None:
|
86
103
|
# Avoid circular imports
|
87
|
-
from streamlit.commands.experimental_query_params import _ensure_no_embed_params
|
88
104
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
89
105
|
|
90
106
|
ctx = get_script_run_ctx()
|
@@ -93,27 +109,31 @@ class QueryParams(MutableMapping[str, str]):
|
|
93
109
|
self._ensure_single_query_api_used()
|
94
110
|
|
95
111
|
msg = ForwardMsg()
|
96
|
-
msg.page_info_changed.query_string =
|
97
|
-
self._query_params,
|
112
|
+
msg.page_info_changed.query_string = parse.urlencode(
|
113
|
+
self._query_params, doseq=True
|
98
114
|
)
|
99
115
|
ctx.query_string = msg.page_info_changed.query_string
|
100
116
|
ctx.enqueue(msg)
|
101
117
|
|
102
118
|
def clear(self) -> None:
|
103
|
-
|
119
|
+
new_query_params = {}
|
120
|
+
for key, value in self._query_params.items():
|
121
|
+
if key in EMBED_QUERY_PARAMS_KEYS:
|
122
|
+
new_query_params[key] = value
|
123
|
+
self._query_params = new_query_params
|
124
|
+
|
104
125
|
self._send_query_param_msg()
|
105
126
|
|
106
127
|
def to_dict(self) -> Dict[str, str]:
|
107
128
|
self._ensure_single_query_api_used()
|
108
|
-
# return the last query param if multiple
|
109
|
-
return {
|
129
|
+
# return the last query param if multiple values are set
|
130
|
+
return {
|
131
|
+
key: self[key]
|
132
|
+
for key in self._query_params
|
133
|
+
if key not in EMBED_QUERY_PARAMS_KEYS
|
134
|
+
}
|
110
135
|
|
111
136
|
def set_with_no_forward_msg(self, key: str, val: Union[List[str], str]) -> None:
|
112
|
-
# Avoid circular imports
|
113
|
-
from streamlit.commands.experimental_query_params import EMBED_QUERY_PARAMS_KEYS
|
114
|
-
|
115
|
-
if key.lower() in EMBED_QUERY_PARAMS_KEYS:
|
116
|
-
return
|
117
137
|
self._query_params[key] = val
|
118
138
|
|
119
139
|
def clear_with_no_forward_msg(self) -> None:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.77d1c464.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.3ab8e8d9.js",
|
5
5
|
"static/js/9336.2d95d840.chunk.js": "./static/js/9336.2d95d840.chunk.js",
|
6
6
|
"static/js/9330.c0dd1723.chunk.js": "./static/js/9330.c0dd1723.chunk.js",
|
7
7
|
"static/js/7217.d970c074.chunk.js": "./static/js/7217.d970c074.chunk.js",
|
@@ -149,6 +149,6 @@
|
|
149
149
|
},
|
150
150
|
"entrypoints": [
|
151
151
|
"static/css/main.77d1c464.css",
|
152
|
-
"static/js/main.
|
152
|
+
"static/js/main.3ab8e8d9.js"
|
153
153
|
]
|
154
154
|
}
|
streamlit/static/index.html
CHANGED
@@ -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.
|
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.3ab8e8d9.js"></script><link href="./static/css/main.77d1c464.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|