streamlit-nightly 1.43.2.dev20250307__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 +306 -0
- streamlit/__main__.py +20 -0
- streamlit/auth_util.py +218 -0
- streamlit/cli_util.py +105 -0
- streamlit/column_config.py +56 -0
- streamlit/commands/__init__.py +13 -0
- streamlit/commands/echo.py +126 -0
- streamlit/commands/execution_control.py +238 -0
- streamlit/commands/experimental_query_params.py +169 -0
- streamlit/commands/logo.py +189 -0
- streamlit/commands/navigation.py +385 -0
- streamlit/commands/page_config.py +311 -0
- streamlit/components/__init__.py +13 -0
- streamlit/components/lib/__init__.py +13 -0
- streamlit/components/lib/local_component_registry.py +84 -0
- streamlit/components/types/__init__.py +13 -0
- streamlit/components/types/base_component_registry.py +99 -0
- streamlit/components/types/base_custom_component.py +150 -0
- streamlit/components/v1/__init__.py +31 -0
- streamlit/components/v1/component_arrow.py +141 -0
- streamlit/components/v1/component_registry.py +130 -0
- streamlit/components/v1/components.py +38 -0
- streamlit/components/v1/custom_component.py +243 -0
- streamlit/config.py +1513 -0
- streamlit/config_option.py +311 -0
- streamlit/config_util.py +177 -0
- streamlit/connections/__init__.py +28 -0
- streamlit/connections/base_connection.py +174 -0
- streamlit/connections/snowflake_connection.py +562 -0
- streamlit/connections/snowpark_connection.py +213 -0
- streamlit/connections/sql_connection.py +425 -0
- streamlit/connections/util.py +97 -0
- streamlit/cursor.py +210 -0
- streamlit/dataframe_util.py +1416 -0
- streamlit/delta_generator.py +602 -0
- streamlit/delta_generator_singletons.py +204 -0
- streamlit/deprecation_util.py +209 -0
- streamlit/development.py +21 -0
- streamlit/elements/__init__.py +13 -0
- streamlit/elements/alert.py +234 -0
- streamlit/elements/arrow.py +962 -0
- streamlit/elements/balloons.py +47 -0
- streamlit/elements/bokeh_chart.py +133 -0
- streamlit/elements/code.py +114 -0
- streamlit/elements/deck_gl_json_chart.py +546 -0
- streamlit/elements/dialog_decorator.py +267 -0
- streamlit/elements/doc_string.py +558 -0
- streamlit/elements/empty.py +130 -0
- streamlit/elements/exception.py +331 -0
- streamlit/elements/form.py +354 -0
- streamlit/elements/graphviz_chart.py +150 -0
- streamlit/elements/heading.py +302 -0
- streamlit/elements/html.py +105 -0
- streamlit/elements/iframe.py +191 -0
- streamlit/elements/image.py +196 -0
- streamlit/elements/json.py +139 -0
- streamlit/elements/layouts.py +879 -0
- streamlit/elements/lib/__init__.py +13 -0
- streamlit/elements/lib/built_in_chart_utils.py +1157 -0
- streamlit/elements/lib/color_util.py +263 -0
- streamlit/elements/lib/column_config_utils.py +542 -0
- streamlit/elements/lib/column_types.py +2188 -0
- streamlit/elements/lib/dialog.py +147 -0
- streamlit/elements/lib/dicttools.py +154 -0
- streamlit/elements/lib/event_utils.py +37 -0
- streamlit/elements/lib/file_uploader_utils.py +66 -0
- streamlit/elements/lib/form_utils.py +77 -0
- streamlit/elements/lib/image_utils.py +441 -0
- streamlit/elements/lib/js_number.py +105 -0
- streamlit/elements/lib/mutable_status_container.py +183 -0
- streamlit/elements/lib/options_selector_utils.py +250 -0
- streamlit/elements/lib/pandas_styler_utils.py +274 -0
- streamlit/elements/lib/policies.py +194 -0
- streamlit/elements/lib/streamlit_plotly_theme.py +207 -0
- streamlit/elements/lib/subtitle_utils.py +176 -0
- streamlit/elements/lib/utils.py +250 -0
- streamlit/elements/map.py +508 -0
- streamlit/elements/markdown.py +277 -0
- streamlit/elements/media.py +793 -0
- streamlit/elements/metric.py +301 -0
- streamlit/elements/plotly_chart.py +546 -0
- streamlit/elements/progress.py +156 -0
- streamlit/elements/pyplot.py +194 -0
- streamlit/elements/snow.py +47 -0
- streamlit/elements/spinner.py +113 -0
- streamlit/elements/text.py +76 -0
- streamlit/elements/toast.py +98 -0
- streamlit/elements/vega_charts.py +1984 -0
- streamlit/elements/widgets/__init__.py +13 -0
- streamlit/elements/widgets/audio_input.py +310 -0
- streamlit/elements/widgets/button.py +1123 -0
- streamlit/elements/widgets/button_group.py +1008 -0
- streamlit/elements/widgets/camera_input.py +263 -0
- streamlit/elements/widgets/chat.py +647 -0
- streamlit/elements/widgets/checkbox.py +352 -0
- streamlit/elements/widgets/color_picker.py +265 -0
- streamlit/elements/widgets/data_editor.py +983 -0
- streamlit/elements/widgets/file_uploader.py +486 -0
- streamlit/elements/widgets/multiselect.py +338 -0
- streamlit/elements/widgets/number_input.py +545 -0
- streamlit/elements/widgets/radio.py +407 -0
- streamlit/elements/widgets/select_slider.py +437 -0
- streamlit/elements/widgets/selectbox.py +366 -0
- streamlit/elements/widgets/slider.py +880 -0
- streamlit/elements/widgets/text_widgets.py +628 -0
- streamlit/elements/widgets/time_widgets.py +970 -0
- streamlit/elements/write.py +574 -0
- streamlit/emojis.py +34 -0
- streamlit/env_util.py +61 -0
- streamlit/error_util.py +105 -0
- streamlit/errors.py +452 -0
- streamlit/external/__init__.py +13 -0
- streamlit/external/langchain/__init__.py +23 -0
- streamlit/external/langchain/streamlit_callback_handler.py +406 -0
- streamlit/file_util.py +247 -0
- streamlit/git_util.py +173 -0
- streamlit/hello/__init__.py +13 -0
- streamlit/hello/animation_demo.py +82 -0
- streamlit/hello/dataframe_demo.py +71 -0
- streamlit/hello/hello.py +37 -0
- streamlit/hello/mapping_demo.py +114 -0
- streamlit/hello/plotting_demo.py +55 -0
- streamlit/hello/streamlit_app.py +55 -0
- streamlit/hello/utils.py +28 -0
- streamlit/logger.py +130 -0
- streamlit/material_icon_names.py +25 -0
- streamlit/navigation/__init__.py +13 -0
- streamlit/navigation/page.py +302 -0
- streamlit/net_util.py +125 -0
- streamlit/platform.py +33 -0
- streamlit/proto/Alert_pb2.py +29 -0
- streamlit/proto/Alert_pb2.pyi +90 -0
- streamlit/proto/AppPage_pb2.py +27 -0
- streamlit/proto/AppPage_pb2.pyi +64 -0
- streamlit/proto/ArrowNamedDataSet_pb2.py +28 -0
- streamlit/proto/ArrowNamedDataSet_pb2.pyi +57 -0
- streamlit/proto/ArrowVegaLiteChart_pb2.py +29 -0
- streamlit/proto/ArrowVegaLiteChart_pb2.pyi +84 -0
- streamlit/proto/Arrow_pb2.py +33 -0
- streamlit/proto/Arrow_pb2.pyi +188 -0
- streamlit/proto/AudioInput_pb2.py +28 -0
- streamlit/proto/AudioInput_pb2.pyi +58 -0
- streamlit/proto/Audio_pb2.py +27 -0
- streamlit/proto/Audio_pb2.pyi +58 -0
- streamlit/proto/AuthRedirect_pb2.py +27 -0
- streamlit/proto/AuthRedirect_pb2.pyi +41 -0
- streamlit/proto/AutoRerun_pb2.py +27 -0
- streamlit/proto/AutoRerun_pb2.pyi +45 -0
- streamlit/proto/BackMsg_pb2.py +29 -0
- streamlit/proto/BackMsg_pb2.pyi +105 -0
- streamlit/proto/Balloons_pb2.py +27 -0
- streamlit/proto/Balloons_pb2.pyi +43 -0
- streamlit/proto/Block_pb2.py +53 -0
- streamlit/proto/Block_pb2.pyi +322 -0
- streamlit/proto/BokehChart_pb2.py +27 -0
- streamlit/proto/BokehChart_pb2.pyi +49 -0
- streamlit/proto/ButtonGroup_pb2.py +36 -0
- streamlit/proto/ButtonGroup_pb2.pyi +169 -0
- streamlit/proto/Button_pb2.py +27 -0
- streamlit/proto/Button_pb2.pyi +71 -0
- streamlit/proto/CameraInput_pb2.py +28 -0
- streamlit/proto/CameraInput_pb2.pyi +58 -0
- streamlit/proto/ChatInput_pb2.py +31 -0
- streamlit/proto/ChatInput_pb2.pyi +111 -0
- streamlit/proto/Checkbox_pb2.py +30 -0
- streamlit/proto/Checkbox_pb2.pyi +90 -0
- streamlit/proto/ClientState_pb2.py +30 -0
- streamlit/proto/ClientState_pb2.pyi +90 -0
- streamlit/proto/Code_pb2.py +27 -0
- streamlit/proto/Code_pb2.pyi +55 -0
- streamlit/proto/ColorPicker_pb2.py +28 -0
- streamlit/proto/ColorPicker_pb2.pyi +67 -0
- streamlit/proto/Common_pb2.py +51 -0
- streamlit/proto/Common_pb2.pyi +293 -0
- streamlit/proto/Components_pb2.py +35 -0
- streamlit/proto/Components_pb2.pyi +172 -0
- streamlit/proto/DataFrame_pb2.py +56 -0
- streamlit/proto/DataFrame_pb2.pyi +397 -0
- streamlit/proto/DateInput_pb2.py +28 -0
- streamlit/proto/DateInput_pb2.pyi +83 -0
- streamlit/proto/DeckGlJsonChart_pb2.py +29 -0
- streamlit/proto/DeckGlJsonChart_pb2.pyi +102 -0
- streamlit/proto/Delta_pb2.py +31 -0
- streamlit/proto/Delta_pb2.pyi +74 -0
- streamlit/proto/DocString_pb2.py +29 -0
- streamlit/proto/DocString_pb2.pyi +93 -0
- streamlit/proto/DownloadButton_pb2.py +27 -0
- streamlit/proto/DownloadButton_pb2.pyi +70 -0
- streamlit/proto/Element_pb2.py +78 -0
- streamlit/proto/Element_pb2.pyi +312 -0
- streamlit/proto/Empty_pb2.py +27 -0
- streamlit/proto/Empty_pb2.pyi +36 -0
- streamlit/proto/Exception_pb2.py +27 -0
- streamlit/proto/Exception_pb2.pyi +72 -0
- streamlit/proto/Favicon_pb2.py +27 -0
- streamlit/proto/Favicon_pb2.pyi +40 -0
- streamlit/proto/FileUploader_pb2.py +28 -0
- streamlit/proto/FileUploader_pb2.pyi +78 -0
- streamlit/proto/ForwardMsg_pb2.py +53 -0
- streamlit/proto/ForwardMsg_pb2.pyi +293 -0
- streamlit/proto/GitInfo_pb2.py +29 -0
- streamlit/proto/GitInfo_pb2.pyi +83 -0
- streamlit/proto/GraphVizChart_pb2.py +27 -0
- streamlit/proto/GraphVizChart_pb2.pyi +53 -0
- streamlit/proto/Heading_pb2.py +27 -0
- streamlit/proto/Heading_pb2.pyi +56 -0
- streamlit/proto/Html_pb2.py +27 -0
- streamlit/proto/Html_pb2.pyi +42 -0
- streamlit/proto/IFrame_pb2.py +27 -0
- streamlit/proto/IFrame_pb2.pyi +59 -0
- streamlit/proto/Image_pb2.py +29 -0
- streamlit/proto/Image_pb2.pyi +84 -0
- streamlit/proto/Json_pb2.py +27 -0
- streamlit/proto/Json_pb2.pyi +53 -0
- streamlit/proto/LabelVisibilityMessage_pb2.py +29 -0
- streamlit/proto/LabelVisibilityMessage_pb2.pyi +68 -0
- streamlit/proto/LinkButton_pb2.py +27 -0
- streamlit/proto/LinkButton_pb2.pyi +58 -0
- streamlit/proto/Logo_pb2.py +27 -0
- streamlit/proto/Logo_pb2.pyi +51 -0
- streamlit/proto/Markdown_pb2.py +29 -0
- streamlit/proto/Markdown_pb2.pyi +86 -0
- streamlit/proto/Metric_pb2.py +32 -0
- streamlit/proto/Metric_pb2.pyi +101 -0
- streamlit/proto/MetricsEvent_pb2.py +30 -0
- streamlit/proto/MetricsEvent_pb2.pyi +200 -0
- streamlit/proto/MultiSelect_pb2.py +28 -0
- streamlit/proto/MultiSelect_pb2.pyi +81 -0
- streamlit/proto/NamedDataSet_pb2.py +28 -0
- streamlit/proto/NamedDataSet_pb2.pyi +59 -0
- streamlit/proto/Navigation_pb2.py +30 -0
- streamlit/proto/Navigation_pb2.pyi +84 -0
- streamlit/proto/NewSession_pb2.py +51 -0
- streamlit/proto/NewSession_pb2.pyi +481 -0
- streamlit/proto/NumberInput_pb2.py +30 -0
- streamlit/proto/NumberInput_pb2.pyi +121 -0
- streamlit/proto/PageConfig_pb2.py +33 -0
- streamlit/proto/PageConfig_pb2.pyi +126 -0
- streamlit/proto/PageInfo_pb2.py +27 -0
- streamlit/proto/PageInfo_pb2.pyi +43 -0
- streamlit/proto/PageLink_pb2.py +27 -0
- streamlit/proto/PageLink_pb2.pyi +63 -0
- streamlit/proto/PageNotFound_pb2.py +27 -0
- streamlit/proto/PageNotFound_pb2.pyi +42 -0
- streamlit/proto/PageProfile_pb2.py +31 -0
- streamlit/proto/PageProfile_pb2.pyi +127 -0
- streamlit/proto/PagesChanged_pb2.py +28 -0
- streamlit/proto/PagesChanged_pb2.pyi +48 -0
- streamlit/proto/ParentMessage_pb2.py +27 -0
- streamlit/proto/ParentMessage_pb2.pyi +46 -0
- streamlit/proto/PlotlyChart_pb2.py +31 -0
- streamlit/proto/PlotlyChart_pb2.pyi +131 -0
- streamlit/proto/Progress_pb2.py +27 -0
- streamlit/proto/Progress_pb2.pyi +43 -0
- streamlit/proto/Radio_pb2.py +28 -0
- streamlit/proto/Radio_pb2.pyi +84 -0
- streamlit/proto/RootContainer_pb2.py +27 -0
- streamlit/proto/RootContainer_pb2.pyi +56 -0
- streamlit/proto/Selectbox_pb2.py +28 -0
- streamlit/proto/Selectbox_pb2.pyi +80 -0
- streamlit/proto/SessionEvent_pb2.py +28 -0
- streamlit/proto/SessionEvent_pb2.pyi +62 -0
- streamlit/proto/SessionStatus_pb2.py +27 -0
- streamlit/proto/SessionStatus_pb2.pyi +57 -0
- streamlit/proto/Skeleton_pb2.py +29 -0
- streamlit/proto/Skeleton_pb2.pyi +71 -0
- streamlit/proto/Slider_pb2.py +32 -0
- streamlit/proto/Slider_pb2.pyi +142 -0
- streamlit/proto/Snow_pb2.py +27 -0
- streamlit/proto/Snow_pb2.pyi +43 -0
- streamlit/proto/Spinner_pb2.py +27 -0
- streamlit/proto/Spinner_pb2.pyi +49 -0
- streamlit/proto/TextArea_pb2.py +28 -0
- streamlit/proto/TextArea_pb2.pyi +80 -0
- streamlit/proto/TextInput_pb2.py +30 -0
- streamlit/proto/TextInput_pb2.pyi +107 -0
- streamlit/proto/Text_pb2.py +27 -0
- streamlit/proto/Text_pb2.pyi +46 -0
- streamlit/proto/TimeInput_pb2.py +28 -0
- streamlit/proto/TimeInput_pb2.pyi +74 -0
- streamlit/proto/Toast_pb2.py +27 -0
- streamlit/proto/Toast_pb2.pyi +45 -0
- streamlit/proto/VegaLiteChart_pb2.py +29 -0
- streamlit/proto/VegaLiteChart_pb2.pyi +71 -0
- streamlit/proto/Video_pb2.py +31 -0
- streamlit/proto/Video_pb2.pyi +117 -0
- streamlit/proto/WidgetStates_pb2.py +31 -0
- streamlit/proto/WidgetStates_pb2.pyi +126 -0
- streamlit/proto/__init__.py +15 -0
- streamlit/proto/openmetrics_data_model_pb2.py +60 -0
- streamlit/proto/openmetrics_data_model_pb2.pyi +522 -0
- streamlit/py.typed +0 -0
- streamlit/runtime/__init__.py +50 -0
- streamlit/runtime/app_session.py +982 -0
- streamlit/runtime/caching/__init__.py +98 -0
- streamlit/runtime/caching/cache_data_api.py +665 -0
- streamlit/runtime/caching/cache_errors.py +142 -0
- streamlit/runtime/caching/cache_resource_api.py +527 -0
- streamlit/runtime/caching/cache_type.py +33 -0
- streamlit/runtime/caching/cache_utils.py +523 -0
- streamlit/runtime/caching/cached_message_replay.py +290 -0
- streamlit/runtime/caching/hashing.py +637 -0
- streamlit/runtime/caching/legacy_cache_api.py +169 -0
- streamlit/runtime/caching/storage/__init__.py +29 -0
- streamlit/runtime/caching/storage/cache_storage_protocol.py +239 -0
- streamlit/runtime/caching/storage/dummy_cache_storage.py +60 -0
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +145 -0
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +223 -0
- streamlit/runtime/connection_factory.py +436 -0
- streamlit/runtime/context.py +280 -0
- streamlit/runtime/credentials.py +364 -0
- streamlit/runtime/forward_msg_cache.py +296 -0
- streamlit/runtime/forward_msg_queue.py +240 -0
- streamlit/runtime/fragment.py +477 -0
- streamlit/runtime/media_file_manager.py +234 -0
- streamlit/runtime/media_file_storage.py +143 -0
- streamlit/runtime/memory_media_file_storage.py +181 -0
- streamlit/runtime/memory_session_storage.py +77 -0
- streamlit/runtime/memory_uploaded_file_manager.py +138 -0
- streamlit/runtime/metrics_util.py +486 -0
- streamlit/runtime/pages_manager.py +165 -0
- streamlit/runtime/runtime.py +792 -0
- streamlit/runtime/runtime_util.py +106 -0
- streamlit/runtime/script_data.py +46 -0
- streamlit/runtime/scriptrunner/__init__.py +38 -0
- streamlit/runtime/scriptrunner/exec_code.py +159 -0
- streamlit/runtime/scriptrunner/magic.py +273 -0
- streamlit/runtime/scriptrunner/magic_funcs.py +32 -0
- streamlit/runtime/scriptrunner/script_cache.py +89 -0
- streamlit/runtime/scriptrunner/script_runner.py +756 -0
- streamlit/runtime/scriptrunner_utils/__init__.py +19 -0
- streamlit/runtime/scriptrunner_utils/exceptions.py +48 -0
- streamlit/runtime/scriptrunner_utils/script_requests.py +307 -0
- streamlit/runtime/scriptrunner_utils/script_run_context.py +287 -0
- streamlit/runtime/secrets.py +534 -0
- streamlit/runtime/session_manager.py +394 -0
- streamlit/runtime/state/__init__.py +41 -0
- streamlit/runtime/state/common.py +191 -0
- streamlit/runtime/state/query_params.py +205 -0
- streamlit/runtime/state/query_params_proxy.py +218 -0
- streamlit/runtime/state/safe_session_state.py +138 -0
- streamlit/runtime/state/session_state.py +772 -0
- streamlit/runtime/state/session_state_proxy.py +153 -0
- streamlit/runtime/state/widgets.py +135 -0
- streamlit/runtime/stats.py +109 -0
- streamlit/runtime/uploaded_file_manager.py +148 -0
- streamlit/runtime/websocket_session_manager.py +167 -0
- streamlit/source_util.py +98 -0
- streamlit/static/favicon.png +0 -0
- streamlit/static/index.html +61 -0
- streamlit/static/static/css/index.Bmkmz40k.css +1 -0
- streamlit/static/static/css/index.DpJG_94W.css +1 -0
- streamlit/static/static/css/index.DzuxGC_t.css +1 -0
- streamlit/static/static/js/FileDownload.esm.Bp9m5jrx.js +1 -0
- streamlit/static/static/js/FileHelper.D_3pbilj.js +5 -0
- streamlit/static/static/js/FormClearHelper.Ct2rwLXo.js +1 -0
- streamlit/static/static/js/Hooks.BKdzj5MJ.js +1 -0
- streamlit/static/static/js/InputInstructions.DB3QGNJP.js +1 -0
- streamlit/static/static/js/ProgressBar.D40A5xc2.js +2 -0
- streamlit/static/static/js/RenderInPortalIfExists.DLUCooTN.js +1 -0
- streamlit/static/static/js/Toolbar.BiGGIQun.js +1 -0
- streamlit/static/static/js/UploadFileInfo.C-jY39rj.js +1 -0
- streamlit/static/static/js/base-input.CQBQT24M.js +4 -0
- streamlit/static/static/js/checkbox.Buj8gd_M.js +9 -0
- streamlit/static/static/js/createDownloadLinkElement.DZMwyjvU.js +1 -0
- streamlit/static/static/js/createSuper.CesK3I23.js +1 -0
- streamlit/static/static/js/data-grid-overlay-editor.B69OOFM4.js +1 -0
- streamlit/static/static/js/downloader.BZQhlBNT.js +1 -0
- streamlit/static/static/js/es6.D9Zhqujy.js +2 -0
- streamlit/static/static/js/iframeResizer.contentWindow.CAzcBpCC.js +1 -0
- streamlit/static/static/js/index.08vcOOvb.js +1 -0
- streamlit/static/static/js/index.0uqKfJUS.js +1 -0
- streamlit/static/static/js/index.B02M5u69.js +203 -0
- streamlit/static/static/js/index.B7mcZKMx.js +1 -0
- streamlit/static/static/js/index.BAQDHFA_.js +1 -0
- streamlit/static/static/js/index.BI60cMVr.js +2 -0
- streamlit/static/static/js/index.BLug2inK.js +1 -0
- streamlit/static/static/js/index.BM6TMY8g.js +2 -0
- streamlit/static/static/js/index.BZ9p1t7G.js +1 -0
- streamlit/static/static/js/index.BZqa87a1.js +2 -0
- streamlit/static/static/js/index.BcsRUzZZ.js +1 -0
- streamlit/static/static/js/index.BgVMiY_P.js +197 -0
- streamlit/static/static/js/index.BtuGy7By.js +6 -0
- streamlit/static/static/js/index.BuDuBmrs.js +1 -0
- streamlit/static/static/js/index.BvXU2oKV.js +1 -0
- streamlit/static/static/js/index.BxcwPacT.js +73 -0
- streamlit/static/static/js/index.CWX8KB81.js +1 -0
- streamlit/static/static/js/index.CXzZTo_q.js +1 -0
- streamlit/static/static/js/index.CcRWp_KL.js +1 -0
- streamlit/static/static/js/index.Cd-_xe55.js +3 -0
- streamlit/static/static/js/index.CdG2PXln.js +4537 -0
- streamlit/static/static/js/index.CjXvXmcP.js +1 -0
- streamlit/static/static/js/index.D1HZENZx.js +776 -0
- streamlit/static/static/js/index.D21Efo64.js +1617 -0
- streamlit/static/static/js/index.D9WgGVBx.js +7 -0
- streamlit/static/static/js/index.DEcsHtvb.js +12 -0
- streamlit/static/static/js/index.DFeMfr_K.js +1 -0
- streamlit/static/static/js/index.DHFBoItz.js +1 -0
- streamlit/static/static/js/index.D_PrBKnJ.js +3 -0
- streamlit/static/static/js/index.DmuRkekN.js +3855 -0
- streamlit/static/static/js/index.Do6eY8sf.js +1 -0
- streamlit/static/static/js/index.Dz3lP2P-.js +1 -0
- streamlit/static/static/js/index.Dz_UqF-s.js +1 -0
- streamlit/static/static/js/index.GkSUsPhJ.js +1 -0
- streamlit/static/static/js/index.H1U1IC_d.js +3 -0
- streamlit/static/static/js/index.g6p_4DPr.js +1 -0
- streamlit/static/static/js/index.g9x_GKss.js +1 -0
- streamlit/static/static/js/index.zo9jm08y.js +1 -0
- streamlit/static/static/js/input.DnaFglHq.js +2 -0
- streamlit/static/static/js/inputUtils.CQWz5UKz.js +1 -0
- streamlit/static/static/js/memory.Crb9x4-F.js +1 -0
- streamlit/static/static/js/mergeWith.ouAz0sK3.js +1 -0
- streamlit/static/static/js/number-overlay-editor._UaN-O48.js +9 -0
- streamlit/static/static/js/possibleConstructorReturn.CtGjGFHz.js +1 -0
- streamlit/static/static/js/sandbox.CBybYOhV.js +1 -0
- streamlit/static/static/js/sprintf.D7DtBTRn.js +1 -0
- streamlit/static/static/js/textarea.Cb_uJt5U.js +2 -0
- streamlit/static/static/js/threshold.DjX0wlsa.js +1 -0
- streamlit/static/static/js/timepicker.DKT7pfoF.js +4 -0
- streamlit/static/static/js/timer.CAwTRJ_g.js +1 -0
- streamlit/static/static/js/toConsumableArray.05Ikp13-.js +3 -0
- streamlit/static/static/js/uniqueId.D2FMWUEI.js +1 -0
- streamlit/static/static/js/useBasicWidgetState.urnZLANY.js +1 -0
- streamlit/static/static/js/useOnInputChange.BOKIIdJ1.js +1 -0
- streamlit/static/static/js/value.CgPGBV_l.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.C_N8J0Xx.js +1 -0
- streamlit/static/static/media/KaTeX_AMS-Regular.BQhdFMY1.woff2 +0 -0
- streamlit/static/static/media/KaTeX_AMS-Regular.DMm9YOAa.woff +0 -0
- streamlit/static/static/media/KaTeX_AMS-Regular.DRggAlZN.ttf +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Bold.ATXxdsX0.ttf +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Bold.BEiXGLvX.woff +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Bold.Dq_IR9rO.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Regular.CTRA-rTL.woff +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Regular.Di6jR-x-.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Caligraphic-Regular.wX97UBjC.ttf +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Bold.BdnERNNW.ttf +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Bold.BsDP51OF.woff +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Bold.CL6g_b3V.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Regular.CB_wures.ttf +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Regular.CTYiF6lA.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Fraktur-Regular.Dxdc4cR9.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Bold.Cx986IdX.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-Bold.Jm3AIy58.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Bold.waoOVXN0.ttf +0 -0
- streamlit/static/static/media/KaTeX_Main-BoldItalic.DxDJ3AOS.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-BoldItalic.DzxPMmG6.ttf +0 -0
- streamlit/static/static/media/KaTeX_Main-BoldItalic.SpSLRI95.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Italic.3WenGoN9.ttf +0 -0
- streamlit/static/static/media/KaTeX_Main-Italic.BMLOBm91.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Italic.NWA7e6Wa.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-Regular.B22Nviop.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Main-Regular.Dr94JaBh.woff +0 -0
- streamlit/static/static/media/KaTeX_Main-Regular.ypZvNtVU.ttf +0 -0
- streamlit/static/static/media/KaTeX_Math-BoldItalic.B3XSjfu4.ttf +0 -0
- streamlit/static/static/media/KaTeX_Math-BoldItalic.CZnvNsCZ.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Math-BoldItalic.iY-2wyZ7.woff +0 -0
- streamlit/static/static/media/KaTeX_Math-Italic.DA0__PXp.woff +0 -0
- streamlit/static/static/media/KaTeX_Math-Italic.flOr_0UB.ttf +0 -0
- streamlit/static/static/media/KaTeX_Math-Italic.t53AETM-.woff2 +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Bold.CFMepnvq.ttf +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Bold.D1sUS0GD.woff2 +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Bold.DbIhKOiC.woff +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Italic.C3H0VqGB.woff2 +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Italic.DN2j7dab.woff +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Italic.YYjJ1zSn.ttf +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Regular.BNo7hRIc.ttf +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Regular.CS6fqUqJ.woff +0 -0
- streamlit/static/static/media/KaTeX_SansSerif-Regular.DDBCnlJ7.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Script-Regular.C5JkGWo-.ttf +0 -0
- streamlit/static/static/media/KaTeX_Script-Regular.D3wIWfF6.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Script-Regular.D5yQViql.woff +0 -0
- streamlit/static/static/media/KaTeX_Size1-Regular.C195tn64.woff +0 -0
- streamlit/static/static/media/KaTeX_Size1-Regular.Dbsnue_I.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size1-Regular.mCD8mA8B.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Size2-Regular.B7gKUWhC.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size2-Regular.Dy4dx90m.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Size2-Regular.oD1tc_U0.woff +0 -0
- streamlit/static/static/media/KaTeX_Size3-Regular.CTq5MqoE.woff +0 -0
- streamlit/static/static/media/KaTeX_Size3-Regular.DgpXs0kz.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size4-Regular.BF-4gkZK.woff +0 -0
- streamlit/static/static/media/KaTeX_Size4-Regular.DWFBv043.ttf +0 -0
- streamlit/static/static/media/KaTeX_Size4-Regular.Dl5lxZxV.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Typewriter-Regular.C0xS9mPB.woff +0 -0
- streamlit/static/static/media/KaTeX_Typewriter-Regular.CO6r4hn1.woff2 +0 -0
- streamlit/static/static/media/KaTeX_Typewriter-Regular.D3Ib7_Hf.ttf +0 -0
- streamlit/static/static/media/MaterialSymbols-Rounded.DcZbplWk.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Bold.CFEfr7-q.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-BoldItalic.C-LkFXxa.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Italic.CxFOx7N-.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Regular.CBOlD63d.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBold.CFHwW3Wd.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBoldItalic.Cg2yRu82.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Bold.-6c9oR8J.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-BoldItalic.DmM_grLY.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Italic.I1ipWe7Q.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Regular.DZLUzqI4.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBold.sKQIyTMz.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBoldItalic.C0wP0icr.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Bold.8TUnKj4x.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-BoldItalic.CBVO7Ve7.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Italic.DkFgL2HZ.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Regular.CNJNET2S.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBold.CHyh9GC5.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBoldItalic.CBtz8sWN.woff2 +0 -0
- streamlit/static/static/media/balloon-0.Czj7AKwE.png +0 -0
- streamlit/static/static/media/balloon-1.CNvFFrND.png +0 -0
- streamlit/static/static/media/balloon-2.DTvC6B1t.png +0 -0
- streamlit/static/static/media/balloon-3.CgSk4tbL.png +0 -0
- streamlit/static/static/media/balloon-4.mbtFrzxf.png +0 -0
- streamlit/static/static/media/balloon-5.CSwkUfRA.png +0 -0
- streamlit/static/static/media/fireworks.B4d-_KUe.gif +0 -0
- streamlit/static/static/media/flake-0.DgWaVvm5.png +0 -0
- streamlit/static/static/media/flake-1.B2r5AHMK.png +0 -0
- streamlit/static/static/media/flake-2.BnWSExPC.png +0 -0
- streamlit/static/static/media/snowflake.JU2jBHL8.svg +11 -0
- streamlit/string_util.py +203 -0
- streamlit/temporary_directory.py +56 -0
- streamlit/testing/__init__.py +13 -0
- streamlit/testing/v1/__init__.py +17 -0
- streamlit/testing/v1/app_test.py +1050 -0
- streamlit/testing/v1/element_tree.py +2083 -0
- streamlit/testing/v1/local_script_runner.py +180 -0
- streamlit/testing/v1/util.py +53 -0
- streamlit/time_util.py +75 -0
- streamlit/type_util.py +460 -0
- streamlit/url_util.py +122 -0
- streamlit/user_info.py +519 -0
- streamlit/util.py +72 -0
- streamlit/vendor/__init__.py +0 -0
- streamlit/vendor/pympler/__init__.py +0 -0
- streamlit/vendor/pympler/asizeof.py +2869 -0
- streamlit/version.py +18 -0
- streamlit/watcher/__init__.py +28 -0
- streamlit/watcher/event_based_path_watcher.py +406 -0
- streamlit/watcher/folder_black_list.py +82 -0
- streamlit/watcher/local_sources_watcher.py +233 -0
- streamlit/watcher/path_watcher.py +185 -0
- streamlit/watcher/polling_path_watcher.py +124 -0
- streamlit/watcher/util.py +207 -0
- streamlit/web/__init__.py +13 -0
- streamlit/web/bootstrap.py +353 -0
- streamlit/web/cache_storage_manager_config.py +38 -0
- streamlit/web/cli.py +369 -0
- streamlit/web/server/__init__.py +26 -0
- streamlit/web/server/app_static_file_handler.py +93 -0
- streamlit/web/server/authlib_tornado_integration.py +60 -0
- streamlit/web/server/browser_websocket_handler.py +246 -0
- streamlit/web/server/component_request_handler.py +116 -0
- streamlit/web/server/media_file_handler.py +141 -0
- streamlit/web/server/oauth_authlib_routes.py +176 -0
- streamlit/web/server/oidc_mixin.py +108 -0
- streamlit/web/server/routes.py +295 -0
- streamlit/web/server/server.py +479 -0
- streamlit/web/server/server_util.py +161 -0
- streamlit/web/server/stats_request_handler.py +95 -0
- streamlit/web/server/upload_file_request_handler.py +137 -0
- streamlit/web/server/websocket_headers.py +56 -0
- streamlit_nightly-1.43.2.dev20250307.data/scripts/streamlit.cmd +16 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/METADATA +207 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/RECORD +563 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/WHEEL +5 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/entry_points.txt +2 -0
- streamlit_nightly-1.43.2.dev20250307.dist-info/top_level.txt +1 -0
streamlit/config.py
ADDED
@@ -0,0 +1,1513 @@
|
|
1
|
+
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2025)
|
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
|
+
"""Loads the configuration data."""
|
16
|
+
|
17
|
+
from __future__ import annotations
|
18
|
+
|
19
|
+
import copy
|
20
|
+
import os
|
21
|
+
import secrets
|
22
|
+
import threading
|
23
|
+
from collections import OrderedDict
|
24
|
+
from enum import Enum
|
25
|
+
from typing import Any, Callable
|
26
|
+
|
27
|
+
from blinker import Signal
|
28
|
+
|
29
|
+
from streamlit import config_util, development, env_util, file_util, util
|
30
|
+
from streamlit.config_option import ConfigOption
|
31
|
+
from streamlit.errors import StreamlitAPIException
|
32
|
+
|
33
|
+
# Config System Global State #
|
34
|
+
|
35
|
+
# Descriptions of each of the possible config sections.
|
36
|
+
# (We use OrderedDict to make the order in which sections are declared in this
|
37
|
+
# file be the same order as the sections appear with `streamlit config show`)
|
38
|
+
_section_descriptions: dict[str, str] = OrderedDict(
|
39
|
+
_test="Special test section just used for unit tests."
|
40
|
+
)
|
41
|
+
|
42
|
+
# Ensures that we don't try to get or set config options when config.toml files
|
43
|
+
# change so are re-parsed.
|
44
|
+
_config_lock = threading.RLock()
|
45
|
+
|
46
|
+
# Stores config options with their default values (or None if they don't have
|
47
|
+
# a default) before they are updated with values from config.toml files, flags
|
48
|
+
# to `streamlit run`, etc. Note that this and _config_options below are
|
49
|
+
# OrderedDicts to ensure stable ordering when printed using
|
50
|
+
# `streamlit config show`.
|
51
|
+
_config_options_template: dict[str, ConfigOption] = OrderedDict()
|
52
|
+
|
53
|
+
# Stores the current state of config options.
|
54
|
+
_config_options: dict[str, ConfigOption] | None = None
|
55
|
+
|
56
|
+
|
57
|
+
# Indicates that a config option was defined by the user.
|
58
|
+
_USER_DEFINED = "<user defined>"
|
59
|
+
|
60
|
+
# Indicates that a config option was defined either in an environment variable
|
61
|
+
# or via command-line flag.
|
62
|
+
_DEFINED_BY_FLAG = "command-line argument or environment variable"
|
63
|
+
|
64
|
+
# Indicates that a config option was defined in an environment variable
|
65
|
+
_DEFINED_BY_ENV_VAR = "environment variable"
|
66
|
+
|
67
|
+
|
68
|
+
class ShowErrorDetailsConfigOptions(str, Enum):
|
69
|
+
"""Valid options for the "client.showErrorDetails" config."""
|
70
|
+
|
71
|
+
FULL = "full"
|
72
|
+
STACKTRACE = "stacktrace"
|
73
|
+
TYPE = "type"
|
74
|
+
NONE = "none"
|
75
|
+
|
76
|
+
@staticmethod
|
77
|
+
def is_true_variation(val: str | bool):
|
78
|
+
return val in ["true", "True", True]
|
79
|
+
|
80
|
+
@staticmethod
|
81
|
+
def is_false_variation(val: str | bool):
|
82
|
+
return val in ["false", "False", False]
|
83
|
+
|
84
|
+
# Config options can be set from several places including the command-line and
|
85
|
+
# the user's script. Legacy config options (true/false) will have type string when set via
|
86
|
+
# command-line and bool when set via user script (e.g. st.set_option("client.showErrorDetails", False)).
|
87
|
+
|
88
|
+
|
89
|
+
def set_option(key: str, value: Any, where_defined: str = _USER_DEFINED) -> None:
|
90
|
+
"""Set config option.
|
91
|
+
|
92
|
+
Run `streamlit config show` in the terminal to see all available options.
|
93
|
+
|
94
|
+
This is an internal API. The public `st.set_option` API is implemented
|
95
|
+
in `set_user_option`.
|
96
|
+
|
97
|
+
Parameters
|
98
|
+
----------
|
99
|
+
key : str
|
100
|
+
The config option key of the form "section.optionName". To see all
|
101
|
+
available options, run `streamlit config show` on a terminal.
|
102
|
+
|
103
|
+
value
|
104
|
+
The new value to assign to this config option.
|
105
|
+
|
106
|
+
where_defined : str
|
107
|
+
Tells the config system where this was set.
|
108
|
+
"""
|
109
|
+
with _config_lock:
|
110
|
+
# Ensure that our config files have been parsed.
|
111
|
+
get_config_options()
|
112
|
+
_set_option(key, value, where_defined)
|
113
|
+
|
114
|
+
|
115
|
+
def set_user_option(key: str, value: Any) -> None:
|
116
|
+
"""Set a configuration option.
|
117
|
+
|
118
|
+
Currently, only ``client`` configuration options can be set within the
|
119
|
+
script itself:
|
120
|
+
|
121
|
+
- ``client.showErrorDetails``
|
122
|
+
- ``client.showSidebarNavigation``
|
123
|
+
- ``client.toolbarMode``
|
124
|
+
|
125
|
+
Calling ``st.set_option`` with any other option will raise a
|
126
|
+
``StreamlitAPIException``. When changing a configuration option in a
|
127
|
+
running app, you may need to trigger a rerun after changing the option to
|
128
|
+
see the effects.
|
129
|
+
|
130
|
+
Run ``streamlit config show`` in a terminal to see all available options.
|
131
|
+
|
132
|
+
Parameters
|
133
|
+
----------
|
134
|
+
key : str
|
135
|
+
The config option key of the form "section.optionName". To see all
|
136
|
+
available options, run ``streamlit config show`` in a terminal.
|
137
|
+
|
138
|
+
value
|
139
|
+
The new value to assign to this config option.
|
140
|
+
|
141
|
+
Example
|
142
|
+
-------
|
143
|
+
|
144
|
+
>>> import streamlit as st
|
145
|
+
>>>
|
146
|
+
>>> st.set_option("client.showErrorDetails", True)
|
147
|
+
|
148
|
+
"""
|
149
|
+
try:
|
150
|
+
opt = _config_options_template[key]
|
151
|
+
except KeyError as ke:
|
152
|
+
raise StreamlitAPIException(f"Unrecognized config option: {key}") from ke
|
153
|
+
# Allow e2e tests to set any option
|
154
|
+
if opt.scriptable:
|
155
|
+
set_option(key, value)
|
156
|
+
return
|
157
|
+
|
158
|
+
raise StreamlitAPIException(
|
159
|
+
f"{key} cannot be set on the fly. Set as command line option, e.g. streamlit run script.py --{key}, or in config.toml instead."
|
160
|
+
)
|
161
|
+
|
162
|
+
|
163
|
+
def get_option(key: str) -> Any:
|
164
|
+
"""Return the current value of a given Streamlit configuration option.
|
165
|
+
|
166
|
+
Run ``streamlit config show`` in a terminal to see all available options.
|
167
|
+
|
168
|
+
Parameters
|
169
|
+
----------
|
170
|
+
key : str
|
171
|
+
The config option key of the form "section.optionName". To see all
|
172
|
+
available options, run ``streamlit config show`` in a terminal.
|
173
|
+
|
174
|
+
Example
|
175
|
+
-------
|
176
|
+
|
177
|
+
>>> import streamlit as st
|
178
|
+
>>>
|
179
|
+
>>> color = st.get_option("theme.primaryColor")
|
180
|
+
|
181
|
+
"""
|
182
|
+
with _config_lock:
|
183
|
+
config_options = get_config_options()
|
184
|
+
|
185
|
+
if key not in config_options:
|
186
|
+
raise RuntimeError(f'Config key "{key}" not defined.')
|
187
|
+
return config_options[key].value
|
188
|
+
|
189
|
+
|
190
|
+
def get_options_for_section(section: str) -> dict[str, Any]:
|
191
|
+
"""Get all of the config options for the given section.
|
192
|
+
|
193
|
+
Run `streamlit config show` in the terminal to see all available options.
|
194
|
+
|
195
|
+
Parameters
|
196
|
+
----------
|
197
|
+
section : str
|
198
|
+
The name of the config section to fetch options for.
|
199
|
+
|
200
|
+
Returns
|
201
|
+
-------
|
202
|
+
dict[str, Any]
|
203
|
+
A dict mapping the names of the options in the given section (without
|
204
|
+
the section name as a prefix) to their values.
|
205
|
+
"""
|
206
|
+
with _config_lock:
|
207
|
+
config_options = get_config_options()
|
208
|
+
|
209
|
+
options_for_section = {}
|
210
|
+
for option in config_options.values():
|
211
|
+
if option.section == section:
|
212
|
+
options_for_section[option.name] = option.value
|
213
|
+
return options_for_section
|
214
|
+
|
215
|
+
|
216
|
+
def _create_section(section: str, description: str) -> None:
|
217
|
+
"""Create a config section and store it globally in this module."""
|
218
|
+
assert section not in _section_descriptions, (
|
219
|
+
f'Cannot define section "{section}" twice.'
|
220
|
+
)
|
221
|
+
_section_descriptions[section] = description
|
222
|
+
|
223
|
+
|
224
|
+
def _create_option(
|
225
|
+
key: str,
|
226
|
+
description: str | None = None,
|
227
|
+
default_val: Any | None = None,
|
228
|
+
scriptable: bool = False,
|
229
|
+
visibility: str = "visible",
|
230
|
+
deprecated: bool = False,
|
231
|
+
deprecation_text: str | None = None,
|
232
|
+
expiration_date: str | None = None,
|
233
|
+
replaced_by: str | None = None,
|
234
|
+
type_: type = str,
|
235
|
+
sensitive: bool = False,
|
236
|
+
) -> ConfigOption:
|
237
|
+
'''Create a ConfigOption and store it globally in this module.
|
238
|
+
|
239
|
+
There are two ways to create a ConfigOption:
|
240
|
+
|
241
|
+
(1) Simple, constant config options are created as follows:
|
242
|
+
|
243
|
+
_create_option('section.optionName',
|
244
|
+
description = 'Put the description here.',
|
245
|
+
default_val = 12345)
|
246
|
+
|
247
|
+
(2) More complex, programmable config options use decorator syntax to
|
248
|
+
resolve their values at runtime:
|
249
|
+
|
250
|
+
@_create_option('section.optionName')
|
251
|
+
def _section_option_name():
|
252
|
+
"""Put the description here."""
|
253
|
+
return 12345
|
254
|
+
|
255
|
+
To achieve this sugar, _create_option() returns a *callable object* of type
|
256
|
+
ConfigObject, which then decorates the function.
|
257
|
+
|
258
|
+
NOTE: ConfigObjects call their evaluation functions *every time* the option
|
259
|
+
is requested. To prevent this, use the `streamlit.util.memoize` decorator as
|
260
|
+
follows:
|
261
|
+
|
262
|
+
@_create_option('section.memoizedOptionName')
|
263
|
+
@util.memoize
|
264
|
+
def _section_memoized_option_name():
|
265
|
+
"""Put the description here."""
|
266
|
+
|
267
|
+
(This function is only called once.)
|
268
|
+
"""
|
269
|
+
return 12345
|
270
|
+
|
271
|
+
'''
|
272
|
+
option = ConfigOption(
|
273
|
+
key,
|
274
|
+
description=description,
|
275
|
+
default_val=default_val,
|
276
|
+
scriptable=scriptable,
|
277
|
+
visibility=visibility,
|
278
|
+
deprecated=deprecated,
|
279
|
+
deprecation_text=deprecation_text,
|
280
|
+
expiration_date=expiration_date,
|
281
|
+
replaced_by=replaced_by,
|
282
|
+
type_=type_,
|
283
|
+
sensitive=sensitive,
|
284
|
+
)
|
285
|
+
assert option.section in _section_descriptions, (
|
286
|
+
'Section "{}" must be one of {}.'.format(
|
287
|
+
option.section,
|
288
|
+
", ".join(_section_descriptions.keys()),
|
289
|
+
)
|
290
|
+
)
|
291
|
+
assert key not in _config_options_template, f'Cannot define option "{key}" twice.'
|
292
|
+
_config_options_template[key] = option
|
293
|
+
return option
|
294
|
+
|
295
|
+
|
296
|
+
def _delete_option(key: str) -> None:
|
297
|
+
"""Remove a ConfigOption by key from the global store.
|
298
|
+
|
299
|
+
Only for use in testing.
|
300
|
+
"""
|
301
|
+
try:
|
302
|
+
del _config_options_template[key]
|
303
|
+
assert _config_options is not None, (
|
304
|
+
"_config_options should always be populated here."
|
305
|
+
)
|
306
|
+
del _config_options[key]
|
307
|
+
except Exception:
|
308
|
+
# We don't care if the option already doesn't exist.
|
309
|
+
pass
|
310
|
+
|
311
|
+
|
312
|
+
# Config Section: Global #
|
313
|
+
|
314
|
+
_create_section("global", "Global options that apply across all of Streamlit.")
|
315
|
+
|
316
|
+
|
317
|
+
_create_option(
|
318
|
+
"global.disableWidgetStateDuplicationWarning",
|
319
|
+
description="""
|
320
|
+
By default, Streamlit displays a warning when a user sets both a widget
|
321
|
+
default value in the function defining the widget and a widget value via
|
322
|
+
the widget's key in `st.session_state`.
|
323
|
+
|
324
|
+
If you'd like to turn off this warning, set this to True.
|
325
|
+
""",
|
326
|
+
default_val=False,
|
327
|
+
type_=bool,
|
328
|
+
)
|
329
|
+
|
330
|
+
|
331
|
+
_create_option(
|
332
|
+
"global.showWarningOnDirectExecution",
|
333
|
+
description="""
|
334
|
+
If True, will show a warning when you run a Streamlit-enabled script
|
335
|
+
via "python my_script.py".
|
336
|
+
""",
|
337
|
+
default_val=True,
|
338
|
+
type_=bool,
|
339
|
+
)
|
340
|
+
|
341
|
+
|
342
|
+
@_create_option("global.developmentMode", visibility="hidden", type_=bool)
|
343
|
+
def _global_development_mode() -> bool:
|
344
|
+
"""Are we in development mode.
|
345
|
+
|
346
|
+
This option defaults to True if and only if Streamlit wasn't installed
|
347
|
+
normally.
|
348
|
+
"""
|
349
|
+
return (
|
350
|
+
not env_util.is_pex()
|
351
|
+
and "site-packages" not in __file__
|
352
|
+
and "dist-packages" not in __file__
|
353
|
+
and "__pypackages__" not in __file__
|
354
|
+
)
|
355
|
+
|
356
|
+
|
357
|
+
_create_option(
|
358
|
+
"global.e2eTest",
|
359
|
+
description="Are we in an e2e (playwright) test? Set automatically when our e2e tests are running.",
|
360
|
+
visibility="hidden",
|
361
|
+
default_val=False,
|
362
|
+
type_=bool,
|
363
|
+
)
|
364
|
+
|
365
|
+
_create_option(
|
366
|
+
"global.unitTest",
|
367
|
+
description="Are we in a unit test?",
|
368
|
+
visibility="hidden",
|
369
|
+
default_val=False,
|
370
|
+
type_=bool,
|
371
|
+
)
|
372
|
+
|
373
|
+
_create_option(
|
374
|
+
"global.appTest",
|
375
|
+
description="Are we in an app test? Set automatically when the AppTest framework is running",
|
376
|
+
visibility="hidden",
|
377
|
+
default_val=False,
|
378
|
+
type_=bool,
|
379
|
+
)
|
380
|
+
|
381
|
+
_create_option(
|
382
|
+
"global.suppressDeprecationWarnings",
|
383
|
+
description="Hide deprecation warnings in the streamlit app.",
|
384
|
+
visibility="hidden",
|
385
|
+
default_val=False,
|
386
|
+
type_=bool,
|
387
|
+
)
|
388
|
+
|
389
|
+
_create_option(
|
390
|
+
"global.minCachedMessageSize",
|
391
|
+
description="""
|
392
|
+
Only cache ForwardMsgs that are greater than or equal to this minimum.
|
393
|
+
""",
|
394
|
+
visibility="hidden",
|
395
|
+
default_val=10 * 1e3,
|
396
|
+
type_=float,
|
397
|
+
) # 10k
|
398
|
+
|
399
|
+
_create_option(
|
400
|
+
"global.maxCachedMessageAge",
|
401
|
+
description="""
|
402
|
+
Expire cached ForwardMsgs whose age is greater than this
|
403
|
+
value. A message's age is defined by how many times its script has
|
404
|
+
finished running since the message has been accessed.
|
405
|
+
""",
|
406
|
+
visibility="hidden",
|
407
|
+
default_val=2,
|
408
|
+
type_=int,
|
409
|
+
)
|
410
|
+
|
411
|
+
_create_option(
|
412
|
+
"global.storeCachedForwardMessagesInMemory",
|
413
|
+
description="""
|
414
|
+
If True, store cached ForwardMsgs in backend memory. This is an
|
415
|
+
internal flag to validate a potential removal of the in-memory
|
416
|
+
forward message cache.
|
417
|
+
""",
|
418
|
+
visibility="hidden",
|
419
|
+
default_val=True,
|
420
|
+
type_=bool,
|
421
|
+
)
|
422
|
+
|
423
|
+
_create_option(
|
424
|
+
"global.includeFragmentRunsInForwardMessageCacheCount",
|
425
|
+
description="""
|
426
|
+
If True, the server will include fragment runs in the count for the
|
427
|
+
forward message cache. The implication is that apps with fragments may
|
428
|
+
see messages being removed from the cache faster. This aligns the server
|
429
|
+
count with the frontend count. This is a temporary fix while we assess the
|
430
|
+
design of the cache.
|
431
|
+
""",
|
432
|
+
visibility="hidden",
|
433
|
+
default_val=False,
|
434
|
+
type_=bool,
|
435
|
+
)
|
436
|
+
|
437
|
+
|
438
|
+
# Config Section: Logger #
|
439
|
+
_create_section("logger", "Settings to customize Streamlit log messages.")
|
440
|
+
|
441
|
+
|
442
|
+
@_create_option("logger.level", type_=str)
|
443
|
+
def _logger_log_level() -> str:
|
444
|
+
"""Level of logging for Streamlit's internal logger: "error", "warning",
|
445
|
+
"info", or "debug".
|
446
|
+
|
447
|
+
Default: "info"
|
448
|
+
"""
|
449
|
+
if get_option("global.developmentMode"):
|
450
|
+
return "debug"
|
451
|
+
else:
|
452
|
+
return "info"
|
453
|
+
|
454
|
+
|
455
|
+
@_create_option("logger.messageFormat", type_=str)
|
456
|
+
def _logger_message_format() -> str:
|
457
|
+
"""String format for logging messages. If logger.datetimeFormat is set,
|
458
|
+
logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See
|
459
|
+
Python's documentation for available attributes:
|
460
|
+
https://docs.python.org/3/library/logging.html#formatter-objects
|
461
|
+
|
462
|
+
Default: "%(asctime)s %(message)s"
|
463
|
+
"""
|
464
|
+
if get_option("global.developmentMode"):
|
465
|
+
from streamlit.logger import DEFAULT_LOG_MESSAGE
|
466
|
+
|
467
|
+
return DEFAULT_LOG_MESSAGE
|
468
|
+
else:
|
469
|
+
return "%(asctime)s %(message)s"
|
470
|
+
|
471
|
+
|
472
|
+
@_create_option(
|
473
|
+
"logger.enableRich",
|
474
|
+
visibility="hidden",
|
475
|
+
type_=bool,
|
476
|
+
scriptable=True,
|
477
|
+
)
|
478
|
+
def _logger_enable_rich() -> bool:
|
479
|
+
"""
|
480
|
+
Controls whether uncaught app exceptions are logged via the rich library.
|
481
|
+
|
482
|
+
If True and if rich is installed, exception tracebacks will be logged with
|
483
|
+
syntax highlighting and formatting. Rich tracebacks are easier to read and
|
484
|
+
show more code than standard Python tracebacks.
|
485
|
+
|
486
|
+
If set to False, the default Python traceback formatting will be used.
|
487
|
+
|
488
|
+
Defaults to True if rich is installed, False otherwise.
|
489
|
+
"""
|
490
|
+
try:
|
491
|
+
import rich # noqa: F401
|
492
|
+
|
493
|
+
# Rich is importable, activate rich logging.
|
494
|
+
return True
|
495
|
+
except Exception:
|
496
|
+
# We are extra broad in catching exceptions here because we don't want
|
497
|
+
# that this causes Streamlit to crash if there is any unexpected
|
498
|
+
# exception thrown by the import
|
499
|
+
return False
|
500
|
+
|
501
|
+
|
502
|
+
# Config Section: Client #
|
503
|
+
|
504
|
+
_create_section("client", "Settings for scripts that use Streamlit.")
|
505
|
+
|
506
|
+
|
507
|
+
_create_option(
|
508
|
+
"client.showErrorDetails",
|
509
|
+
description="""
|
510
|
+
Controls whether uncaught app exceptions and deprecation warnings
|
511
|
+
are displayed in the browser. This can be one of the following:
|
512
|
+
|
513
|
+
- "full" : In the browser, Streamlit displays app deprecation
|
514
|
+
warnings and exceptions, including exception types,
|
515
|
+
exception messages, and associated tracebacks.
|
516
|
+
- "stacktrace" : In the browser, Streamlit displays exceptions,
|
517
|
+
including exception types, generic exception messages,
|
518
|
+
and associated tracebacks. Deprecation warnings and
|
519
|
+
full exception messages will only print to the
|
520
|
+
console.
|
521
|
+
- "type" : In the browser, Streamlit displays exception types and
|
522
|
+
generic exception messages. Deprecation warnings, full
|
523
|
+
exception messages, and associated tracebacks only
|
524
|
+
print to the console.
|
525
|
+
- "none" : In the browser, Streamlit displays generic exception
|
526
|
+
messages. Deprecation warnings, full exception
|
527
|
+
messages, associated tracebacks, and exception types
|
528
|
+
will only print to the console.
|
529
|
+
- True : This is deprecated. Streamlit displays "full"
|
530
|
+
error details.
|
531
|
+
- False : This is deprecated. Streamlit displays "stacktrace"
|
532
|
+
error details.
|
533
|
+
""",
|
534
|
+
default_val=ShowErrorDetailsConfigOptions.FULL,
|
535
|
+
type_=str,
|
536
|
+
scriptable=True,
|
537
|
+
)
|
538
|
+
|
539
|
+
_create_option(
|
540
|
+
"client.toolbarMode",
|
541
|
+
description="""
|
542
|
+
Change the visibility of items in the toolbar, options menu,
|
543
|
+
and settings dialog (top right of the app).
|
544
|
+
|
545
|
+
Allowed values:
|
546
|
+
- "auto" : Show the developer options if the app is accessed through
|
547
|
+
localhost or through Streamlit Community Cloud as a developer.
|
548
|
+
Hide them otherwise.
|
549
|
+
- "developer" : Show the developer options.
|
550
|
+
- "viewer" : Hide the developer options.
|
551
|
+
- "minimal" : Show only options set externally (e.g. through
|
552
|
+
Streamlit Community Cloud) or through st.set_page_config.
|
553
|
+
If there are no options left, hide the menu.
|
554
|
+
""",
|
555
|
+
default_val="auto",
|
556
|
+
type_=str,
|
557
|
+
scriptable=True,
|
558
|
+
)
|
559
|
+
|
560
|
+
_create_option(
|
561
|
+
"client.showSidebarNavigation",
|
562
|
+
description="""
|
563
|
+
Controls whether to display the default sidebar page navigation in a
|
564
|
+
multi-page app. This only applies when app's pages are defined by the
|
565
|
+
`pages/` directory.
|
566
|
+
""",
|
567
|
+
default_val=True,
|
568
|
+
type_=bool,
|
569
|
+
scriptable=True,
|
570
|
+
)
|
571
|
+
|
572
|
+
# Config Section: Runner #
|
573
|
+
|
574
|
+
_create_section("runner", "Settings for how Streamlit executes your script")
|
575
|
+
|
576
|
+
_create_option(
|
577
|
+
"runner.magicEnabled",
|
578
|
+
description="""
|
579
|
+
Allows you to type a variable or string by itself in a single line of
|
580
|
+
Python code to write it to the app.
|
581
|
+
""",
|
582
|
+
default_val=True,
|
583
|
+
type_=bool,
|
584
|
+
)
|
585
|
+
|
586
|
+
_create_option(
|
587
|
+
"runner.postScriptGC",
|
588
|
+
description="""
|
589
|
+
Run the Python Garbage Collector after each script execution. This
|
590
|
+
can help avoid excess memory use in Streamlit apps, but could
|
591
|
+
introduce delay in rerunning the app script for high-memory-use
|
592
|
+
applications.
|
593
|
+
""",
|
594
|
+
default_val=True,
|
595
|
+
type_=bool,
|
596
|
+
visibility="hidden",
|
597
|
+
)
|
598
|
+
|
599
|
+
_create_option(
|
600
|
+
"runner.fastReruns",
|
601
|
+
description="""
|
602
|
+
Handle script rerun requests immediately, rather than waiting for script
|
603
|
+
execution to reach a yield point. This makes Streamlit much more
|
604
|
+
responsive to user interaction, but it can lead to race conditions in
|
605
|
+
apps that mutate session_state data outside of explicit session_state
|
606
|
+
assignment statements.
|
607
|
+
""",
|
608
|
+
default_val=True,
|
609
|
+
type_=bool,
|
610
|
+
)
|
611
|
+
|
612
|
+
_create_option(
|
613
|
+
"runner.enforceSerializableSessionState",
|
614
|
+
description="""
|
615
|
+
Raise an exception after adding unserializable data to Session State.
|
616
|
+
Some execution environments may require serializing all data in Session
|
617
|
+
State, so it may be useful to detect incompatibility during development,
|
618
|
+
or when the execution environment will stop supporting it in the future.
|
619
|
+
""",
|
620
|
+
default_val=False,
|
621
|
+
type_=bool,
|
622
|
+
)
|
623
|
+
|
624
|
+
_create_option(
|
625
|
+
"runner.enumCoercion",
|
626
|
+
description="""
|
627
|
+
Adjust how certain 'options' widgets like radio, selectbox, and
|
628
|
+
multiselect coerce Enum members when the Enum class gets re-defined
|
629
|
+
during a script re-run. For more information, check out the docs:
|
630
|
+
https://docs.streamlit.io/develop/concepts/design/custom-classes#enums
|
631
|
+
|
632
|
+
Allowed values:
|
633
|
+
- "off": Disables Enum coercion.
|
634
|
+
- "nameOnly": Enum classes can be coerced if their member names match.
|
635
|
+
- "nameAndValue": Enum classes can be coerced if their member names AND
|
636
|
+
member values match.
|
637
|
+
""",
|
638
|
+
default_val="nameOnly",
|
639
|
+
type_=str,
|
640
|
+
)
|
641
|
+
|
642
|
+
# Config Section: Server #
|
643
|
+
|
644
|
+
_create_section("server", "Settings for the Streamlit server")
|
645
|
+
|
646
|
+
_create_option(
|
647
|
+
"server.folderWatchBlacklist",
|
648
|
+
description="""
|
649
|
+
List of folders that should not be watched for changes.
|
650
|
+
|
651
|
+
Relative paths will be taken as relative to the current working directory.
|
652
|
+
|
653
|
+
Example: ['/home/user1/env', 'relative/path/to/folder']
|
654
|
+
""",
|
655
|
+
default_val=[],
|
656
|
+
)
|
657
|
+
|
658
|
+
_create_option(
|
659
|
+
"server.fileWatcherType",
|
660
|
+
description="""
|
661
|
+
Change the type of file watcher used by Streamlit, or turn it off
|
662
|
+
completely.
|
663
|
+
|
664
|
+
Allowed values:
|
665
|
+
- "auto" : Streamlit will attempt to use the watchdog module, and
|
666
|
+
falls back to polling if watchdog is not available.
|
667
|
+
- "watchdog" : Force Streamlit to use the watchdog module.
|
668
|
+
- "poll" : Force Streamlit to always use polling.
|
669
|
+
- "none" : Streamlit will not watch files.
|
670
|
+
""",
|
671
|
+
default_val="auto",
|
672
|
+
type_=str,
|
673
|
+
)
|
674
|
+
|
675
|
+
|
676
|
+
@_create_option("server.cookieSecret", type_=str, sensitive=True)
|
677
|
+
@util.memoize
|
678
|
+
def _server_cookie_secret() -> str:
|
679
|
+
"""Symmetric key used to produce signed cookies. If deploying on multiple
|
680
|
+
replicas, this should be set to the same value across all replicas to ensure
|
681
|
+
they all share the same secret.
|
682
|
+
|
683
|
+
Default: randomly generated secret key.
|
684
|
+
"""
|
685
|
+
return secrets.token_hex()
|
686
|
+
|
687
|
+
|
688
|
+
@_create_option("server.headless", type_=bool)
|
689
|
+
def _server_headless() -> bool:
|
690
|
+
"""If false, will attempt to open a browser window on start.
|
691
|
+
|
692
|
+
Default: false unless (1) we are on a Linux box where DISPLAY is unset, or
|
693
|
+
(2) we are running in the Streamlit Atom plugin.
|
694
|
+
"""
|
695
|
+
if env_util.IS_LINUX_OR_BSD and not os.getenv("DISPLAY"):
|
696
|
+
# We're running in Linux and DISPLAY is unset
|
697
|
+
return True
|
698
|
+
|
699
|
+
return False
|
700
|
+
|
701
|
+
|
702
|
+
_create_option(
|
703
|
+
"server.runOnSave",
|
704
|
+
description="""
|
705
|
+
Automatically rerun script when the file is modified on disk.
|
706
|
+
""",
|
707
|
+
default_val=False,
|
708
|
+
type_=bool,
|
709
|
+
)
|
710
|
+
|
711
|
+
_create_option(
|
712
|
+
"server.allowRunOnSave",
|
713
|
+
description="""
|
714
|
+
Allows users to automatically rerun when app is updated.
|
715
|
+
""",
|
716
|
+
visibility="hidden",
|
717
|
+
default_val=True,
|
718
|
+
type_=bool,
|
719
|
+
)
|
720
|
+
|
721
|
+
|
722
|
+
@_create_option("server.address")
|
723
|
+
def _server_address() -> str | None:
|
724
|
+
"""The address where the server will listen for client and browser
|
725
|
+
connections. Use this if you want to bind the server to a specific address.
|
726
|
+
If set, the server will only be accessible from this address, and not from
|
727
|
+
any aliases (like localhost).
|
728
|
+
|
729
|
+
Default: (unset)
|
730
|
+
"""
|
731
|
+
return None
|
732
|
+
|
733
|
+
|
734
|
+
_create_option(
|
735
|
+
"server.port",
|
736
|
+
description="""
|
737
|
+
The port where the server will listen for browser connections.
|
738
|
+
|
739
|
+
Don't use port 3000 which is reserved for internal development.
|
740
|
+
""",
|
741
|
+
default_val=8501,
|
742
|
+
type_=int,
|
743
|
+
)
|
744
|
+
|
745
|
+
_create_option(
|
746
|
+
"server.scriptHealthCheckEnabled",
|
747
|
+
visibility="hidden",
|
748
|
+
description="""
|
749
|
+
Flag for enabling the script health check endpoint. It's used for checking if
|
750
|
+
a script loads successfully. On success, the endpoint will return a 200
|
751
|
+
HTTP status code. On failure, the endpoint will return a 503 HTTP status code.
|
752
|
+
|
753
|
+
Note: This is an experimental Streamlit internal API. The API is subject
|
754
|
+
to change anytime so this should be used at your own risk
|
755
|
+
""",
|
756
|
+
default_val=False,
|
757
|
+
type_=bool,
|
758
|
+
)
|
759
|
+
|
760
|
+
_create_option(
|
761
|
+
"server.baseUrlPath",
|
762
|
+
description="""
|
763
|
+
The base path for the URL where Streamlit should be served from.
|
764
|
+
""",
|
765
|
+
default_val="",
|
766
|
+
type_=str,
|
767
|
+
)
|
768
|
+
|
769
|
+
# TODO: Rename to server.enableCorsProtection.
|
770
|
+
_create_option(
|
771
|
+
"server.enableCORS",
|
772
|
+
description="""
|
773
|
+
Enables support for Cross-Origin Resource Sharing (CORS) protection,
|
774
|
+
for added security.
|
775
|
+
|
776
|
+
If XSRF protection is enabled and CORS protection is disabled at the
|
777
|
+
same time, Streamlit will enable them both instead.
|
778
|
+
""",
|
779
|
+
default_val=True,
|
780
|
+
type_=bool,
|
781
|
+
)
|
782
|
+
|
783
|
+
|
784
|
+
_create_option(
|
785
|
+
"server.enableXsrfProtection",
|
786
|
+
description="""
|
787
|
+
Enables support for Cross-Site Request Forgery (XSRF) protection, for
|
788
|
+
added security.
|
789
|
+
|
790
|
+
If XSRF protection is enabled and CORS protection is disabled at the
|
791
|
+
same time, Streamlit will enable them both instead.
|
792
|
+
""",
|
793
|
+
default_val=True,
|
794
|
+
type_=bool,
|
795
|
+
)
|
796
|
+
|
797
|
+
_create_option(
|
798
|
+
"server.maxUploadSize",
|
799
|
+
description="""
|
800
|
+
Max size, in megabytes, for files uploaded with the file_uploader.
|
801
|
+
""",
|
802
|
+
default_val=200, # If this default is changed, please also update the docstring for `DeltaGenerator.file_uploader`.
|
803
|
+
type_=int,
|
804
|
+
)
|
805
|
+
|
806
|
+
_create_option(
|
807
|
+
"server.maxMessageSize",
|
808
|
+
description="""
|
809
|
+
Max size, in megabytes, of messages that can be sent via the WebSocket
|
810
|
+
connection.
|
811
|
+
""",
|
812
|
+
default_val=200,
|
813
|
+
type_=int,
|
814
|
+
)
|
815
|
+
|
816
|
+
_create_option(
|
817
|
+
"server.enableArrowTruncation",
|
818
|
+
description="""
|
819
|
+
Enable automatically truncating all data structures that get serialized into Arrow (e.g. DataFrames)
|
820
|
+
to ensure that the size is under `server.maxMessageSize`.
|
821
|
+
""",
|
822
|
+
visibility="hidden",
|
823
|
+
default_val=False,
|
824
|
+
scriptable=True,
|
825
|
+
type_=bool,
|
826
|
+
)
|
827
|
+
|
828
|
+
_create_option(
|
829
|
+
"server.enableWebsocketCompression",
|
830
|
+
description="""
|
831
|
+
Enables support for websocket compression.
|
832
|
+
""",
|
833
|
+
default_val=False,
|
834
|
+
type_=bool,
|
835
|
+
)
|
836
|
+
|
837
|
+
_create_option(
|
838
|
+
"server.enableStaticServing",
|
839
|
+
description="""
|
840
|
+
Enable serving files from a `static` directory in the running app's
|
841
|
+
directory.
|
842
|
+
""",
|
843
|
+
default_val=False,
|
844
|
+
type_=bool,
|
845
|
+
)
|
846
|
+
|
847
|
+
_create_option(
|
848
|
+
"server.disconnectedSessionTTL",
|
849
|
+
description="""
|
850
|
+
TTL in seconds for sessions whose websockets have been disconnected. The server
|
851
|
+
may choose to clean up session state, uploaded files, etc for a given session
|
852
|
+
with no active websocket connection at any point after this time has passed.
|
853
|
+
""",
|
854
|
+
default_val=120,
|
855
|
+
type_=int,
|
856
|
+
)
|
857
|
+
|
858
|
+
# Config Section: Browser #
|
859
|
+
|
860
|
+
_create_section("browser", "Configuration of non-UI browser options.")
|
861
|
+
|
862
|
+
|
863
|
+
_create_option(
|
864
|
+
"browser.serverAddress",
|
865
|
+
description="""
|
866
|
+
Internet address where users should point their browsers in order to
|
867
|
+
connect to the app. Can be IP address or DNS name and path.
|
868
|
+
|
869
|
+
This is used to:
|
870
|
+
- Set the correct URL for CORS and XSRF protection purposes.
|
871
|
+
- Show the URL on the terminal
|
872
|
+
- Open the browser
|
873
|
+
""",
|
874
|
+
default_val="localhost",
|
875
|
+
type_=str,
|
876
|
+
)
|
877
|
+
|
878
|
+
|
879
|
+
_create_option(
|
880
|
+
"browser.gatherUsageStats",
|
881
|
+
description="""
|
882
|
+
Whether to send usage statistics to Streamlit.
|
883
|
+
""",
|
884
|
+
default_val=True,
|
885
|
+
type_=bool,
|
886
|
+
)
|
887
|
+
|
888
|
+
|
889
|
+
@_create_option("browser.serverPort", type_=int)
|
890
|
+
def _browser_server_port() -> int:
|
891
|
+
"""Port where users should point their browsers in order to connect to the
|
892
|
+
app.
|
893
|
+
|
894
|
+
This is used to:
|
895
|
+
- Set the correct URL for XSRF protection purposes.
|
896
|
+
- Show the URL on the terminal (part of `streamlit run`).
|
897
|
+
- Open the browser automatically (part of `streamlit run`).
|
898
|
+
|
899
|
+
This option is for advanced use cases. To change the port of your app, use
|
900
|
+
`server.Port` instead. Don't use port 3000 which is reserved for internal
|
901
|
+
development.
|
902
|
+
|
903
|
+
Default: whatever value is set in server.port.
|
904
|
+
"""
|
905
|
+
return int(get_option("server.port"))
|
906
|
+
|
907
|
+
|
908
|
+
_SSL_PRODUCTION_WARNING = [
|
909
|
+
"DO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through "
|
910
|
+
"security audits or performance tests. For the production environment, "
|
911
|
+
"we recommend performing SSL termination by the load balancer or the reverse proxy."
|
912
|
+
]
|
913
|
+
|
914
|
+
_create_option(
|
915
|
+
"server.sslCertFile",
|
916
|
+
description=(
|
917
|
+
f"""
|
918
|
+
Server certificate file for connecting via HTTPS.
|
919
|
+
Must be set at the same time as "server.sslKeyFile".
|
920
|
+
|
921
|
+
{_SSL_PRODUCTION_WARNING}
|
922
|
+
"""
|
923
|
+
),
|
924
|
+
)
|
925
|
+
|
926
|
+
_create_option(
|
927
|
+
"server.sslKeyFile",
|
928
|
+
description=(
|
929
|
+
f"""
|
930
|
+
Cryptographic key file for connecting via HTTPS.
|
931
|
+
Must be set at the same time as "server.sslCertFile".
|
932
|
+
|
933
|
+
{_SSL_PRODUCTION_WARNING}
|
934
|
+
"""
|
935
|
+
),
|
936
|
+
)
|
937
|
+
|
938
|
+
# Config Section: UI #
|
939
|
+
|
940
|
+
_create_section("ui", "Configuration of UI elements displayed in the browser.")
|
941
|
+
|
942
|
+
_create_option(
|
943
|
+
"ui.hideTopBar",
|
944
|
+
description="""
|
945
|
+
Flag to hide most of the UI elements found at the top of a Streamlit app.
|
946
|
+
|
947
|
+
NOTE: This does *not* hide the main menu in the top-right of an app.
|
948
|
+
""",
|
949
|
+
default_val=False,
|
950
|
+
type_=bool,
|
951
|
+
visibility="hidden",
|
952
|
+
)
|
953
|
+
|
954
|
+
|
955
|
+
# Config Section: Mapbox #
|
956
|
+
|
957
|
+
_create_section("mapbox", "Mapbox configuration that is being used by DeckGL.")
|
958
|
+
|
959
|
+
_create_option(
|
960
|
+
"mapbox.token",
|
961
|
+
description="""
|
962
|
+
Configure Streamlit to use a custom Mapbox
|
963
|
+
token for elements like st.pydeck_chart and st.map.
|
964
|
+
To get a token for yourself, create an account at
|
965
|
+
https://mapbox.com. It's free (for moderate usage levels)!
|
966
|
+
""",
|
967
|
+
default_val="",
|
968
|
+
sensitive=True,
|
969
|
+
)
|
970
|
+
|
971
|
+
|
972
|
+
# Config Section: Magic #
|
973
|
+
|
974
|
+
_create_section("magic", "Settings for how Streamlit pre-processes your script")
|
975
|
+
|
976
|
+
_create_option(
|
977
|
+
"magic.displayRootDocString",
|
978
|
+
description="""
|
979
|
+
Streamlit's "magic" parser typically skips strings that appear to be
|
980
|
+
docstrings. When this flag is set to True, Streamlit will instead display
|
981
|
+
the root-level docstring in the app, just like any other magic string.
|
982
|
+
This is useful for things like notebooks.
|
983
|
+
""",
|
984
|
+
visibility="hidden",
|
985
|
+
default_val=False,
|
986
|
+
type_=bool,
|
987
|
+
)
|
988
|
+
|
989
|
+
_create_option(
|
990
|
+
"magic.displayLastExprIfNoSemicolon",
|
991
|
+
description="""
|
992
|
+
Make Streamlit's "magic" parser always display the last expression in the
|
993
|
+
root file if it has no semicolon at the end. This matches the behavior of
|
994
|
+
Jupyter notebooks, for example.
|
995
|
+
""",
|
996
|
+
visibility="hidden",
|
997
|
+
default_val=False,
|
998
|
+
type_=bool,
|
999
|
+
)
|
1000
|
+
|
1001
|
+
|
1002
|
+
# Config Section: Custom Theme #
|
1003
|
+
|
1004
|
+
_create_section("theme", "Settings to define a custom theme for your Streamlit app.")
|
1005
|
+
|
1006
|
+
_create_option(
|
1007
|
+
"theme.base",
|
1008
|
+
description="""
|
1009
|
+
The preset Streamlit theme that your custom theme inherits from.
|
1010
|
+
One of "light" or "dark".
|
1011
|
+
""",
|
1012
|
+
)
|
1013
|
+
|
1014
|
+
_create_option(
|
1015
|
+
"theme.primaryColor",
|
1016
|
+
description="Primary accent color for interactive elements.",
|
1017
|
+
)
|
1018
|
+
|
1019
|
+
_create_option(
|
1020
|
+
"theme.backgroundColor",
|
1021
|
+
description="Background color for the main content area.",
|
1022
|
+
)
|
1023
|
+
|
1024
|
+
_create_option(
|
1025
|
+
"theme.secondaryBackgroundColor",
|
1026
|
+
description="Background color used for the sidebar and most interactive widgets.",
|
1027
|
+
)
|
1028
|
+
|
1029
|
+
_create_option(
|
1030
|
+
"theme.textColor",
|
1031
|
+
description="Color used for almost all text.",
|
1032
|
+
)
|
1033
|
+
|
1034
|
+
_create_option(
|
1035
|
+
"theme.linkColor",
|
1036
|
+
description="Color used for all links.",
|
1037
|
+
visibility="hidden",
|
1038
|
+
)
|
1039
|
+
|
1040
|
+
_create_option(
|
1041
|
+
"theme.font",
|
1042
|
+
description="""
|
1043
|
+
The font family for all text in the app, except code blocks. One of "sans serif",
|
1044
|
+
"serif", or "monospace".
|
1045
|
+
To use a custom font, it needs to be added via [theme.fontFaces].
|
1046
|
+
""",
|
1047
|
+
)
|
1048
|
+
|
1049
|
+
_create_option(
|
1050
|
+
"theme.codeFont",
|
1051
|
+
description="""
|
1052
|
+
The font family to use for code (monospace) in the app.
|
1053
|
+
To use a custom font, it needs to be added via [theme.fontFaces].
|
1054
|
+
""",
|
1055
|
+
visibility="hidden",
|
1056
|
+
)
|
1057
|
+
|
1058
|
+
_create_option(
|
1059
|
+
"theme.fontFaces",
|
1060
|
+
description="""
|
1061
|
+
Configure a list of font faces that you can use for the app & code fonts.
|
1062
|
+
""",
|
1063
|
+
visibility="hidden",
|
1064
|
+
)
|
1065
|
+
|
1066
|
+
|
1067
|
+
_create_option(
|
1068
|
+
"theme.baseRadius",
|
1069
|
+
description="""
|
1070
|
+
The radius used as basis for the corners of most UI elements. Can be:
|
1071
|
+
"none", "small", "medium", "large", "full", or the number in pixel or rem.
|
1072
|
+
For example: "10px", "0.5rem", "1.2rem", "2rem".
|
1073
|
+
""",
|
1074
|
+
visibility="hidden",
|
1075
|
+
)
|
1076
|
+
|
1077
|
+
_create_option(
|
1078
|
+
"theme.borderColor",
|
1079
|
+
description="""
|
1080
|
+
The color of the border around elements.
|
1081
|
+
""",
|
1082
|
+
visibility="hidden",
|
1083
|
+
)
|
1084
|
+
|
1085
|
+
_create_option(
|
1086
|
+
"theme.showBorderAroundInputs",
|
1087
|
+
description="""
|
1088
|
+
Whether to show a border around input elements (e.g. text_input, number_input,
|
1089
|
+
file_uploader, etc).
|
1090
|
+
""",
|
1091
|
+
type_=bool,
|
1092
|
+
visibility="hidden",
|
1093
|
+
)
|
1094
|
+
|
1095
|
+
_create_option(
|
1096
|
+
"theme.baseFontSize",
|
1097
|
+
description="""
|
1098
|
+
Sets the root font size (in pixels) for the app, which determines the overall
|
1099
|
+
scale of text and UI elements. The default base font size is 16.
|
1100
|
+
""",
|
1101
|
+
type_=int,
|
1102
|
+
visibility="hidden",
|
1103
|
+
)
|
1104
|
+
|
1105
|
+
_create_option(
|
1106
|
+
"theme.showSidebarSeparator",
|
1107
|
+
description="""
|
1108
|
+
Whether to show a vertical separator between the sidebar and the main content.
|
1109
|
+
""",
|
1110
|
+
type_=bool,
|
1111
|
+
visibility="hidden",
|
1112
|
+
)
|
1113
|
+
|
1114
|
+
# Config Section: Secrets #
|
1115
|
+
|
1116
|
+
_create_section("secrets", "Secrets configuration.")
|
1117
|
+
|
1118
|
+
_create_option(
|
1119
|
+
"secrets.files",
|
1120
|
+
description="""
|
1121
|
+
List of locations where secrets are searched. An entry can be a path to a
|
1122
|
+
TOML file or directory path where Kubernetes style secrets are saved.
|
1123
|
+
Order is important, import is first to last, so secrets in later files
|
1124
|
+
will take precedence over earlier ones.
|
1125
|
+
""",
|
1126
|
+
default_val=[
|
1127
|
+
# NOTE: The order here is important! Project-level secrets should overwrite global
|
1128
|
+
# secrets.
|
1129
|
+
file_util.get_streamlit_file_path("secrets.toml"),
|
1130
|
+
file_util.get_project_streamlit_file_path("secrets.toml"),
|
1131
|
+
],
|
1132
|
+
)
|
1133
|
+
|
1134
|
+
|
1135
|
+
def get_where_defined(key: str) -> str:
|
1136
|
+
"""Indicate where (e.g. in which file) this option was defined.
|
1137
|
+
|
1138
|
+
Parameters
|
1139
|
+
----------
|
1140
|
+
key : str
|
1141
|
+
The config option key of the form "section.optionName"
|
1142
|
+
|
1143
|
+
"""
|
1144
|
+
with _config_lock:
|
1145
|
+
config_options = get_config_options()
|
1146
|
+
|
1147
|
+
if key not in config_options:
|
1148
|
+
raise RuntimeError('Config key "%s" not defined.' % key)
|
1149
|
+
return config_options[key].where_defined
|
1150
|
+
|
1151
|
+
|
1152
|
+
def _is_unset(option_name: str) -> bool:
|
1153
|
+
"""Check if a given option has not been set by the user.
|
1154
|
+
|
1155
|
+
Parameters
|
1156
|
+
----------
|
1157
|
+
option_name : str
|
1158
|
+
The option to check
|
1159
|
+
|
1160
|
+
|
1161
|
+
Returns
|
1162
|
+
-------
|
1163
|
+
bool
|
1164
|
+
True if the option has not been set by the user.
|
1165
|
+
|
1166
|
+
"""
|
1167
|
+
return get_where_defined(option_name) == ConfigOption.DEFAULT_DEFINITION
|
1168
|
+
|
1169
|
+
|
1170
|
+
def is_manually_set(option_name: str) -> bool:
|
1171
|
+
"""Check if a given option was actually defined by the user.
|
1172
|
+
|
1173
|
+
Parameters
|
1174
|
+
----------
|
1175
|
+
option_name : str
|
1176
|
+
The option to check
|
1177
|
+
|
1178
|
+
|
1179
|
+
Returns
|
1180
|
+
-------
|
1181
|
+
bool
|
1182
|
+
True if the option has been set by the user.
|
1183
|
+
|
1184
|
+
"""
|
1185
|
+
return get_where_defined(option_name) not in (
|
1186
|
+
ConfigOption.DEFAULT_DEFINITION,
|
1187
|
+
ConfigOption.STREAMLIT_DEFINITION,
|
1188
|
+
)
|
1189
|
+
|
1190
|
+
|
1191
|
+
def show_config() -> None:
|
1192
|
+
"""Print all config options to the terminal."""
|
1193
|
+
with _config_lock:
|
1194
|
+
assert _config_options is not None, (
|
1195
|
+
"_config_options should always be populated here."
|
1196
|
+
)
|
1197
|
+
config_util.show_config(_section_descriptions, _config_options)
|
1198
|
+
|
1199
|
+
|
1200
|
+
# Load Config Files #
|
1201
|
+
|
1202
|
+
|
1203
|
+
def _set_option(key: str, value: Any, where_defined: str) -> None:
|
1204
|
+
"""Set a config option by key / value pair.
|
1205
|
+
|
1206
|
+
This function assumes that the _config_options dictionary has already been
|
1207
|
+
populated and thus should only be used within this file and by tests.
|
1208
|
+
|
1209
|
+
Parameters
|
1210
|
+
----------
|
1211
|
+
key : str
|
1212
|
+
The key of the option, like "logger.level".
|
1213
|
+
value
|
1214
|
+
The value of the option.
|
1215
|
+
where_defined : str
|
1216
|
+
Tells the config system where this was set.
|
1217
|
+
|
1218
|
+
"""
|
1219
|
+
assert _config_options is not None, (
|
1220
|
+
"_config_options should always be populated here."
|
1221
|
+
)
|
1222
|
+
if key not in _config_options:
|
1223
|
+
# Import logger locally to prevent circular references
|
1224
|
+
from streamlit.logger import get_logger
|
1225
|
+
|
1226
|
+
LOGGER = get_logger(__name__)
|
1227
|
+
|
1228
|
+
LOGGER.warning(
|
1229
|
+
f'"{key}" is not a valid config option. If you previously had this config '
|
1230
|
+
"option set, it may have been removed."
|
1231
|
+
)
|
1232
|
+
|
1233
|
+
else:
|
1234
|
+
_config_options[key].set_value(value, where_defined)
|
1235
|
+
|
1236
|
+
|
1237
|
+
def _update_config_with_sensitive_env_var(config_options: dict[str, ConfigOption]):
|
1238
|
+
"""Update the config system by parsing the environment variable.
|
1239
|
+
|
1240
|
+
This should only be called from get_config_options.
|
1241
|
+
"""
|
1242
|
+
for opt_name, opt_val in config_options.items():
|
1243
|
+
if not opt_val.sensitive:
|
1244
|
+
continue
|
1245
|
+
env_var_value = os.environ.get(opt_val.env_var)
|
1246
|
+
if env_var_value is None:
|
1247
|
+
continue
|
1248
|
+
_set_option(opt_name, env_var_value, _DEFINED_BY_ENV_VAR)
|
1249
|
+
|
1250
|
+
|
1251
|
+
def _update_config_with_toml(raw_toml: str, where_defined: str) -> None:
|
1252
|
+
"""Update the config system by parsing this string.
|
1253
|
+
|
1254
|
+
This should only be called from get_config_options.
|
1255
|
+
|
1256
|
+
Parameters
|
1257
|
+
----------
|
1258
|
+
raw_toml : str
|
1259
|
+
The TOML file to parse to update the config values.
|
1260
|
+
where_defined : str
|
1261
|
+
Tells the config system where this was set.
|
1262
|
+
|
1263
|
+
"""
|
1264
|
+
import toml
|
1265
|
+
|
1266
|
+
parsed_config_file = toml.loads(raw_toml)
|
1267
|
+
|
1268
|
+
for section, options in parsed_config_file.items():
|
1269
|
+
for name, value in options.items():
|
1270
|
+
value = _maybe_read_env_variable(value)
|
1271
|
+
_set_option(f"{section}.{name}", value, where_defined)
|
1272
|
+
|
1273
|
+
|
1274
|
+
def _maybe_read_env_variable(value: Any) -> Any:
|
1275
|
+
"""If value is "env:foo", return value of environment variable "foo".
|
1276
|
+
|
1277
|
+
If value is not in the shape above, returns the value right back.
|
1278
|
+
|
1279
|
+
Parameters
|
1280
|
+
----------
|
1281
|
+
value : any
|
1282
|
+
The value to check
|
1283
|
+
|
1284
|
+
Returns
|
1285
|
+
-------
|
1286
|
+
any
|
1287
|
+
Either returns value right back, or the value of the environment
|
1288
|
+
variable.
|
1289
|
+
|
1290
|
+
"""
|
1291
|
+
if isinstance(value, str) and value.startswith("env:"):
|
1292
|
+
var_name = value[len("env:") :]
|
1293
|
+
env_var = os.environ.get(var_name)
|
1294
|
+
|
1295
|
+
if env_var is None:
|
1296
|
+
# Import logger locally to prevent circular references
|
1297
|
+
from streamlit.logger import get_logger
|
1298
|
+
|
1299
|
+
LOGGER = get_logger(__name__)
|
1300
|
+
|
1301
|
+
LOGGER.error("No environment variable called %s", var_name)
|
1302
|
+
else:
|
1303
|
+
return _maybe_convert_to_number(env_var)
|
1304
|
+
|
1305
|
+
return value
|
1306
|
+
|
1307
|
+
|
1308
|
+
def _maybe_convert_to_number(v: Any) -> Any:
|
1309
|
+
"""Convert v to int or float, or leave it as is."""
|
1310
|
+
try:
|
1311
|
+
return int(v)
|
1312
|
+
except Exception:
|
1313
|
+
pass
|
1314
|
+
|
1315
|
+
try:
|
1316
|
+
return float(v)
|
1317
|
+
except Exception:
|
1318
|
+
pass
|
1319
|
+
|
1320
|
+
return v
|
1321
|
+
|
1322
|
+
|
1323
|
+
# Allow outside modules to wait for the config file to be parsed before doing
|
1324
|
+
# something.
|
1325
|
+
_on_config_parsed = Signal(doc="Emitted when the config file is parsed.")
|
1326
|
+
|
1327
|
+
CONFIG_FILENAMES = [
|
1328
|
+
file_util.get_streamlit_file_path("config.toml"),
|
1329
|
+
file_util.get_project_streamlit_file_path("config.toml"),
|
1330
|
+
]
|
1331
|
+
|
1332
|
+
|
1333
|
+
def get_config_options(
|
1334
|
+
force_reparse=False, options_from_flags: dict[str, Any] | None = None
|
1335
|
+
) -> dict[str, ConfigOption]:
|
1336
|
+
"""Create and return a dict mapping config option names to their values,
|
1337
|
+
returning a cached dict if possible.
|
1338
|
+
|
1339
|
+
Config option values are sourced from the following locations. Values
|
1340
|
+
set in locations further down the list overwrite those set earlier.
|
1341
|
+
1. default values defined in this file
|
1342
|
+
2. the global `~/.streamlit/config.toml` file
|
1343
|
+
3. per-project `$CWD/.streamlit/config.toml` files
|
1344
|
+
4. environment variables such as `STREAMLIT_SERVER_PORT`
|
1345
|
+
5. command line flags passed to `streamlit run`
|
1346
|
+
|
1347
|
+
Parameters
|
1348
|
+
----------
|
1349
|
+
force_reparse : bool
|
1350
|
+
Force config files to be parsed so that we pick up any changes to them.
|
1351
|
+
|
1352
|
+
options_from_flags : dict[str, any] or None
|
1353
|
+
Config options that we received via CLI flag.
|
1354
|
+
|
1355
|
+
Returns
|
1356
|
+
-------
|
1357
|
+
dict[str, ConfigOption]
|
1358
|
+
An ordered dict that maps config option names to their values.
|
1359
|
+
"""
|
1360
|
+
global _config_options
|
1361
|
+
|
1362
|
+
if not options_from_flags:
|
1363
|
+
options_from_flags = {}
|
1364
|
+
|
1365
|
+
# Avoid grabbing the lock in the case where there's nothing for us to do.
|
1366
|
+
config_options = _config_options
|
1367
|
+
if config_options and not force_reparse:
|
1368
|
+
return config_options
|
1369
|
+
|
1370
|
+
with _config_lock:
|
1371
|
+
# Short-circuit if config files were parsed while we were waiting on
|
1372
|
+
# the lock.
|
1373
|
+
if _config_options and not force_reparse:
|
1374
|
+
return _config_options
|
1375
|
+
|
1376
|
+
old_options = _config_options
|
1377
|
+
_config_options = copy.deepcopy(_config_options_template)
|
1378
|
+
|
1379
|
+
# Values set in files later in the CONFIG_FILENAMES list overwrite those
|
1380
|
+
# set earlier.
|
1381
|
+
for filename in CONFIG_FILENAMES:
|
1382
|
+
if not os.path.exists(filename):
|
1383
|
+
continue
|
1384
|
+
|
1385
|
+
with open(filename, encoding="utf-8") as input:
|
1386
|
+
file_contents = input.read()
|
1387
|
+
|
1388
|
+
_update_config_with_toml(file_contents, filename)
|
1389
|
+
|
1390
|
+
_update_config_with_sensitive_env_var(_config_options)
|
1391
|
+
|
1392
|
+
for opt_name, opt_val in options_from_flags.items():
|
1393
|
+
_set_option(opt_name, opt_val, _DEFINED_BY_FLAG)
|
1394
|
+
|
1395
|
+
if old_options and config_util.server_option_changed(
|
1396
|
+
old_options, _config_options
|
1397
|
+
):
|
1398
|
+
# Import logger locally to prevent circular references.
|
1399
|
+
from streamlit.logger import get_logger
|
1400
|
+
|
1401
|
+
LOGGER = get_logger(__name__)
|
1402
|
+
LOGGER.warning(
|
1403
|
+
"An update to the [server] config option section was detected."
|
1404
|
+
" To have these changes be reflected, please restart streamlit."
|
1405
|
+
)
|
1406
|
+
|
1407
|
+
_on_config_parsed.send()
|
1408
|
+
return _config_options
|
1409
|
+
|
1410
|
+
|
1411
|
+
def _check_conflicts() -> None:
|
1412
|
+
# Node-related conflicts
|
1413
|
+
|
1414
|
+
# When using the Node server, we must always connect to 8501 (this is
|
1415
|
+
# hard-coded in JS). Otherwise, the browser would decide what port to
|
1416
|
+
# connect to based on window.location.port, which in dev is going to
|
1417
|
+
# be (3000)
|
1418
|
+
|
1419
|
+
# Import logger locally to prevent circular references
|
1420
|
+
from streamlit.logger import get_logger
|
1421
|
+
|
1422
|
+
LOGGER = get_logger(__name__)
|
1423
|
+
|
1424
|
+
if get_option("global.developmentMode"):
|
1425
|
+
assert _is_unset("server.port"), (
|
1426
|
+
"server.port does not work when global.developmentMode is true."
|
1427
|
+
)
|
1428
|
+
|
1429
|
+
assert _is_unset("browser.serverPort"), (
|
1430
|
+
"browser.serverPort does not work when global.developmentMode is true."
|
1431
|
+
)
|
1432
|
+
|
1433
|
+
# XSRF conflicts
|
1434
|
+
if get_option("server.enableXsrfProtection"):
|
1435
|
+
if not get_option("server.enableCORS") or get_option("global.developmentMode"):
|
1436
|
+
LOGGER.warning(
|
1437
|
+
"""
|
1438
|
+
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
|
1439
|
+
As a result, 'server.enableCORS' is being overridden to 'true'.
|
1440
|
+
|
1441
|
+
More information:
|
1442
|
+
In order to protect against CSRF attacks, we send a cookie with each request.
|
1443
|
+
To do so, we must specify allowable origins, which places a restriction on
|
1444
|
+
cross-origin resource sharing.
|
1445
|
+
|
1446
|
+
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
|
1447
|
+
"""
|
1448
|
+
)
|
1449
|
+
|
1450
|
+
|
1451
|
+
def _set_development_mode() -> None:
|
1452
|
+
development.is_development_mode = get_option("global.developmentMode")
|
1453
|
+
|
1454
|
+
|
1455
|
+
def on_config_parsed(
|
1456
|
+
func: Callable[[], None], force_connect=False, lock=False
|
1457
|
+
) -> Callable[[], bool]:
|
1458
|
+
"""Wait for the config file to be parsed then call func.
|
1459
|
+
|
1460
|
+
If the config file has already been parsed, just calls func immediately
|
1461
|
+
unless force_connect is set.
|
1462
|
+
|
1463
|
+
Parameters
|
1464
|
+
----------
|
1465
|
+
func : Callable[[], None]
|
1466
|
+
A function to run on config parse.
|
1467
|
+
|
1468
|
+
force_connect : bool
|
1469
|
+
Wait until the next config file parse to run func, even if config files
|
1470
|
+
have already been parsed.
|
1471
|
+
|
1472
|
+
lock : bool
|
1473
|
+
If set, grab _config_lock before running func.
|
1474
|
+
|
1475
|
+
Returns
|
1476
|
+
-------
|
1477
|
+
Callable[[], bool]
|
1478
|
+
A function that the caller can use to deregister func.
|
1479
|
+
"""
|
1480
|
+
|
1481
|
+
# We need to use the same receiver when we connect or disconnect on the
|
1482
|
+
# Signal. If we don't do this, then the registered receiver won't be released
|
1483
|
+
# leading to a memory leak because the Signal will keep a reference of the
|
1484
|
+
# callable argument. When the callable argument is an object method, then
|
1485
|
+
# the reference to that object won't be released.
|
1486
|
+
def receiver(_):
|
1487
|
+
return func_with_lock()
|
1488
|
+
|
1489
|
+
def disconnect():
|
1490
|
+
return _on_config_parsed.disconnect(receiver)
|
1491
|
+
|
1492
|
+
def func_with_lock():
|
1493
|
+
if lock:
|
1494
|
+
with _config_lock:
|
1495
|
+
func()
|
1496
|
+
else:
|
1497
|
+
func()
|
1498
|
+
|
1499
|
+
if force_connect or not _config_options:
|
1500
|
+
# weak=False so that we have control of when the on_config_parsed
|
1501
|
+
# callback is deregistered.
|
1502
|
+
_on_config_parsed.connect(receiver, weak=False)
|
1503
|
+
else:
|
1504
|
+
func_with_lock()
|
1505
|
+
|
1506
|
+
return disconnect
|
1507
|
+
|
1508
|
+
|
1509
|
+
# Run _check_conflicts only once the config file is parsed in order to avoid
|
1510
|
+
# loops. We also need to grab the lock when running _check_conflicts since it
|
1511
|
+
# may edit config options based on the values of other config options.
|
1512
|
+
on_config_parsed(_check_conflicts, lock=True)
|
1513
|
+
on_config_parsed(_set_development_mode)
|