Create and deploy Streamlit apps using Snowflake CLI¶
This topic describes working with Streamlit in Snowflake using Snowflake CLI.
What is Snowflake CLI?¶
Snowflake CLI is an open-source command-line tool explicitly designed for developer-centric workloads in addition to SQL operations. For Streamlit developers who currently use a local IDE development flow and a Git-backed continuous integration and deployment (CI/CD) collaboration workflow, Snowflake CLI provides familiar tooling to integrate Streamlit in Snowflake into their current development flow.
For more information, see Snowflake CLI.
Before creating a Streamlit app by using Snowflake CLI:
Ensure that you meet the required prerequisites for using Streamlit in Snowflake.
Install Snowflake CLI. See Installing Snowflake CLI.
Developer guides¶
Guide |
Description |
---|---|
Learn about creating a Streamlit app using Snowflake CLI. |
|
Learn about deploying a Streamlit app using Snowflake CLI. |
|
Learn about retrieving the URL for a Streamlit app. |
|
Learn about sharing a Streamlit app with other roles using Snowflake CLI. |
|
Learn about managing a Streamlit app using Snowflake CLI. |
Create a CI/CD pipeline with Snowflake CLI and a GitHub Actions workflow¶
The following section describes how to deploy a Streamlit app in Snowflake by using Snowflake CLI and a GitHub Actions workflow. You can use a similar approach for other version control providers.
Prerequisites¶
Before deploying a Streamlit app by using Snowflake CLI and a GitHub Actions workflow, ensure that you:
Meet the required prerequisites for using Streamlit in Snowflake.
Have a GitHub repository to add files to.
Example: Create a GitHub Actions workflow using Snowflake CLI¶
In your repository, in the
.github/workflows
directory, create amain.yml
workflow file.Create a
SNOWCLI_PW
secret to use in the GitHub Actions workflow.Copy the following into the
main.yml
file:# Name the GitHub Action name: Deploy via Snowflake CLI on: push: branches: - main env: PYTHON_VERSION: '3.8' jobs: build-and-deploy: runs-on: ubuntu-latest environment: dev steps: # Checks out your repository under $GITHUB_WORKSPACE, so your workflow can access it - name: 'Checkout GitHub Action' uses: actions/checkout@v3 - name: Install Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: 'Install Snowflake CLI' shell: bash run: | python -m pip install --upgrade pip pip install snowflake-cli-labs - name: 'Create config' shell: bash env: SNOWFLAKE_PASSWORD: ${{ secrets.SNOWCLI_PW }} run: | mkdir -p ~/.snowflake cp config.toml ~/.snowflake/config.toml echo "password = \"$SNOWFLAKE_PASSWORD\"" >> ~/.snowflake/config.toml chmod 0600 ~/.snowflake/config.toml - name: 'Deploy the Streamlit app' shell: bash run: | snow streamlit deploy --replace
To run your workflow, commit and push the changes to your repository.
For more information, see GitHub Actions documentation.