了解不同类型的 Streamlit 对象

Snowflake 中的 Streamlit 对象有两个重要差异,这会影响它们的功能、限制和管理:

  • How the source location is specified: using the ROOT_LOCATION parameter (legacy) or the FROM parameter (recommended).
  • The runtime environment: warehouse runtime or container runtime.

本页介绍了源位置规范之间的差异,这些差异反过来又会影响可以使用的运行时环境。

For more information about runtime environments, see Runtime environments for Streamlit apps. For a checklist to migrate from warehouse to container runtimes, see Migrating between runtime environments.

源位置

When you create Streamlit apps in Snowflake, you can use two different parameters to specify the location of your source files: ROOT_LOCATION or FROM. ROOT_LOCATION is a legacy parameter that has several restrictions. Currently, FROM is the recommended parameter for new apps and is required to access the latest Streamlit in Snowflake features, including container runtimes. This page explains how to differentiate between the two types of apps. To enable the latest Streamlit in Snowflake features, you must upgrade your legacy Streamlits. For more information, see Migrating between runtime environments.

FROM 参数(推荐)

FROM 参数将文件从指定位置复制到 Streamlit 对象内的嵌入式暂存区中。这是当前创建 Streamlit 应用程序的推荐方法。

优势:

  • 同时支持仓库和容器运行时。
  • Enables multi-file editing in Snowsight.
  • 与 Git 集成功能兼容。
  • 在 Streamlit 对象中使用嵌入式的、带版本的暂存区。

语法:

CREATE STREAMLIT my_app
FROM '@my_stage/app_folder'
MAIN_FILE = 'streamlit_app.py';

ROOT_LOCATION 参数(旧版)

The ROOT_LOCATION parameter creates an app that references an internal stage as its source. This is a legacy approach with several limitations. If you created your app using an older version of Snowsight, your app’s root location might be a snow URL (snow://) instead of a named stage.

限制:

  • 仅支持仓库运行时(无法使用容器运行时)。
  • No multi-file editing support in Snowsight.
  • 无法使用 Git 集成功能。
  • 需要持续访问内部暂存区。

语法:

CREATE STREAMLIT my_app
ROOT_LOCATION = '@my_stage/app_folder'
MAIN_FILE = '/streamlit_app.py';

确定应用程序的源位置类型

You can determine which parameter was used to create your app by examining the DESCRIBE STREAMLIT output:

DESCRIBE STREAMLIT my_app;
  • ROOT_LOCATION-based apps return fewer columns and include a root_location column.
  • FROM-based apps return more columns and include a live_version_location_uri column.

When you edit an app in Snowsight, you are pushing updates to either the root_location or the live_version_location_uri, depending on the app type. You can update both types of apps using SQL commands to PUT or COPY FILES to these locations.