streamlit-nightly 1.36.1.dev20240702__py2.py3-none-any.whl → 1.36.1.dev20240704__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/navigation.py +1 -1
- streamlit/components/v1/component_arrow.py +16 -11
- streamlit/components/v1/custom_component.py +2 -1
- streamlit/dataframe_util.py +884 -0
- streamlit/delta_generator.py +6 -4
- streamlit/elements/arrow.py +26 -45
- streamlit/elements/lib/built_in_chart_utils.py +78 -19
- streamlit/elements/lib/column_config_utils.py +1 -1
- streamlit/elements/lib/pandas_styler_utils.py +4 -2
- streamlit/elements/lib/policies.py +60 -8
- streamlit/elements/lib/utils.py +100 -10
- streamlit/elements/map.py +4 -15
- streamlit/elements/metric.py +5 -2
- streamlit/elements/plotly_chart.py +11 -12
- streamlit/elements/vega_charts.py +19 -31
- streamlit/elements/widgets/button.py +17 -15
- streamlit/elements/widgets/camera_input.py +15 -10
- streamlit/elements/widgets/chat.py +9 -11
- streamlit/elements/widgets/checkbox.py +13 -11
- streamlit/elements/widgets/color_picker.py +14 -10
- streamlit/elements/widgets/data_editor.py +18 -19
- streamlit/elements/widgets/file_uploader.py +15 -10
- streamlit/elements/widgets/multiselect.py +13 -15
- streamlit/elements/widgets/number_input.py +13 -11
- streamlit/elements/widgets/radio.py +13 -15
- streamlit/elements/widgets/select_slider.py +13 -13
- streamlit/elements/widgets/selectbox.py +13 -15
- streamlit/elements/widgets/slider.py +14 -10
- streamlit/elements/widgets/text_widgets.py +21 -17
- streamlit/elements/widgets/time_widgets.py +18 -16
- streamlit/elements/write.py +7 -15
- streamlit/runtime/caching/cache_utils.py +2 -5
- streamlit/runtime/state/common.py +51 -2
- streamlit/runtime/state/session_state.py +2 -1
- streamlit/runtime/state/session_state_proxy.py +1 -1
- streamlit/runtime/state/widgets.py +1 -1
- streamlit/static/asset-manifest.json +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{main.e2ab315a.js → main.28e3c6e9.js} +2 -2
- streamlit/testing/v1/element_tree.py +3 -3
- streamlit/type_util.py +0 -1069
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240704.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240704.dist-info}/RECORD +48 -47
- /streamlit/static/static/js/{main.e2ab315a.js.LICENSE.txt → main.28e3c6e9.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.36.1.dev20240702.data → streamlit_nightly-1.36.1.dev20240704.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240704.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240704.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240704.dist-info}/top_level.txt +0 -0
@@ -23,12 +23,15 @@ from typing_extensions import TypeAlias
|
|
23
23
|
|
24
24
|
from streamlit.elements.form import current_form_id
|
25
25
|
from streamlit.elements.lib.policies import (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
check_widget_policies,
|
27
|
+
maybe_raise_label_warnings,
|
28
|
+
)
|
29
|
+
from streamlit.elements.lib.utils import (
|
30
|
+
Key,
|
31
|
+
LabelVisibility,
|
32
|
+
get_label_visibility_proto_value,
|
33
|
+
to_key,
|
30
34
|
)
|
31
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
32
35
|
from streamlit.errors import StreamlitAPIException
|
33
36
|
from streamlit.js_number import JSNumber, JSNumberBoundsException
|
34
37
|
from streamlit.proto.NumberInput_pb2 import NumberInput as NumberInputProto
|
@@ -42,7 +45,6 @@ from streamlit.runtime.state import (
|
|
42
45
|
register_widget,
|
43
46
|
)
|
44
47
|
from streamlit.runtime.state.common import compute_widget_id
|
45
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
46
48
|
|
47
49
|
if TYPE_CHECKING:
|
48
50
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -284,11 +286,11 @@ class NumberInputMixin:
|
|
284
286
|
) -> Number | None:
|
285
287
|
key = to_key(key)
|
286
288
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
default_value=value if value != "min" else None,
|
289
|
+
check_widget_policies(
|
290
|
+
self.dg,
|
291
|
+
key,
|
292
|
+
on_change,
|
293
|
+
default_value=value if value != "min" else None,
|
292
294
|
)
|
293
295
|
maybe_raise_label_warnings(label, label_visibility)
|
294
296
|
|
@@ -18,16 +18,18 @@ from dataclasses import dataclass
|
|
18
18
|
from textwrap import dedent
|
19
19
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
|
20
20
|
|
21
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
21
22
|
from streamlit.elements.form import current_form_id
|
22
23
|
from streamlit.elements.lib.policies import (
|
23
|
-
|
24
|
-
|
25
|
-
check_fragment_path_policy,
|
26
|
-
check_session_state_rules,
|
24
|
+
check_widget_policies,
|
25
|
+
maybe_raise_label_warnings,
|
27
26
|
)
|
28
27
|
from streamlit.elements.lib.utils import (
|
28
|
+
Key,
|
29
|
+
LabelVisibility,
|
29
30
|
get_label_visibility_proto_value,
|
30
31
|
maybe_coerce_enum,
|
32
|
+
to_key,
|
31
33
|
)
|
32
34
|
from streamlit.errors import StreamlitAPIException
|
33
35
|
from streamlit.proto.Radio_pb2 import Radio as RadioProto
|
@@ -42,14 +44,8 @@ from streamlit.runtime.state import (
|
|
42
44
|
)
|
43
45
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
44
46
|
from streamlit.type_util import (
|
45
|
-
Key,
|
46
|
-
LabelVisibility,
|
47
|
-
OptionSequence,
|
48
47
|
T,
|
49
48
|
check_python_comparable,
|
50
|
-
ensure_indexable,
|
51
|
-
maybe_raise_label_warnings,
|
52
|
-
to_key,
|
53
49
|
)
|
54
50
|
from streamlit.util import index_
|
55
51
|
|
@@ -258,13 +254,15 @@ class RadioMixin:
|
|
258
254
|
) -> T | None:
|
259
255
|
key = to_key(key)
|
260
256
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
257
|
+
check_widget_policies(
|
258
|
+
self.dg,
|
259
|
+
key,
|
260
|
+
on_change,
|
261
|
+
default_value=None if index == 0 else index,
|
262
|
+
)
|
265
263
|
maybe_raise_label_warnings(label, label_visibility)
|
266
264
|
|
267
|
-
opt =
|
265
|
+
opt = convert_anything_to_sequence(options)
|
268
266
|
check_python_comparable(opt)
|
269
267
|
|
270
268
|
id = compute_widget_id(
|
@@ -20,16 +20,19 @@ from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, Tuple, cast
|
|
20
20
|
|
21
21
|
from typing_extensions import TypeGuard
|
22
22
|
|
23
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
23
24
|
from streamlit.elements.form import current_form_id
|
24
25
|
from streamlit.elements.lib.policies import (
|
25
|
-
|
26
|
-
|
27
|
-
check_session_state_rules,
|
26
|
+
check_widget_policies,
|
27
|
+
maybe_raise_label_warnings,
|
28
28
|
)
|
29
29
|
from streamlit.elements.lib.utils import (
|
30
|
+
Key,
|
31
|
+
LabelVisibility,
|
30
32
|
get_label_visibility_proto_value,
|
31
33
|
maybe_coerce_enum,
|
32
34
|
maybe_coerce_enum_sequence,
|
35
|
+
to_key,
|
33
36
|
)
|
34
37
|
from streamlit.errors import StreamlitAPIException
|
35
38
|
from streamlit.proto.Slider_pb2 import Slider as SliderProto
|
@@ -47,14 +50,8 @@ from streamlit.runtime.state.common import (
|
|
47
50
|
save_for_app_testing,
|
48
51
|
)
|
49
52
|
from streamlit.type_util import (
|
50
|
-
Key,
|
51
|
-
LabelVisibility,
|
52
|
-
OptionSequence,
|
53
53
|
T,
|
54
54
|
check_python_comparable,
|
55
|
-
ensure_indexable,
|
56
|
-
maybe_raise_label_warnings,
|
57
|
-
to_key,
|
58
55
|
)
|
59
56
|
from streamlit.util import index_
|
60
57
|
|
@@ -263,12 +260,15 @@ class SelectSliderMixin:
|
|
263
260
|
) -> T | tuple[T, T]:
|
264
261
|
key = to_key(key)
|
265
262
|
|
266
|
-
|
267
|
-
|
268
|
-
|
263
|
+
check_widget_policies(
|
264
|
+
self.dg,
|
265
|
+
key,
|
266
|
+
on_change,
|
267
|
+
default_value=value,
|
268
|
+
)
|
269
269
|
maybe_raise_label_warnings(label, label_visibility)
|
270
270
|
|
271
|
-
opt =
|
271
|
+
opt = convert_anything_to_sequence(options)
|
272
272
|
check_python_comparable(opt)
|
273
273
|
|
274
274
|
if len(opt) == 0:
|
@@ -17,16 +17,18 @@ from dataclasses import dataclass
|
|
17
17
|
from textwrap import dedent
|
18
18
|
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
|
19
19
|
|
20
|
+
from streamlit.dataframe_util import OptionSequence, convert_anything_to_sequence
|
20
21
|
from streamlit.elements.form import current_form_id
|
21
22
|
from streamlit.elements.lib.policies import (
|
22
|
-
|
23
|
-
|
24
|
-
check_fragment_path_policy,
|
25
|
-
check_session_state_rules,
|
23
|
+
check_widget_policies,
|
24
|
+
maybe_raise_label_warnings,
|
26
25
|
)
|
27
26
|
from streamlit.elements.lib.utils import (
|
27
|
+
Key,
|
28
|
+
LabelVisibility,
|
28
29
|
get_label_visibility_proto_value,
|
29
30
|
maybe_coerce_enum,
|
31
|
+
to_key,
|
30
32
|
)
|
31
33
|
from streamlit.errors import StreamlitAPIException
|
32
34
|
from streamlit.proto.Selectbox_pb2 import Selectbox as SelectboxProto
|
@@ -41,14 +43,8 @@ from streamlit.runtime.state import (
|
|
41
43
|
)
|
42
44
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
43
45
|
from streamlit.type_util import (
|
44
|
-
Key,
|
45
|
-
LabelVisibility,
|
46
|
-
OptionSequence,
|
47
46
|
T,
|
48
47
|
check_python_comparable,
|
49
|
-
ensure_indexable,
|
50
|
-
maybe_raise_label_warnings,
|
51
|
-
to_key,
|
52
48
|
)
|
53
49
|
from streamlit.util import index_
|
54
50
|
|
@@ -238,13 +234,15 @@ class SelectboxMixin:
|
|
238
234
|
) -> T | None:
|
239
235
|
key = to_key(key)
|
240
236
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
237
|
+
check_widget_policies(
|
238
|
+
self.dg,
|
239
|
+
key,
|
240
|
+
on_change,
|
241
|
+
default_value=None if index == 0 else index,
|
242
|
+
)
|
245
243
|
maybe_raise_label_warnings(label, label_visibility)
|
246
244
|
|
247
|
-
opt =
|
245
|
+
opt = convert_anything_to_sequence(options)
|
248
246
|
check_python_comparable(opt)
|
249
247
|
|
250
248
|
id = compute_widget_id(
|
@@ -24,12 +24,15 @@ from typing_extensions import TypeAlias
|
|
24
24
|
|
25
25
|
from streamlit.elements.form import current_form_id
|
26
26
|
from streamlit.elements.lib.policies import (
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
check_widget_policies,
|
28
|
+
maybe_raise_label_warnings,
|
29
|
+
)
|
30
|
+
from streamlit.elements.lib.utils import (
|
31
|
+
Key,
|
32
|
+
LabelVisibility,
|
33
|
+
get_label_visibility_proto_value,
|
34
|
+
to_key,
|
31
35
|
)
|
32
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
33
36
|
from streamlit.errors import StreamlitAPIException
|
34
37
|
from streamlit.js_number import JSNumber, JSNumberBoundsException
|
35
38
|
from streamlit.proto.Slider_pb2 import Slider as SliderProto
|
@@ -43,7 +46,6 @@ from streamlit.runtime.state import (
|
|
43
46
|
register_widget,
|
44
47
|
)
|
45
48
|
from streamlit.runtime.state.common import compute_widget_id
|
46
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
47
49
|
|
48
50
|
if TYPE_CHECKING:
|
49
51
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -370,10 +372,12 @@ class SliderMixin:
|
|
370
372
|
) -> SliderReturn:
|
371
373
|
key = to_key(key)
|
372
374
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
375
|
+
check_widget_policies(
|
376
|
+
self.dg,
|
377
|
+
key,
|
378
|
+
on_change,
|
379
|
+
default_value=value,
|
380
|
+
)
|
377
381
|
maybe_raise_label_warnings(label, label_visibility)
|
378
382
|
|
379
383
|
id = compute_widget_id(
|
@@ -20,12 +20,15 @@ from typing import TYPE_CHECKING, Literal, cast, overload
|
|
20
20
|
|
21
21
|
from streamlit.elements.form import current_form_id
|
22
22
|
from streamlit.elements.lib.policies import (
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
check_widget_policies,
|
24
|
+
maybe_raise_label_warnings,
|
25
|
+
)
|
26
|
+
from streamlit.elements.lib.utils import (
|
27
|
+
Key,
|
28
|
+
LabelVisibility,
|
29
|
+
get_label_visibility_proto_value,
|
30
|
+
to_key,
|
27
31
|
)
|
28
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
29
32
|
from streamlit.errors import StreamlitAPIException
|
30
33
|
from streamlit.proto.TextArea_pb2 import TextArea as TextAreaProto
|
31
34
|
from streamlit.proto.TextInput_pb2 import TextInput as TextInputProto
|
@@ -40,15 +43,12 @@ from streamlit.runtime.state import (
|
|
40
43
|
)
|
41
44
|
from streamlit.runtime.state.common import compute_widget_id
|
42
45
|
from streamlit.type_util import (
|
43
|
-
Key,
|
44
|
-
LabelVisibility,
|
45
46
|
SupportsStr,
|
46
|
-
maybe_raise_label_warnings,
|
47
|
-
to_key,
|
48
47
|
)
|
49
48
|
|
50
49
|
if TYPE_CHECKING:
|
51
50
|
from streamlit.delta_generator import DeltaGenerator
|
51
|
+
from streamlit.type_util import SupportsStr
|
52
52
|
|
53
53
|
|
54
54
|
@dataclass
|
@@ -261,10 +261,12 @@ class TextWidgetsMixin:
|
|
261
261
|
) -> str | None:
|
262
262
|
key = to_key(key)
|
263
263
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
264
|
+
check_widget_policies(
|
265
|
+
self.dg,
|
266
|
+
key,
|
267
|
+
on_change,
|
268
|
+
default_value=None if value == "" else value,
|
269
|
+
)
|
268
270
|
maybe_raise_label_warnings(label, label_visibility)
|
269
271
|
|
270
272
|
# Make sure value is always string or None:
|
@@ -531,10 +533,12 @@ class TextWidgetsMixin:
|
|
531
533
|
) -> str | None:
|
532
534
|
key = to_key(key)
|
533
535
|
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
536
|
+
check_widget_policies(
|
537
|
+
self.dg,
|
538
|
+
key,
|
539
|
+
on_change,
|
540
|
+
default_value=None if value == "" else value,
|
541
|
+
)
|
538
542
|
maybe_raise_label_warnings(label, label_visibility)
|
539
543
|
|
540
544
|
value = str(value) if value is not None else None
|
@@ -34,12 +34,15 @@ from typing_extensions import TypeAlias
|
|
34
34
|
|
35
35
|
from streamlit.elements.form import current_form_id
|
36
36
|
from streamlit.elements.lib.policies import (
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
check_widget_policies,
|
38
|
+
maybe_raise_label_warnings,
|
39
|
+
)
|
40
|
+
from streamlit.elements.lib.utils import (
|
41
|
+
Key,
|
42
|
+
LabelVisibility,
|
43
|
+
get_label_visibility_proto_value,
|
44
|
+
to_key,
|
41
45
|
)
|
42
|
-
from streamlit.elements.lib.utils import get_label_visibility_proto_value
|
43
46
|
from streamlit.errors import StreamlitAPIException
|
44
47
|
from streamlit.proto.DateInput_pb2 import DateInput as DateInputProto
|
45
48
|
from streamlit.proto.TimeInput_pb2 import TimeInput as TimeInputProto
|
@@ -54,7 +57,6 @@ from streamlit.runtime.state import (
|
|
54
57
|
)
|
55
58
|
from streamlit.runtime.state.common import compute_widget_id
|
56
59
|
from streamlit.time_util import adjust_years
|
57
|
-
from streamlit.type_util import Key, LabelVisibility, maybe_raise_label_warnings, to_key
|
58
60
|
|
59
61
|
if TYPE_CHECKING:
|
60
62
|
from streamlit.delta_generator import DeltaGenerator
|
@@ -429,11 +431,11 @@ class TimeWidgetsMixin:
|
|
429
431
|
) -> time | None:
|
430
432
|
key = to_key(key)
|
431
433
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
default_value=value if value != "now" else None,
|
434
|
+
check_widget_policies(
|
435
|
+
self.dg,
|
436
|
+
key,
|
437
|
+
on_change,
|
438
|
+
default_value=value if value != "now" else None,
|
437
439
|
)
|
438
440
|
maybe_raise_label_warnings(label, label_visibility)
|
439
441
|
|
@@ -694,11 +696,11 @@ class TimeWidgetsMixin:
|
|
694
696
|
) -> DateWidgetReturn:
|
695
697
|
key = to_key(key)
|
696
698
|
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
default_value=value if value != "default_value_today" else None,
|
699
|
+
check_widget_policies(
|
700
|
+
self.dg,
|
701
|
+
key,
|
702
|
+
on_change,
|
703
|
+
default_value=value if value != "default_value_today" else None,
|
702
704
|
)
|
703
705
|
maybe_raise_label_warnings(label, label_visibility)
|
704
706
|
|
streamlit/elements/write.py
CHANGED
@@ -21,7 +21,7 @@ import types
|
|
21
21
|
from io import StringIO
|
22
22
|
from typing import TYPE_CHECKING, Any, Callable, Final, Generator, Iterable, List, cast
|
23
23
|
|
24
|
-
from streamlit import type_util
|
24
|
+
from streamlit import dataframe_util, type_util
|
25
25
|
from streamlit.errors import StreamlitAPIException
|
26
26
|
from streamlit.logger import get_logger
|
27
27
|
from streamlit.runtime.metrics_util import gather_metrics
|
@@ -128,7 +128,7 @@ class WriteMixin:
|
|
128
128
|
|
129
129
|
# Just apply some basic checks for common iterable types that should
|
130
130
|
# not be passed in here.
|
131
|
-
if isinstance(stream, str) or
|
131
|
+
if isinstance(stream, str) or dataframe_util.is_dataframe_like(stream):
|
132
132
|
raise StreamlitAPIException(
|
133
133
|
"`st.write_stream` expects a generator or stream-like object as input "
|
134
134
|
f"not {type(stream)}. Please use `st.write` instead for "
|
@@ -401,22 +401,14 @@ class WriteMixin:
|
|
401
401
|
item()
|
402
402
|
else:
|
403
403
|
self.write(item, unsafe_allow_html=unsafe_allow_html)
|
404
|
-
elif type_util.is_unevaluated_data_object(
|
405
|
-
arg
|
406
|
-
) or type_util.is_snowpark_row_list(arg):
|
407
|
-
flush_buffer()
|
408
|
-
self.dg.dataframe(arg)
|
409
|
-
elif type_util.is_dataframe_like(arg):
|
410
|
-
import numpy as np
|
411
|
-
|
412
|
-
flush_buffer()
|
413
|
-
if len(np.shape(arg)) > 2:
|
414
|
-
self.dg.text(arg)
|
415
|
-
else:
|
416
|
-
self.dg.dataframe(arg)
|
417
404
|
elif isinstance(arg, Exception):
|
418
405
|
flush_buffer()
|
419
406
|
self.dg.exception(arg)
|
407
|
+
elif dataframe_util.is_dataframe_like(
|
408
|
+
arg
|
409
|
+
) or dataframe_util.is_snowpark_row_list(arg):
|
410
|
+
flush_buffer()
|
411
|
+
self.dg.dataframe(arg)
|
420
412
|
elif type_util.is_altair_chart(arg):
|
421
413
|
flush_buffer()
|
422
414
|
self.dg.altair_chart(arg)
|
@@ -26,6 +26,7 @@ from collections import defaultdict
|
|
26
26
|
from typing import TYPE_CHECKING, Any, Callable, Final
|
27
27
|
|
28
28
|
from streamlit import type_util
|
29
|
+
from streamlit.dataframe_util import is_unevaluated_data_object
|
29
30
|
from streamlit.elements.spinner import spinner
|
30
31
|
from streamlit.logger import get_logger
|
31
32
|
from streamlit.runtime.caching.cache_errors import (
|
@@ -44,7 +45,6 @@ from streamlit.runtime.caching.cached_message_replay import (
|
|
44
45
|
replay_cached_messages,
|
45
46
|
)
|
46
47
|
from streamlit.runtime.caching.hashing import HashFuncsDict, update_hash
|
47
|
-
from streamlit.type_util import UNEVALUATED_DATAFRAME_TYPES
|
48
48
|
from streamlit.util import HASHLIB_KWARGS
|
49
49
|
|
50
50
|
if TYPE_CHECKING:
|
@@ -289,10 +289,7 @@ class CachedFunc:
|
|
289
289
|
# An exception was thrown while we tried to write to the cache. Report it to the user.
|
290
290
|
# (We catch `RuntimeError` here because it will be raised by Apache Spark if we do not
|
291
291
|
# collect dataframe before using `st.cache_data`.)
|
292
|
-
if
|
293
|
-
type_util.is_type(computed_value, type_name)
|
294
|
-
for type_name in UNEVALUATED_DATAFRAME_TYPES
|
295
|
-
]:
|
292
|
+
if is_unevaluated_data_object(computed_value):
|
296
293
|
# If the returned value is an unevaluated dataframe, raise an error.
|
297
294
|
# Unevaluated dataframes are not yet in the local memory, which also
|
298
295
|
# means they cannot be properly cached (serialized).
|
@@ -27,13 +27,16 @@ from typing import (
|
|
27
27
|
Final,
|
28
28
|
Generic,
|
29
29
|
Iterable,
|
30
|
+
Literal,
|
30
31
|
Tuple,
|
31
32
|
TypeVar,
|
32
33
|
Union,
|
34
|
+
cast,
|
35
|
+
get_args,
|
33
36
|
)
|
34
37
|
|
35
38
|
from google.protobuf.message import Message
|
36
|
-
from typing_extensions import TypeAlias
|
39
|
+
from typing_extensions import TypeAlias, TypeGuard
|
37
40
|
|
38
41
|
from streamlit import config, util
|
39
42
|
from streamlit.errors import StreamlitAPIException
|
@@ -64,7 +67,6 @@ if TYPE_CHECKING:
|
|
64
67
|
|
65
68
|
from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext
|
66
69
|
from streamlit.runtime.state.widgets import NoValue
|
67
|
-
from streamlit.type_util import ValueFieldName
|
68
70
|
|
69
71
|
|
70
72
|
# Protobuf types for all widgets.
|
@@ -110,6 +112,53 @@ WidgetCallback: TypeAlias = Callable[..., None]
|
|
110
112
|
WidgetDeserializer: TypeAlias = Callable[[Any, str], T]
|
111
113
|
WidgetSerializer: TypeAlias = Callable[[T], Any]
|
112
114
|
|
115
|
+
# The array value field names are part of the larger set of possible value
|
116
|
+
# field names. See the explanation for said set below. The message types
|
117
|
+
# associated with these fields are distinguished by storing data in a `data`
|
118
|
+
# field in their messages, meaning they need special treatment in certain
|
119
|
+
# circumstances. Hence, they need their own, dedicated, sub-type.
|
120
|
+
ArrayValueFieldName: TypeAlias = Literal[
|
121
|
+
"double_array_value",
|
122
|
+
"int_array_value",
|
123
|
+
"string_array_value",
|
124
|
+
]
|
125
|
+
|
126
|
+
# A frozenset containing the allowed values of the ArrayValueFieldName type.
|
127
|
+
# Useful for membership checking.
|
128
|
+
_ARRAY_VALUE_FIELD_NAMES: Final = frozenset(
|
129
|
+
cast(
|
130
|
+
"tuple[ArrayValueFieldName, ...]",
|
131
|
+
# NOTE: get_args is not recursive, so this only works as long as
|
132
|
+
# ArrayValueFieldName remains flat.
|
133
|
+
get_args(ArrayValueFieldName),
|
134
|
+
)
|
135
|
+
)
|
136
|
+
|
137
|
+
# These are the possible field names that can be set in the `value` oneof-field
|
138
|
+
# of the WidgetState message (schema found in .proto/WidgetStates.proto).
|
139
|
+
# We need these as a literal type to ensure correspondence with the protobuf
|
140
|
+
# schema in certain parts of the python code.
|
141
|
+
# TODO(harahu): It would be preferable if this type was automatically derived
|
142
|
+
# from the protobuf schema, rather than manually maintained. Not sure how to
|
143
|
+
# achieve that, though.
|
144
|
+
ValueFieldName: TypeAlias = Literal[
|
145
|
+
ArrayValueFieldName,
|
146
|
+
"arrow_value",
|
147
|
+
"bool_value",
|
148
|
+
"bytes_value",
|
149
|
+
"double_value",
|
150
|
+
"file_uploader_state_value",
|
151
|
+
"int_value",
|
152
|
+
"json_value",
|
153
|
+
"string_value",
|
154
|
+
"trigger_value",
|
155
|
+
"string_trigger_value",
|
156
|
+
]
|
157
|
+
|
158
|
+
|
159
|
+
def is_array_value_field_name(obj: object) -> TypeGuard[ArrayValueFieldName]:
|
160
|
+
return obj in _ARRAY_VALUE_FIELD_NAMES
|
161
|
+
|
113
162
|
|
114
163
|
@dataclass(frozen=True)
|
115
164
|
class WidgetMetadata(Generic[T]):
|
@@ -40,13 +40,14 @@ from streamlit.proto.WidgetStates_pb2 import WidgetStates as WidgetStatesProto
|
|
40
40
|
from streamlit.runtime.state.common import (
|
41
41
|
RegisterWidgetResult,
|
42
42
|
T,
|
43
|
+
ValueFieldName,
|
43
44
|
WidgetMetadata,
|
45
|
+
is_array_value_field_name,
|
44
46
|
is_keyed_widget_id,
|
45
47
|
is_widget_id,
|
46
48
|
)
|
47
49
|
from streamlit.runtime.state.query_params import QueryParams
|
48
50
|
from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
|
49
|
-
from streamlit.type_util import ValueFieldName, is_array_value_field_name
|
50
51
|
|
51
52
|
if TYPE_CHECKING:
|
52
53
|
from streamlit.runtime.session_manager import SessionManager
|
@@ -18,11 +18,11 @@ from typing import Any, Final, Iterator, MutableMapping
|
|
18
18
|
|
19
19
|
from streamlit import logger as _logger
|
20
20
|
from streamlit import runtime
|
21
|
+
from streamlit.elements.lib.utils import Key
|
21
22
|
from streamlit.runtime.metrics_util import gather_metrics
|
22
23
|
from streamlit.runtime.state.common import require_valid_user_key
|
23
24
|
from streamlit.runtime.state.safe_session_state import SafeSessionState
|
24
25
|
from streamlit.runtime.state.session_state import SessionState
|
25
|
-
from streamlit.type_util import Key
|
26
26
|
|
27
27
|
_LOGGER: Final = _logger.get_logger(__name__)
|
28
28
|
|
@@ -25,6 +25,7 @@ from streamlit.proto.WidgetStates_pb2 import WidgetState, WidgetStates
|
|
25
25
|
from streamlit.runtime.state.common import (
|
26
26
|
RegisterWidgetResult,
|
27
27
|
T,
|
28
|
+
ValueFieldName,
|
28
29
|
WidgetArgs,
|
29
30
|
WidgetCallback,
|
30
31
|
WidgetDeserializer,
|
@@ -37,7 +38,6 @@ from streamlit.runtime.state.common import (
|
|
37
38
|
|
38
39
|
if TYPE_CHECKING:
|
39
40
|
from streamlit.runtime.scriptrunner import ScriptRunContext
|
40
|
-
from streamlit.type_util import ValueFieldName
|
41
41
|
|
42
42
|
|
43
43
|
ElementType: TypeAlias = str
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.29bca1b5.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.28e3c6e9.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.29bca1b5.css",
|
154
|
-
"static/js/main.
|
154
|
+
"static/js/main.28e3c6e9.js"
|
155
155
|
]
|
156
156
|
}
|
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.28e3c6e9.js"></script><link href="./static/css/main.29bca1b5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|