限制和库变更

本主题介绍当 Streamlit 功能在 Snowflake 中的表现与开源库不同时,所涉及的限制和功能行为变更。

To view release notes for each Streamlit version, see Streamlit documentation (https://docs.streamlit.io/develop/quick-reference/release-notes).

Limitations and changes for all runtimes

The following limitations apply to all Streamlit in Snowflake apps, regardless of runtime environment:

Limitations and changes that vary by runtime

The following table compares limitations that differ between warehouse runtimes and container runtimes (Preview). For more information about runtime environments, see Streamlit 应用程序的运行时环境.

Limitation

Warehouse runtime

Container runtime (Preview)

Python versions

3.9, 3.10, 3.11

3.11 only

Streamlit versions

1.22+ (limited selection)

1.50+ (any version, including streamlit-nightly versions)

Package-based v2 components

Not supported

Supported

Displaying large amounts of data

32 MB

Configurable

File uploads

200 MB

Configurable

Mapbox and Carto

Requires acknowledgement of the External Offerings Terms.

Not subject to the External Offerings Terms.

Caching

Single-session caching. Cached values can't be shared between sessions.

Fully supported. Cached values are shared across all viewer sessions unless you use session-scoping in the cache decorator.

ROOT_LOCATION parameter

Supported as a legacy parameter in CREATE STREAMLIT.

Not supported

Maintenance window

Not applicable

Subject to the Snowpark Container Services maintenance window.

Static file serving

Not supported

Supported

Limitation details

不支持的 Streamlit 功能

The following Streamlit features are not fully supported in Streamlit in Snowflake:

  • st.set_page_config (https://docs.streamlit.io/develop/api-reference/configuration/st.set_page_config):

    The page_title, page_icon, and menu_items properties of the st.set_page_config command aren't supported.

  • config.toml (https://docs.streamlit.io/develop/api-reference/configuration/config.toml) file:

    For a summary of supported and unsupported configuration options, see Streamlit 配置.

Loading external resources

All Streamlit in Snowflake apps run within a Content Security Policy (CSP) that restricts what resources can be loaded. The CSP blocks loading code from external domains and embedding external content in iframes. It also blocks front-end calls that are generally considered unsafe, like eval(). For more information about the CSP, see 内容安全策略.

例如,以下代码运行时没有 Python 错误,但不会在浏览器中加载或执行脚本:

# This won't work
st.html(
   "<script src="http://www.example.com/example.js"></script>",
   unsafe_allow_javascript=True
)
Copy

备注

根据 Snowflake 责任共担模式,应用程序开发人员负责安全检查和 Streamlit in Snowflake 应用程序代码的软件供应链。

Custom components

As a consequence of the CSP, custom components can't load scripts from external domains in warehouse and container runtimes. Because package-based components use an asset directory to serve their static content, the following differences apply:

  • In warehouse runtimes, package-based v2 components that utilize an asset directory aren't supported.

  • In container runtimes, package-based v2 components are fully supported.

To use a v2 custom component in a warehouse runtime, it must be defined with inline HTML, CSS, and JavaScript.

备注

Components imported from a third-party source are subject to the license attached to that component. You are responsible for ensuring that your use of a component is permitted by its license.

Snowflake doesn't build or maintain third-party components that you might import into Streamlit in Snowflake. Use of such components is at your own risk and is not subject to any warranties, service level agreements, or other similar guarantees by Snowflake.

Query parameters

For st.query_params (https://docs.streamlit.io/develop/api-reference/caching-and-state/st.query_params) in Streamlit in Snowflake, a streamlit- prefix is added to each query parameter key in the URL. This prefix isn't included when you use st.query_params to get or set a value.

例如,请考虑以下 URL:

https://app.snowflake.cn/org/account_name/#/streamlit-apps/DB.SCHEMA.APP_NAME?streamlit-first_key=one&streamlit-second_key=two

The parameters in this URL are accessible in st.query_params as the following key-value pairs:

{
   "first_key" : "one",
   "second_key" : "two"
}
Copy

Displaying large amounts of data

Streamlit apps running in warehouse runtimes have a 32-MB limit on the size of messages exchanged between the backend and the frontend. If you attempt to display more than 32 MB of data with a single Streamlit command, like st.dataframe, the following error occurs:

MessageSizeError: Data Size exceeds message limit

要避免此限制,请将 Streamlit 应用程序设计为以小于 32 MB 的增量显示数据。对于可运行查询大小或内存中可拥有的数据量,没有明确的限制。

In container runtimes, this limit defaults to 200 MB and can be changed by setting the Streamlit configuration option, server.maxMessageSize. However, the message size can't exceed the capacity of the container's memory. Allowing larger messages could exceed the container's memory limit, especially if concurrent viewers are present.

File uploads

The default file-size limit for st.file_uploader (https://docs.streamlit.io/develop/api-reference/widgets/st.file_uploader) and st.chat_input (https://docs.streamlit.io/develop/api-reference/chat/st.chat_input) is 200 MB. In warehouse runtimes, this isn't configurable. In container runtimes, this limit can be changed by setting the Streamlit configuration option, server.maxUploadSize. However, the file size can't exceed the capacity of the container's memory. Allowing larger files could exceed the container's memory limit, especially if concurrent viewers are present.

For larger files, consider processing data in smaller batches or using alternative uploading methods.

Mapbox and Carto

Mapbox and Carto provide map tiles when you use the st.map (https://docs.streamlit.io/develop/api-reference/charts/st.map) or st.pydeck_chart (https://docs.streamlit.io/develop/api-reference/charts/st.pydeck_chart) Streamlit commands.

In warehouse runtimes, which manage their packages with conda, Mapbox and Carto are third-party applications that are subject to Snowflake's External Offerings Terms.

重要

Mapbox is not available in the People's Republic of China. Snowflake recommends using Carto instead.

To use these commands in warehouse runtimes, you must acknowledge the External Offerings Terms. Container runtimes don't require this acknowledgement.

Caching

Caching is partially supported in warehouse runtimes and fully supported in container runtimes.

In warehouse runtimes, caching is limited to single-session caching. Cached values can't be shared between sessions. In container runtimes, caching is fully supported. Cached values are shared across all viewer sessions.

语言: 中文