Skip to content

Commit 3ad70ca

Browse files
authored
Merge pull request #4 from kaarthik108/chore/refractor-incremental-ingest-chromadb
chore/refractor-incremental-ingest-chromadb
2 parents e99afd9 + 07e1828 commit 3ad70ca

File tree

32 files changed

+1385
-567
lines changed

32 files changed

+1385
-567
lines changed

.example.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ DATABASE=
66
SCHEMA=
77
ROLE=
88

9-
OPENAI_API_KEY=
9+
OPENAI_API_KEY=
10+
LLM_MODEL=gpt-3.5-turbo-16k
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Deploy to Snowflake
2+
3+
on:
4+
push:
5+
branches:
6+
- prod
7+
paths:
8+
- "src/**"
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
environment: ${{ github.ref_name }}
14+
15+
env:
16+
ACCOUNT: ${{ vars.SNOWFLAKE_ACCOUNT }}
17+
USER_NAME: ${{ vars.SNOWFLAKE_USER }}
18+
PASSWORD: ${{ secrets.SNOWFLAKE_PWD }}
19+
ROLE: ${{ vars.SNOWFLAKE_ROLE }}
20+
DATABASE: ${{ vars.SNOWFLAKE_DATABASE }}
21+
SCHEMA: ${{ vars.SNOWFLAKE_SCHEMA }}
22+
WAREHOUSE: ${{ vars.SNOWFLAKE_WAREHOUSE }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: "3.10"
32+
33+
- name: Cache dependencies
34+
uses: actions/cache@v3
35+
with:
36+
path: |
37+
~/.cache/pypoetry
38+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/pyproject.toml') }}
39+
restore-keys: |
40+
${{ runner.os }}-poetry-
41+
42+
- name: Install Poetry
43+
run: |
44+
curl -sSL https://install.python-poetry.org | python3 -
45+
46+
- name: Install dependencies
47+
run: |
48+
poetry install
49+
50+
- name: Build
51+
run: |
52+
poetry build
53+
54+
- name: Get changed files
55+
id: changed-files
56+
uses: tj-actions/changed-files@v37
57+
58+
- name: Deploy to Snowflake
59+
run: |
60+
IFS=$'\n'
61+
for file in ${{ steps.changed-files.outputs.all_modified_files }}; do
62+
# Skip if path is not under src
63+
if [[ $file != src/* ]]; then
64+
continue
65+
fi
66+
# Extract the path relative to src
67+
rel_path="${file#src/}"
68+
component_type=$(echo $rel_path | cut -d'/' -f1)
69+
component_name=$(echo $rel_path | cut -d'/' -f2)
70+
component_path="src/$component_type/$component_name"
71+
72+
# Check if the component directory exists
73+
if [ ! -d "$component_path" ]; then
74+
echo "Directory $component_path does not exist. Skipping..."
75+
continue
76+
fi
77+
78+
echo "Component Type: $component_type"
79+
echo "Component Name: $component_name"
80+
case $component_type in
81+
task)
82+
poetry run snowdev deploy --task $component_name || echo "Failed to deploy task $component_name"
83+
;;
84+
streamlit)
85+
poetry run snowdev deploy --streamlit $component_name || echo "Failed to deploy streamlit $component_name"
86+
;;
87+
udf)
88+
poetry run snowdev deploy --udf $component_name || echo "Failed to deploy udf $component_name"
89+
;;
90+
sproc)
91+
poetry run snowdev deploy --sproc $component_name || echo "Failed to deploy sproc $component_name"
92+
;;
93+
esac
94+
done

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,12 @@ install-snowpark-ml-1.0.2.sh
155155
!examples/src/
156156
!examples/static/
157157

158-
chroma_db/
158+
.vscode/
159+
160+
chroma_db/
161+
162+
# checksums for chromadb
163+
checksums.json
164+
165+
# compiled task scripts
166+
compiled/

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
SnowDev is a command-line utility designed for deploying various components related to Snowflake such as UDFs, stored procedures, and Streamlit applications using **Snowpark**. This tool streamlines tasks like initializing directories, local testing, uploading, and auto create components code using AI.
66

7+
## Features
8+
9+
SnowDev currently supports the following components:
10+
11+
- **UDF (User-Defined Function)**
12+
- **Stored Procedure**
13+
- **Streamlit**
14+
- **Tasks**
15+
16+
717
## Setup
818

919
```bash
@@ -55,6 +65,7 @@ snowdev <command> [options]
5565
- `--udf <udf_name>`: Name or identifier for the UDF you want to deploy.
5666
- `--sproc <sproc_name>`: Name or identifier for the Stored Procedure you want to deploy.
5767
- `--streamlit <streamlit_name>`: Name or identifier for the Streamlit application you want to deploy. (This is still in PrPr)
68+
- `--task <task_name>`: Name of the snowflake task you want to deploy.
5869
- `--upload <upload_item>`: Specifies what to upload. Currently supported options: `static`.
5970
- `--package <package_name>`: Specifies the name of the package to zip and upload to the static folder.
6071
- `--embed`: Used with the `ai` command to run embeddings.
@@ -77,10 +88,11 @@ snowdev <command> [options]
7788
- [x] Support for UDFs and Stored Procedures
7889
- [x] Support for Streamlit
7990
- [x] AI interactions for embedding and suggestions
91+
- [x] Support for snowflake Tasks
92+
- [x] AI to add the packages to toml file
93+
- [ ] Support for multiple python scripts in stored procedures
8094
- [ ] Use AI to modify existing code for optimization
81-
- [ ] AI to add the packages to toml file
8295
- [ ] Adding more granularity for AI commands
83-
- [ ] Support for snowflake Tasks
8496

8597

8698

docs/cli.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SnowDev CLI Documentation
2+
3+
SnowDev is a CLI tool designed to deploy Snowflake components such as UDFs, Stored Procedures, Streamlit apps, and tasks. Below is the detailed documentation of all the commands available in the SnowDev CLI.
4+
5+
## 1. `init`
6+
- **Description**: Initialize the project structure.
7+
- **Usage**: `snowdev init`
8+
9+
## 2. `new`
10+
- **Description**: Create a new component.
11+
- **Usage**: `snowdev new [OPTIONS]`
12+
- **Options**:
13+
- `--udf <udf_name>`: The name of the UDF.
14+
- `--sproc <sproc_name>`: The name of the stored procedure.
15+
- `--streamlit <streamlit_name>`: The name of the Streamlit app.
16+
- `--task <task_name>`: The name of the task.
17+
18+
## 3. `test`
19+
- **Description**: Test the deployment.
20+
- **Usage**: `snowdev test [OPTIONS]`
21+
- **Options**:
22+
- `--udf <udf_name>`: The name of the UDF.
23+
- `--sproc <sproc_name>`: The name of the stored procedure.
24+
25+
## 4. `upload`
26+
- **Description**: Upload static content to stage, only for zipped external packages.
27+
- **Usage**: `snowdev upload`
28+
29+
## 5. `add`
30+
- **Description**: Add a package and optionally upload.
31+
- **Usage**: `snowdev add --package <package_name>`
32+
33+
## 6. `ai`
34+
- **Description**: Interact with AI components. Run embeddings or create new AI components.
35+
- **Usage**: `snowdev ai [OPTIONS]`
36+
- **Options**:
37+
- `--udf <udf_name>`: The name of the UDF.
38+
- `--sproc <sproc_name>`: The name of the stored procedure.
39+
- `--streamlit <streamlit_name>`: The name of the Streamlit app.
40+
- `--embed`: Run the embeddings.
41+
- `--task <task_name>`: The name of the task.
42+
43+
## 7. `deploy`
44+
- **Description**: Deploy components.
45+
- **Usage**: `snowdev deploy [OPTIONS]`
46+
- **Options**:
47+
- `--udf <udf_name>`: The name of the UDF.
48+
- `--sproc <sproc_name>`: The name of the stored procedure.
49+
- `--streamlit <streamlit_name>`: The name of the Streamlit app.
50+
- `--task <task_name>`: The name of the task.
51+
52+
## 8. `task`
53+
- **Description**: Commands for tasks. Actions: resume, suspend, execute.
54+
- **Usage**: `snowdev task --name <task_name> --action <action>`
55+
- **Options**:
56+
- `--name <task_name>`: The name of the task. (Required)
57+
- `--action <action>`: The action to be performed on the task. Choices: resume, suspend, execute. (Required)

docs/quickstart.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@ Now that you have SnowDev installed and initialized, it's time to see it in acti
105105
snowdev deploy --streamlit "order_chart_app"
106106
```
107107
108+
---
109+
### Deploying Tasks
110+
111+
1. **Add a New snowflake Task**
112+
113+
Create a new task application named `sample_task`:
114+
115+
```bash
116+
snowdev new --task "sample_task"
117+
```
118+
119+
Modify the sql in the src/task/sample_task/app.sql
120+
121+
2. **Deploy the task Application to Production**
122+
123+
Ready to go live? Deploy the application to production:
124+
125+
```bash
126+
snowdev deploy --task "sample_task"
127+
```
128+
129+
3. **Resume the Task**
130+
131+
Resume the task so it starts the schedule:
132+
133+
```bash
134+
snowdev task --name "sample_task" --action resume
135+
```
136+
108137
---
109138
110139
### Deploying using AI

examples/src/sproc/test_sproc/app.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ role = ""
55

66
[tool.poetry.dependencies]
77
python = "3.10.0"
8-
snowflake-snowpark-python = "1.5.1"
8+
snowflake-snowpark-python = "1.6.1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import any external package here
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: snowflake-test
22
channels:
33
- snowflake
4-
snowflake:
5-
database:
6-
schema:
7-
role:
84
dependencies:
9-
- pyyaml
5+
- pyyaml

examples/src/streamlit/test_script/external.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)