部署 Streamlit 应用程序¶
snow streamlit deploy 命令会在所选数据库和架构中创建一个新的 Streamlit 对象。默认情况下,此命令会在您的当前工作目录中查找名为 streamlit_app.py 的主文件。
先决条件¶
在使用 Snowflake CLI 部署 Streamlit 应用程序之前,应满足以下先决条件:
确保您拥有具有正确目录结构的本地 Streamlit 应用程序,并且必须存在
snowflake.yml项目定义文件。Ensure that your account has the correct privileges as described in 创建和使用 Streamlit 应用程序所需的权限.
确保可以创建或访问您能在其中上传 Streamlit 应用程序文件的命名暂存区。
如何部署 Streamlit 应用程序¶
备注
随着 Snowflake CLI 3.14.0 版本的发布,snow streamlit deploy 命令现已采用更新后的 CREATE STREAMLIT 语法 (FROM source_location),取代了已弃用的语法 (ROOT_LOCATION = '<stage_path_and_root_directory>')。要继续使用已弃用的语法,可以使用 --legacy 选项。
snow streamlit deploy 命令用于将本地文件上传到暂存区,并在您选择的数据库和架构内创建新的 Streamlit 对象。项目定义文件 应指定主 Python 文件和查询仓库。您还可以指定以下选项:
--replace:替换指定的 Streamlit 应用程序(如果它已经存在)。--open:部署应用程序后,在默认浏览器中打开 Streamlit 应用程序。--prune:移除暂存区中存在的文件,但不移除本地文件系统中的文件(默认情况下不移除任何文件)。--legacy:选择使用 时默认使用的角色和仓库。使用已弃用的 SQLsyntax (ROOT_LOCATION = '<stage_path_and_root_directory>')。
By default the command automatically deploys the environment.yml file and the content of the pages/
directory, if any of those exists. You can use different files by using command-line options.
有关创建 Streamlit 应用程序的更多信息,请参阅 CLI snow streamlit deploy 和 SQL CREATE STREAMLIT 命令。