Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions notebook-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,54 @@ chalk_client = ChalkClient(
branch="new-feature"
)
```

## Snowflake

This guide references https://docs.snowflake.com/en/user-guide/ui-snowsight/notebooks-external-access

We will need to configure the notebook to use external access integration with secrets.
The `client_id` and `client_secret` can be generated by navigating to settings in the Chalk dashboard then selecting Access Tokens.
```sql
-- Step 1: Create secrets
CREATE SECRET client_id
TYPE = GENERIC_STRING
SECRET_STRING = '<client_id>';
CREATE SECRET client_secret
TYPE = GENERIC_STRING
SECRET_STRING = '<client_secret>';

-- Step 2: Create a network rule
CREATE OR REPLACE NETWORK RULE chalkpy_network_rule
MODE = EGRESS
TYPE = HOST_PORT
VALUE_LIST = ('api.chalk.ai');

-- Step 3: Create an external access integration that uses the network rule and secret
CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION chalkpy_integration
ALLOWED_NETWORK_RULES = (chalkpy_network_rule)
ALLOWED_AUTHENTICATION_SECRETS = (client_id, client_secret)
ENABLED = true;

-- Step 4: Associate with integration and secret with the notebook
ALTER NOTEBOOK my_notebook
SET EXTERNAL_ACCESS_INTEGRATIONS = (chalkpy_integration),
SECRETS = ('client_id' = client_id, 'client_secret' = client_secret);

-- Step 5: Grant the USAGE privilege on roles that will use the external access integration
GRANT USAGE ON INTEGRATION chalkpy_integration TO ROLE my_notebook_role;
```
Accessing the secret inside a notebook
```python
import streamlit as st
client_id = st.secrets['client_id']
client_secret = st.secrets['client_secret']
```

Connecting using the Chalk Client
```python
from chalk.client import ChalkClient
client = ChalkClient(
client_id=client_id,
client_secret=client_secret
)
```