Create and deploy Streamlit apps using Snowsight¶
Streamlit in Snowflake provides a Python editor in Snowsight where you can write, edit, and run code for a Streamlit app. The editor provides auto-completion and displays documentation for Streamlit and Snowpark functions.
Ensure you’ve reviewed the prerequisites before you use Snowsight to work with Streamlit apps.
Note
You can create single-page Streamlit apps by using Snowsight, but to deploy a multi-page Streamlit app, you must use SQL commands. See Create and deploy Streamlit apps using SQL for details.
After deploying a Streamlit app, you can view the multi-page app in Snowsight. See View a Streamlit app for more information.
Create a Streamlit app by using Snowsight¶
Sign in to Snowsight.
In the left navigation bar, select Projects » Streamlit.
Select + Streamlit.
The Create Streamlit App window opens.
Enter a name for your app.
In the Warehouse dropdown, select the warehouse where you want to run your app and execute queries.
In the App location dropdown, select the database and schema for your app.
Select Create.
The Streamlit in Snowflake editor opens an example Streamlit app in Viewer mode. Viewer mode allows you to see how the Streamlit application appears to users.
The Streamlit in Snowflake interface is divided into three panes:
Object browser: Allows you to see the databases, schemas, and views you have permissions to access.
Streamlit editor: Provides a Python editor for your Streamlit code.
Streamlit preview: Displays the running Streamlit app.
By default, only the Streamlit editor and preview panes are displayed. To change the display, use the show/hide buttons in the lower-left corner of the Streamlit in Snowflake editor.
Run a Streamlit app in Streamlit in Snowflake¶
To update the content in the Streamlit preview pane, select Run.
Manage packages for a Streamlit app¶
You can view, add, and remove external Python packages for your Streamlit app by using the Streamlit editor in Snowsight.
View the packages installed for a Streamlit app¶
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app whose packages you want to view.
At the top of the Streamlit editor, select Packages.
Snowsight displays a list of installed packages.
Select the Streamlit version to use in the Streamlit app¶
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app.
Select Edit.
At the top of the Streamlit editor, select Packages.
Select the Streamlit version.
Add a supported Python package to a Streamlit app¶
By default, Streamlit in Snowflake installs the python
, snowflake-snowpark
, and streamlit
packages
in your environment. You can use Snowsight to add other packages. See the
Snowflake Anaconda Channel for a list of supported packages.
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app to which you want to add a Python package.
At the top of the Streamlit editor, select Packages.
In the search text field, select a package from the list of supported packages, or enter the name of the package.
Remove a package from a Streamlit app¶
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app from which you want to remove a Python package.
At the top of the Streamlit editor, select Packages.
Select the x icon next to the package you want to remove.
Note
The python
, snowflake-snowpark
, and streamlit
packages are installed by default and cannot be
removed.
View a Streamlit app¶
For information on the privileges required to view a Streamlit app, see Privileges required to view a Streamlit app.
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app you want to view.
The main Streamlit app opens in the Streamlit in Snowflake viewer.
Optional: If you are viewing a multi-page Streamlit app, select a tab to view additional pages.
Manage Streamlit apps¶
After creating a Streamlit app, you can perform additional related tasks that are described in the following sections.
Edit a Streamlit app¶
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app you want to edit.
The main Streamlit app opens in the Streamlit in Snowflake viewer.
Select Edit.
The Streamlit editor opens.
Update your application code.
To view the changes you made to the app, select Run.
Rename a Streamlit app¶
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app you want to rename.
Select Edit.
Select the name of the app in the upper-left corner.
Enter the new name in the text box.
Click outside the text box to commit the change.
Change the warehouse of a Streamlit app¶
While developing, testing, and running a Streamlit app, you might want to modify the warehouse used to run the app and queries. For example, you might need to use a warehouse with more capacity to handle queries run by the app.
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app whose warehouse you want to change.
Select the name of the app in the upper-left corner.
Select the new warehouse from the dropdown list.
Delete a Streamlit app¶
Deleting a Streamlit app permanently removes it from Snowflake. Any users with whom you have shared the app will no longer be able to view and interact with the Streamlit app. Before deleting a Streamlit app, ensure that you have saved your application code outside of Snowflake.
Sign in to Snowsight.
In the navigation menu, select Projects » Streamlit.
Select the Streamlit app you want to delete.
Select Edit.
Select the name of the app in the upper-left corner.
Select Delete, and then select Delete App.
Snowflake deletes the Streamlit app and displays the updated list of available apps.