Skip to content

Commit

Permalink
Snowflake docs review (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dmatthews authored Dec 16, 2024
1 parent 28e75b3 commit 9185bc9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions content/deploy/snowflake/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Host your apps alongside your data in a single, global platform. Snowflake provi
<Tile
icon="code"
title="Examples"
text="Explore a plethora of example apps in Snowflake Labs' snowflake-demo-streamlit repository."
text="Explore a wide variety of example apps in Snowflake Labs' snowflake-demo-streamlit repository."
link="https://github.com/Snowflake-Labs/snowflake-demo-streamlit"
background="lightBlue-70"
/>
Expand All @@ -31,27 +31,27 @@ Host your apps alongside your data in a single, global platform. Snowflake provi
/>
</TileContainer>

There are three ways to host Streamlit apps in Snowflake.
There are three ways to host Streamlit apps in Snowflake:

<InlineCalloutContainer>
<InlineCallout
color="lightBlue-70"
icon="bolt"
bold="Streamlit in Snowflake."
href="https://docs.snowflake.com/developer-guide/streamlit/about-streamlit"
>Run your Streamlit app as a native object in Snowflake. Enjoy an in-browser editor and minimal work to configure your environment. Share your app with other users in your Snowflake account through role-based access control. This is a great way to deploy apps internally for your business. Check out Snowflake docs!</InlineCallout>
>Run your Streamlit app as a native object in Snowflake. Enjoy an in-browser editor and minimal work to configure your environment. Share your app with other users in your Snowflake account through role-based access control (RBAC). This is a great way to deploy apps internally for your business. Check out Snowflake docs!</InlineCallout>
<InlineCallout
color="lightBlue-70"
icon="ac_unit"
bold="Snowflake Native Apps."
href="https://docs.snowflake.com/en/developer-guide/native-apps/adding-streamlit"
>Package your app with data and share it with other Snowflake accounts. This is a great way to share apps and their underlying data with other organizations who use Snowflake so they can run it in their own account. Check out Snowflake docs!</InlineCallout>
>Package your app with data and share it with other Snowflake accounts. This is a great way to share apps and their underlying data with other organizations who use Snowflake. Check out Snowflake docs!</InlineCallout>
<InlineCallout
color="lightBlue-70"
icon="web_asset"
bold="Snowpark Container Services."
href="https://docs.snowflake.com/en/developer-guide/snowpark-container-services/overview"
>Deploy your app in a container that's optimized to run in Snowflake. This is the most flexible option where you can use any library. Share your app publicly or privately. Check out Snowflake docs!</InlineCallout>
>Deploy your app in a container that's optimized to run in Snowflake. This is the most flexible option, where you can use any library and assign a public URL to your app. Manage your allowed viewers through your Snowflake account. Check out Snowflake docs!</InlineCallout>
</InlineCalloutContainer>

<Note>
Expand Down
22 changes: 11 additions & 11 deletions content/develop/tutorials/databases/snowflake.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ slug: /develop/tutorials/databases/snowflake

## Introduction

This guide explains how to securely access a Snowflake database from Streamlit. It uses [st.connection](/develop/api-reference/connections/st.connection), the [Snowpark library](https://docs.snowflake.com/en/developer-guide/snowpark/python/index) and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management).
This guide explains how to securely access a Snowflake database from Streamlit. It uses [st.connection](/develop/api-reference/connections/st.connection), the [Snowpark library](https://docs.snowflake.com/en/developer-guide/snowpark/python/index), and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management).

### Prerequisites

Expand All @@ -20,7 +20,7 @@ This guide explains how to securely access a Snowflake database from Streamlit.
```

<Note>
Use the correct version of Python required by `snowflake-snowpark-python`. For example, if you use `snowflake-snowpark-python==1.23.0` you must use Python version \>=3.8, \<3.12.
Use the correct version of Python required by `snowflake-snowpark-python`. For example, if you use `snowflake-snowpark-python==1.23.0`, you must use Python version \>=3.8, \<3.12.
</Note>

- You must have a Snowflake account. To create a trial account, see the [tutorial](/get-started/installation/streamlit-in-snowflake) in _Get started_.
Expand All @@ -31,13 +31,13 @@ This guide explains how to securely access a Snowflake database from Streamlit.
If you already have a database that you want to use, you can [skip to the next step](#add-connection-parameters-to-your-local-app-secrets).

1. Sign in to your Snowflake account at [https://app.snowflake.com](https://app.snowflake.com).
1. In the left navigation, click "**Projects**," then click "**Worksheets**."
1. In the left navigation, select "**Projects**," and then select "**Worksheets**."
1. To create a new worksheet, in the upper-right corner, click the plus icon (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>add</i>).

You can use a worksheet to quickly and conveniently execute SQL statements. This is a great way to learn about and experiment with SQL in a trial account.

1. Optional: To rename your worksheet, in the upper-left corner, hover over the tab with your worksheet name, and click the overflow menu icon (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>more_vert</i>). Select "**Rename**", enter a new worksheet name (e.g. "Scratchwork"), and press "**Enter**".
1. To create a new database with a table, in your worksheet's SQL editor, type the following SQL statements, and execute them.
1. Optional: To rename your worksheet, in the upper-left corner, hover over the tab with your worksheet name, and then click the overflow menu icon (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>more_vert</i>). Select "**Rename**", enter a new worksheet name (e.g. "Scratchwork"), and then press "**Enter**".
1. To create a new database with a table, in your worksheet's SQL editor, type and execute the following SQL statements:

```sql
CREATE DATABASE PETS;
Expand All @@ -56,7 +56,7 @@ If you already have a database that you want to use, you can [skip to the next s

<Important>

If no lines are highlighted and you click the play button, only the line with your cursor will execute.
If no lines are highlighted and you click the play button, only the line with your cursor will be executed.

</Important>

Expand All @@ -75,11 +75,11 @@ If you already have a database that you want to use, you can [skip to the next s

Because the SQL statements did not specify a schema, they defaulted to the "PUBLIC" schema within the new "PETS" database. The role and warehouse are trial-account defaults. You can see the role and warehouse used by your worksheet in the upper-right corner, to the left of the "**Share**" and play (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>play_arrow</i>) buttons.

In Snowflake, databases provide storage and warehouses provide compute. When you configure your connection, you aren't explicitly required to declare role, warehouse, database, and schema; if these are not specified, the connection will use your account defaults. You can also change these settings within an active connection if you need to use multiple roles, warehouses, or databases. However, declaring these defaults avoids unintentional selections.
In Snowflake, databases provide storage, and warehouses provide compute. When you configure your connection, you aren't explicitly required to declare role, warehouse, database, and schema; if these are not specified, the connection will use your account defaults. If you want to use multiple roles, warehouses, or databases, you can also change these settings within an active connection. However, declaring these defaults avoids unintentional selections.

1. To conveniently copy your account identifier, in the lower-left corner, click your profile image, and hover over your account. A popover dialog expands to the right with your organization and account. In the popover, hover over your account, and click the copy icon (<i style={{ verticalAlign: "-.25em", transform: "rotateZ(90deg)" }} className={{ class: "material-icons-sharp" }}>content_copy</i>).

The account identifier in your clipboard is period-separated, which is the format used for SQL statements. Paste your account identifier into your notes, and change the period into a hyphen. The Snowflake Connector for Python requires the hyphen-separated format for your account identifier.
The account identifier in your clipboard is period-separated, which is the format used for SQL statements. However, the Snowflake Connector for Python requires a hyphen-separated format. Paste your account identifier into your notes, and change the period to a hyphen.

```toml
account = "xxxxxxx-xxxxxxx"
Expand Down Expand Up @@ -156,7 +156,7 @@ If you already have your connection configured using [Snowflake's connections fi

## Write your Streamlit app

1. Copy the code below to your Streamlit app and save it. If you are not using the example database and table from the first section of this tutorial, replace the SQL query and results handling as desired.
1. Copy the following code to your Streamlit app and save it. If you are not using the example database and table from the first section of this tutorial, replace the SQL query and results handling as appropriate.

```python
# streamlit_app.py
Expand All @@ -170,7 +170,7 @@ If you already have your connection configured using [Snowflake's connections fi
st.write(f"{row.NAME} has a :{row.PET}:")
```

The `st.connection` command creates a `SnowflakeConnection` object and handles secrets retrieval. The `.query()` method handles query caching and retries. By default, query results are cached without expiring. Setting `ttl="10m"` ensures the query result is cached for no longer than 10 minutes. To disable caching, you can set `ttl=0` instead. Learn more in [Caching](/develop/concepts/architecture/caching).
The `st.connection` command creates a `SnowflakeConnection` object and handles secrets retrieval. The `.query()` method handles query caching and retries. By default, query results are cached without expiring. Setting `ttl="10m"` ensures that the query result is cached for no longer than 10 minutes. To disable caching, you can set `ttl=0` instead. Learn more in [Caching](/develop/concepts/architecture/caching).

<Note>

Expand All @@ -192,7 +192,7 @@ If you already have your connection configured using [Snowflake's connections fi

![Finished app screenshot](/images/databases/streamlit-app.png)

### Use a Snowpark Session
### Use a Snowpark session

The [SnowflakeConnection](/develop/api-reference/connections/st.connections.snowflakeconnection) used above also provides access to [Snowpark sessions](https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/session.html) for dataframe-style operations that run natively inside Snowflake. Using this approach, you can rewrite the app above as follows:

Expand Down
14 changes: 7 additions & 7 deletions content/get-started/installation/sis.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ All you need is an email address! Everything else happens in your 30-day trial a
<Image alt="Choose your Snowflake edition, provider, and region" src="/images/get-started/SiS-region.png" />
</div>

1. Answer or skip a few questions to let us know more about yourself.
1. Answer a few questions to let us know more about yourself, or skip them.

1. A message will display: "You're now signed up!" Go to your email, and click on the activation link. (Within your link, note the subdomain. This is your Snowflake account identifier. `https://<account_identifier>.snowflakecomputing.com`)

1. Set your username and password. This will be an admin user account within your Snowflake account. Your Snowflake account can have multiple users within it.

1. If you are not signed in after setting your password, follow the instructions to enter your Snowflake account identifier, then enter your username and password. If you've accidentally closed your browser, you can log in at [app.snowflake.com](https://app.snowflake.com/).
1. If you are not signed in after setting your password, follow the instructions to enter your Snowflake account identifier, and then enter your username and password. If you've accidentally closed your browser, you can sign in at [app.snowflake.com](https://app.snowflake.com/).

Congratulations! You have a trial Snowflake account.

Expand Down Expand Up @@ -89,7 +89,7 @@ The databases in the above screenshot are as follows:
- App location: "STREAMLIT_DB" and "PUBLIC"
- App warehouse: "COMPUTE_WH" (default) or "STREAMLIT_WH" (if you created a new warehouse)

If you can't select your database, refresh the page to ensure the interface is displaying current information.
If you can't select your database, refresh the page to ensure that the interface is displaying current information.

1. Click "**Create**." (Note that the app will run with the rights of "ACCOUNTADMIN" for simplicity. You can curate your roles and permissions to choose who can create and access apps.)

Expand All @@ -107,7 +107,7 @@ The databases in the above screenshot are as follows:
st.write("Hello World")
```

If you want to get back to the sample code later, you can always make another app to edit the same example again.
If you want to return to the sample code later, you can always make another app to edit the same example again.

1. In the upper-right corner, click the blue "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>play_arrow</i> **Run**" button to make the running app reflect your changes.

Expand Down Expand Up @@ -135,17 +135,17 @@ The databases in the above screenshot are as follows:

1. Optional: Make more edits to your app. You must interact with your app or click the blue "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>play_arrow</i> **Run**" button to display the changes. This is different from a local environment where you can save your changes to trigger a rerun.

1. To go back to Snowsight, in the upper-left corner, click "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>chevron_left</i> **Streamlit Apps**."
1. To return to Snowsight, in the upper-left corner, click "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>chevron_left</i> **Streamlit Apps**."

## Return to your app

When you want to view or edit your app again, you can return to it through Snowsight. If you are returning to the site, you can log in at [app.snowflake.com](https://app.snowflake.com/).
When you want to view or edit your app again, you can return to it through Snowsight. If you are returning to the site, you can sign in at [app.snowflake.com](https://app.snowflake.com/).

1. In the left navigation, select "**Projects**" → "**Streamlit**."

1. In your list of apps, click "**Hello World**."

If you don't see your app, check that you have your role set to "ACCOUNTADMIN" as described in [Optional: Create a warehouse](/get-started/installation/streamlit-in-snowflake#optional-create-a-warehouse).
If you don't see your app, check that your role is set to "ACCOUNTADMIN" as described in [Optional: Create a warehouse](/get-started/installation/streamlit-in-snowflake#optional-create-a-warehouse).

1. Your app will open in viewing mode. To edit your app, in the upper-right corner, click "**Edit**."

Expand Down

0 comments on commit 9185bc9

Please sign in to comment.