-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create smoke test for Snowflake notebooks. (#1619)
- Loading branch information
1 parent
4b196e9
commit 0f348bc
Showing
5 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
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,8 @@ | ||
name: app_environment | ||
channels: | ||
- snowflake | ||
dependencies: | ||
- trulens-connectors-snowflake=* | ||
- trulens-core=* | ||
- trulens-feedback=* | ||
- trulens-providers-cortex=* |
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,79 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import trulens.connectors.snowflake\n", | ||
"\n", | ||
"print(trulens.connectors.snowflake.__version__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import trulens.core\n", | ||
"\n", | ||
"print(trulens.core.__version__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import trulens.feedback\n", | ||
"\n", | ||
"print(trulens.feedback.__version__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import trulens.providers.cortex\n", | ||
"\n", | ||
"print(trulens.providers.cortex.__version__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# State the obvious.\n", | ||
"\n", | ||
"print(\"Kojikun is the world's cutest baby!\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "trulens_3_11", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from unittest import main | ||
import uuid | ||
|
||
from tests.util.snowflake_test_case import SnowflakeTestCase | ||
|
||
_STAGE_NAME = "SNOWFLAKE_NOTEBOOKS" | ||
|
||
|
||
class TestSnowflakeNotebooks(SnowflakeTestCase): | ||
def test_simple_notebook(self) -> None: | ||
self._upload_and_run_notebook( | ||
"test_simple_notebook", | ||
"simple", | ||
"tests/e2e/data/", | ||
) | ||
|
||
def _upload_and_run_notebook( | ||
self, schema_base_name: str, name: str, path: str | ||
) -> None: | ||
try: | ||
schema_name = ( | ||
f"{schema_base_name}_{str(uuid.uuid4()).replace('-', '_')}" | ||
) | ||
self.create_and_use_schema(schema_name) | ||
self.run_query(f"CREATE STAGE {_STAGE_NAME}") | ||
self.run_query( | ||
f"PUT file://{path}/{name}.ipynb @{_STAGE_NAME} AUTO_COMPRESS = FALSE" | ||
) | ||
self.run_query( | ||
f"PUT file://{path}/environment.yml @{_STAGE_NAME} AUTO_COMPRESS = FALSE" | ||
) | ||
self.run_query( | ||
f""" | ||
CREATE NOTEBOOK {name} | ||
FROM '@{_STAGE_NAME}' | ||
MAIN_FILE = '{name}.ipynb' | ||
QUERY_WAREHOUSE = {self._snowflake_connection_parameters["warehouse"]} | ||
""" | ||
) | ||
self.run_query(f"ALTER NOTEBOOK {name} ADD LIVE VERSION FROM LAST") | ||
self.run_query(f"EXECUTE NOTEBOOK {name}()") | ||
finally: | ||
self.run_query(f"DROP STAGE IF EXISTS {_STAGE_NAME}") | ||
self.run_query(f"DROP NOTEBOOK IF EXISTS {name}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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