Create and run a Streamlit app in a workspace¶
This topic describes how to create, run, deploy, and configure a Streamlit in Snowflake app in a workspace.
Create a Streamlit app¶
Open a workspace in Snowsight.
Select + Add new » Streamlit app. Alternatively, select the Streamlit app shortcut from the workspace home screen.
Snowflake creates a folder with the following starter files:
streamlit_app.py: The app source code, pre-populated with a demo app.pyproject.toml: Where you add Python package dependencies.snowflake.yml: A declarative file that specifies deployment settings such as compute, runtime, and so on..streamlit/config.toml: Streamlit configuration settings.
Run and preview your app¶
Whenever you open a Streamlit file, an action bar appears at the top of the file. Press Run or use Cmd+Enter (Mac) / Ctrl+Enter (Windows/Linux) to start or rerun your app and preview your latest changes.
The running app is a development app: a private instance that only you can see while you’re working on it. To publish your app to other users, see Deploy your app.
Deploy your app¶
Deploying publishes your workspace code to a Streamlit object that other users can access.
In the project pane toolbar, select Deploy.
In the deploy dialog, review the settings:
App title: Defaults to the app name in the workspace.
Location: The database and schema where the Streamlit object is created.
Execution: The compute pool to run the app and the query warehouse to run queries in the app.
Network: Any External Access Integrations you want to add to the app.
Sharing: Add roles that will have USAGE privilege on the app.
Select Deploy.
Snowflake copies your app files into the Streamlit object and makes the app available to users with the appropriate privileges.
Redeploy your app¶
After you make changes to your code, select Deploy again in the project pane. Select the deployment target and confirm. The new code overwrites the existing Streamlit app.
If you select a different database or schema as the target for the app deployment, the previous app continues to run in its original location.
Edit a deployed app¶
When viewing a deployed Streamlit app in Snowsight, select Edit to open the app’s source code in its workspace. Snowflake opens the workspace and file associated with the deployed app.
Note
Only the app owner can edit and redeploy a deployed app.
App settings¶
The settings dialog lets you configure the following properties for apps in your workspace:
Execution: The warehouse used to run SQL queries.
External network access via an External Access Integration.
For apps in workspaces, settings are stored per app, per user. Changing settings on your development app doesn’t affect the deployed app..
For deployed apps, settings are stored on the Streamlit object and apply to all
viewers. Settings are also written to snowflake.yml so they persist across
deploys.
Collaboration and Git¶
Workspaces support private workspaces, where only you can see and edit the code and deploy the app.
When you deploy, the new code overwrites the existing code in the Streamlit object.
Source code mapping¶
A deployed Streamlit object is connected to one logical source code location: the workspace and file path it was deployed from.
If you move the location of your application within your workspace, this mapping no longer works and you need to redeploy from the new source location.