Skip to content

Commit 6790c99

Browse files
committed
Add integration testing for Snowflake notebooks
1 parent 5fdf630 commit 6790c99

5 files changed

Lines changed: 75 additions & 15 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Run Snowflake integration tests
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the "main" branch
6+
push:
7+
branches: [ "main" ]
8+
# Skip on this check PR to reduce number of AuraDS instances created
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14+
jobs:
15+
tests:
16+
# The type of runner that the job will run on
17+
runs-on: ${{ matrix.os}}
18+
timeout-minutes: 30
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest]
23+
defaults:
24+
run:
25+
working-directory: python-wrapper
26+
27+
# Steps represent a sequence of tasks that will be executed as part of the job
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.11"
34+
cache: 'pip'
35+
cache-dependency-path: pyproject.toml
36+
- run: pip install ".[dev]"
37+
- run: pip install ".[pandas]"
38+
39+
- name: Run tests
40+
env:
41+
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
42+
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
43+
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
44+
SNOWFLAKE_ROLE: ACCOUNTADMIN
45+
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
46+
run: pytest tests/ --include-snowflake

python-wrapper/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ notebook = [
6666
"ipywidgets>=8.0.0",
6767
"palettable==3.3.3",
6868
"matplotlib==3.10.0",
69+
"snowflake-snowpark-python==1.26.0",
6970
]
7071

7172
[project.urls]

python-wrapper/tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ def pytest_addoption(parser: Any) -> None:
1010
action="store_true",
1111
help="include tests requiring a Neo4j instance with GDS running",
1212
)
13+
parser.addoption(
14+
"--include-snowflake",
15+
action="store_true",
16+
help="include tests requiring a Snowflake connection",
17+
)
1318

1419

1520
def pytest_collection_modifyitems(config: Any, items: Any) -> None:
@@ -18,6 +23,11 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None:
1823
for item in items:
1924
if "requires_neo4j_and_gds" in item.keywords:
2025
item.add_marker(skip)
26+
if not config.getoption("--include-snowflake"):
27+
skip = pytest.mark.skip(reason="skipping since requiring a Snowflake connection")
28+
for item in items:
29+
if "requires_snowflake" in item.keywords:
30+
item.add_marker(skip)
2131

2232

2333
@pytest.fixture(scope="package")

python-wrapper/tests/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[pytest]
22
markers =
33
requires_neo4j_and_gds: mark a test as a requiring a Neo4j instance with GDS running
4+
requires_snowflake: mark a test as a requiring a Snowflake connection
45
filterwarnings =
56
error
67
ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning

python-wrapper/tests/test_notebooks.py

100755100644
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,20 @@ def filter_func(notebook: str) -> bool:
120120
run_notebooks(filter_func)
121121

122122

123-
# def test_snowflake() -> None:
124-
# snowflake_notebooks = ["snowflake-nvl-example.ipynb"]
125-
#
126-
# def filter_func(notebook: str) -> bool:
127-
# return notebook in snowflake_notebooks
128-
#
129-
# run_notebooks(filter_func)
130-
#
131-
# def test_simple() -> None:
132-
# simple_notebooks = ["simple-nvl-example.ipynb"]
133-
#
134-
# def filter_func(notebook: str) -> bool:
135-
# return notebook in simple_notebooks
136-
#
137-
# run_notebooks(filter_func)
123+
@pytest.mark.requires_snowflake
124+
def test_snowflake() -> None:
125+
snowflake_notebooks = ["snowpark-nvl-example.ipynb"]
126+
127+
def filter_func(notebook: str) -> bool:
128+
return notebook in snowflake_notebooks
129+
130+
run_notebooks(filter_func)
131+
132+
133+
def test_simple() -> None:
134+
simple_notebooks = ["simple-nvl-example.ipynb"]
135+
136+
def filter_func(notebook: str) -> bool:
137+
return notebook in simple_notebooks
138+
139+
run_notebooks(filter_func)

0 commit comments

Comments
 (0)