Streamlit in Snowflake: Enable Git integration and multi-file editing for Streamlit in Snowflake apps (Pending)¶
Attention
This behavior change is in the 2025_01 bundle.
For the current status of the bundle, refer to Bundle History.
Streamlit in Snowflake apps behave as follows:
- Before this change:
Git integration and multi-file editing for Streamlit in Snowflake apps are not supported in Snowsight.
- After this change:
Git integration and multi-file editing are supported for new Streamlit in Snowflake apps and include changes in the following areas:
-
Supports connecting Streamlit in Snowflake apps to a Git repository.
Supports creating Streamlit in Snowflake apps from a Git repository.
Supports editing multiple files within Snowsight itself.
Note
The existing Streamlit in Snowflake apps using ROOT_LOCATION work as before, but Git integration and multi-file editing are not supported.
-
Snowsight¶
Create a Streamlit in Snowflake app from a file in a Git repository¶
To create a Streamlit app from a file in a Git repository, do the following:
Sign in to Snowsight.
Select Projects » Streamlit.
Next to + Streamlit, open the drop-down menu and select Create from repository.
For File location in repository, select the repository and branch in the repository that contain the Streamlit app file, then select the specific
.py
file. For details on connecting Snowflake to your Git repository, see Setting up Snowflake to use Git.For App location, select a database and schema to contain the Streamlit app. These cannot be changed after you create the app.
For Query warehouse and App warehouse, select a warehouse.
Select Create to create a Streamlit app from the
.py
file in your Git repository.
Connect a Streamlit in Snowflake app with a Git repository¶
To connect an existing Streamlit app to a Git repository, do the following:
Sign in to Snowsight.
Select Projects » Streamlit and open or create a Streamlit app.
In the Files tab, next to the database object explorer, select Connect Git Repository.
For File location in repository, select the repository and branch in the repository with which you want to sync the Streamlit app.
Select Select Folder.
When you are prompted to commit and push your app to the Git repository, select Push to Git.
Edit multiple files within Snowsight¶
To edit multiple files of your Streamlit in Snowflake app within Snowsight:
Sign in to Snowsight.
Select Projects » Streamlit and open or create a Streamlit app.
In the Files tab, select a file to edit.
Changes to CREATE STREAMLIT and ALTER STREAMLIT commands¶
When this behavior change bundle is enabled, the following changes to CREATE STREAMLIT and ALTER STREAMLIT commands are introduced.
CREATE STREAMLIT¶
The code for Streamlit apps no longer requires a separate stage object; the Streamlit object stores the app code. Using the FROM clause, you can indicate the existing location to copy the code from to the Streamlit app.
Syntax¶
CREATE [ OR REPLACE ] STREAMLIT [ IF NOT EXISTS ] <name>
[ { VERSION <version_alias_name> |
VERSION (COMMENT = <version_comment>) |
VERSION <version_alias_name> (COMMENT = <version_comment>) } ]
[ FROM <source_location>]
MAIN_FILE = '<path_to_main_file_in_root_directory>'
QUERY_WAREHOUSE = <warehouse_name>
[ COMMENT = <create_comment> ]
[ DEFAULT_VERSION = <default_version_name_or_alias> ]
[ TITLE = '<app_title>' ]
[ IMPORTS = ( '<stage_path_and_file_name_to_read>' [ , ... ] ) ]
[ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
Required parameters¶
name
Name of the Streamlit app.
path_to_main_file_in_root_directory
Specifies the filename of the Streamlit app. This filename is relative to the value of
ROOT_LOCATION
.warehouse_name
Specifies the warehouse to run SQL queries issued by the Streamlit app.
Optional parameters¶
version_alias_name
A user-specified version alias name.
version_comment
A user-provided comment for this version.
source_location
A location where the source files are copied from.
create_comment
Specifies a comment for the Streamlit object. By default, there is no value.
default_version_name_or_alias
The name of the default version used.
app_title
Specifies a title for the Streamlit app to display in Snowsight.
stage_path_and_file_name_to_read
The location (stage), path, and name of the file(s) to import.
integration_name
The names of external access integrations needed in order for the Streamlit app code to access external networks.
Examples¶
To create a Streamlit app from a stage, run the CREATE STREAMLIT command, as shown in the following example:
CREATE STREAMLIT app
FROM @streamlit_db.streamlit_schema.streamlit_stage;
MAIN_FILE = 'streamlit_app.py'
QUERY_WAREHOUSE = my_warehouse;
To create a Streamlit app from a Git repository, run the CREATE STREAMLIT command, as shown in the following example:
CREATE STREAMLIT app
FROM @streamlit_db.streamlit_schema.streamlit_repo/branches/streamlit_branch/;
MAIN_FILE = 'streamlit_app.py'
QUERY_WAREHOUSE = my_warehouse;
ALTER STREAMLIT¶
When this behavior change bundle is enabled, the ALTER STREAMLIT command is updated to include the following:
Syntax¶
ALTER STREAMLIT <name> ADD VERSION [ [ IF NOT EXISTS] <version_alias_name> ]
FROM <source_location>
[ COMMENT = <add_version_comment> ]
ALTER STREAMLIT <name> ADD VERSION <version_name>
FROM { <snowgit_tag_uri> | <snowgit_commit_uri> }
[ COMMENT = <git_pull_comment> ]
ALTER STREAMLIT <name> ADD LIVE VERSION [ [IF NOT EXISTS] <version_alias_name> ]
[ FROM LAST ]
[ COMMENT = <add_version_comment> ]
ALTER STREAMLIT <name> VERSION <existing_version_name_or_alias>
SET ALIAS = <new_version_name_alias>
ALTER STREAMLIT <name> COMMIT [ VERSION <live_version_alias> ] [COMMENT = <version_comment>]
ALTER STREAMLIT <name> SET DEFAULT_VERSION = <version_name> | <version_name_alias>
ALTER STREAMLIT <name> PUSH [TO <git_branch_uri>] [ { GIT_CREDENTIALS = <snowflake_secret> | USERNAME = <git_username> password = <git_password> } NAME = <git_author_name> EMAIL = <git_author_email> ] [ COMMENT = <git_push_comment>]
ALTER STREAMLIT <name> ABORT [ VERSION <live_version_alias> ]
ALTER STREAMLIT <name> PULL
Parameters¶
name
Name of the Streamlit app.
version_alias_name
A user-specified version alias name.
source_location
A location where the source files are copied from. Requires the OWNERSHIP privilege.
ALTER STREAMLIT name PUSH
Pushes the latest committed changes to the Git repo, using the branch stored in the base version if
git_branch_uri
is not specified.If the base version is not based on a Git branch, throws an error. Requires OWNERSHIP privilege.
git-branch-uri
Target branch to push committed changes to.
git_author_name
Name of the git author to use.
git_author_email
A valid e-mail address to use as the git author’s name.
git_push_comment
A user-specified comment to include in the git push.
ALTER STREAMLIT name ABORT
Removes an existing version and deletes its files. If no version specified, it deletes live_version by default. Requires OWNERSHIP privilege.
ALTER STREAMLIT name PULL
Pulls latest changes from source to the live version of this Streamlit. Requires OWNERSHIP privilege.
New columns in DESCRIBE STREAMLIT output¶
When this behavior change bundle is enabled, the output of the DESCRIBE STREAMLIT command includes the following new columns:
Column name |
Description |
---|---|
default_version |
For future use. |
default_version_name |
For future use. |
default_version_alias |
For future use. |
default_version_location_uri |
For future use. |
default_version_source_location_uri |
For future use. |
default_version_git_commit_hash |
For future use. |
live_version |
String. Specifies which version is the live version for this app. |
live_version_name |
String. The name of the live version for this app. |
live_version_alias |
String. The alias of the live version for this app. |
live_version_location_uri |
String. The URI to where files of the live version are stored. |
live_version_source_location_uri |
String. Specifies the URI to where the live_version was copied from. Null if this Streamlit was not cloned. |
live_version_git_commit_hash |
String. Hexademical hash of the git commit that the live_version points to. Null if a Git repository is not connected. |
Ref: 1888