-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snowflake sqlalchemy implementation (#1216)
* add snowflake table implementation for sqlachemy * fmt * fmt * joined load * bug * joined 2 deep * add logging in snowflake doc * fmt * fmt? * remove unneeded * rm trulens source install instructions * remove legacy streamlit cache clear * fmt * add snowflake doc to mkdocs --------- Co-authored-by: Piotr Mardziel <[email protected]>
- Loading branch information
1 parent
62896cc
commit 98cb4a0
Showing
6 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
docs/trulens_eval/tracking/logging/where_to_log/log_in_snowflake.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# ❄️ Logging in Snowflake | ||
|
||
Snowflake’s fully managed [data warehouse](https://www.snowflake.com/en/data-cloud/workloads/data-warehouse/?utm_cta=website-homepage-workload-card-data-warehouse) provides automatic provisioning, availability, tuning, data protection and more—across clouds and regions—for an unlimited number of users and jobs. | ||
|
||
TruLens can write and read from a Snowflake database using a SQLAlchemy connection. This allows you to read, write, persist and share _TruLens_ logs in a _Snowflake_ database. | ||
|
||
Here is a _working_ guide to logging in _Snowflake_. | ||
|
||
## Install the [Snowflake SQLAlchemy toolkit](https://docs.snowflake.com/en/developer-guide/python-connector/sqlalchemy) with the Python Connector | ||
|
||
For now, we need to use a working branch of snowflake-sqlalchemy that supports sqlalchemy 2.0. | ||
|
||
!!! example "Install Snowflake-SQLAlchemy" | ||
|
||
```bash | ||
# Clone the Snowflake github repo: | ||
git clone [email protected]:snowflakedb/snowflake-sqlalchemy.git | ||
|
||
# Check out the sqlalchemy branch: | ||
git checkout SNOW-1058245-sqlalchemy-20-support | ||
|
||
# Install hatch: | ||
pip install hatch | ||
|
||
# Build snowflake-sqlalchemy via hatch: | ||
python -m hatch build --clean | ||
|
||
# Install snowflake-sqlalchemy | ||
pip install dist/*.whl | ||
``` | ||
|
||
## Connect TruLens to the Snowflake database | ||
|
||
!!! example "Connect TruLens to the Snowflake database" | ||
|
||
```python | ||
from trulens_eval import Tru | ||
tru = Tru(database_url=( | ||
'snowflake://{user}:{password}@{account_identifier}/' | ||
'{database}/{schema}?warehouse={warehouse}&role={role}' | ||
).format( | ||
user='<user>', | ||
password='<password>', | ||
account_identifier='<account-identifer>', | ||
database='<database>', | ||
schema='<schema>', | ||
warehouse='<warehouse>', | ||
role='<role>' | ||
)) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters