Creating a Streamlit app

Prerequisites

Before creating a Streamlit app with Snowflake CLI, you should meet the following prerequisites:

Initialize a Streamlit app

The snow streamlit init command creates a local directory with a sample set of files that help you get started creating a Streamlit app. When you execute this command, Snowflake CLI creates the following directory structure:

example_streamlit/            - project name (default: example_streamlit)
  snowflake.yml               - configuration for snow streamlit commands
  environment.yml             - additional config for Streamlit, for example installing packages
  streamlit_app.py            - entrypoint file of the app
  pages/                      - directory name for Streamlit pages (default pages)
  common/                     - example “shared library”

To initialize a Streamlit app named my-streamlit-app, enter the following command:

snow streamlit init "my-streamlit-app"
Copy

Caution

Files inside a project directory are processed by Snowflake CLI and could be uploaded to Snowflake when executing other snow streamlit commands. You should use caution when putting any sensitive information inside files in a project directory.

For more information about the file structure, see Creating the Streamlit files on your local file system.

Create the project definition for a Streamlit app

Each Streamlit app in Snowflake must include a snowflake.yml project definition file. Streamlit is limited to one application per project definition file.

The following shows a sample snowflake.yml project definition file:

definition_version: 1
streamlit:
  name: streamlit_app
  stage: my_streamlit_stage
  query_warehouse: my_streamlit_warehouse
  main_file: streamlit_app.py
  env_file: environment.yml
  pages_dir: pages/
  additional_source_files:
    - common/hello.py
Copy

The following table describes the properties of a Streamlit project definition.

Streamlit project definition properties

Property

Definition

definition_version

required, int

Version of the project definition schema, which is currently 1.

streamlit.name

required, string

App identifier.

streamlit.stage

optional, string

Stage in which the app’s artifacts will be stored. Default: “streamlit”.

streamlit.query_warehouse

required, string

Snowflake warehouse to host the app.

streamlit.main_file

optional, string

Entrypoint file of the streamlit app. Default: “streamlit_app.py”.

streamlit.env_file

optional, string

File defining additional configurations for the app, such as external dependencies. Default: “environment.yml”.

streamlit.pages_dir

optional, string

Streamlit pages. Default: “pages”.

streamlit.additional_source_files

required, string sequence

List of additional files which should be included into deployment artifacts.