-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add setup.py and editable install - Update environment.yml to create the editable install - Sproc now returns a table - Set OpenSSL version to address this issue: wbond/oscrypto#75 - Consolidate test req's into requirements.txt - Update README for the corresponding changes above
- Loading branch information
1 parent
8639aa6
commit 32d440f
Showing
16 changed files
with
131 additions
and
123 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
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
snowsql_config_path = "" | ||
snowsql_connection_name = "" | ||
|
||
[dev] | ||
database = "" | ||
schema = "" | ||
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
snowflake-snowpark-python | ||
snowflake-snowpark-python[pandas] | ||
tomli | ||
toml | ||
pytest | ||
snowflake-vcrpy @ git+https://github.com/Snowflake-Labs/snowflake-vcrpy.git@v0.1.1 |
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,12 @@ | ||
""" | ||
Run `conda env create --file environment.yaml` to create an editable | ||
install of this project | ||
""" | ||
|
||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="Example Snowpark Python project", | ||
version="0.1.0", | ||
packages=find_packages() | ||
) |
File renamed without changes.
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 @@ | ||
""" | ||
An example stored procedure. __main__ provides an entrypoint for local development | ||
and testing. | ||
""" | ||
|
||
from snowflake.snowpark.session import Session | ||
from snowflake.snowpark.dataframe import col, DataFrame | ||
from snowflake.snowpark.functions import udf | ||
from src import functions | ||
|
||
def run(snowpark_session: Session) -> DataFrame: | ||
""" | ||
A sample stored procedure which creates a small DataFrame, prints it to the | ||
console, and returns the number of rows in the table. | ||
""" | ||
|
||
combine_udf = udf(functions.combine) | ||
|
||
schema = ["col_1", "col_2"] | ||
|
||
data = [ | ||
("Welcome to ", "Snowflake!"), | ||
("Learn more: ", "https://www.snowflake.com/snowpark/"), | ||
] | ||
|
||
df = snowpark_session.create_dataframe(data, schema) | ||
|
||
df2 = df.select(combine_udf(col("col_1"), col("col_2")).as_("hello_world")).sort( | ||
"hello_world", ascending=False | ||
) | ||
|
||
return df2 | ||
|
||
|
||
if __name__ == "__main__": | ||
# This entrypoint is used for local development (`$ python src/procs/app.py`) | ||
|
||
from src.util.local import get_env_var_config | ||
|
||
print("Creating session...") | ||
session = Session.builder.configs(get_env_var_config()).create() | ||
session.add_import(functions.__file__, 'src.functions') | ||
|
||
print("Running stored procedure...") | ||
result = run(session) | ||
|
||
print("Stored procedure complete:") | ||
result.show() |
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 was deleted.
Oops, something went wrong.
Empty file.
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,16 @@ | ||
""" | ||
Fixtures and configurations for the PyTest suite | ||
""" | ||
|
||
import pytest | ||
from snowflake.snowpark.session import Session | ||
from src.util.local import get_env_var_config | ||
|
||
@pytest.fixture | ||
def session(scope='module'): | ||
# pylint: disable=unused-argument | ||
""" | ||
Creates a Session object for tests | ||
""" | ||
|
||
return Session.builder.configs(get_env_var_config()).create() |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
""" | ||
Tests for the procedure module. | ||
""" | ||
|
||
from snowflake.snowpark.session import Session | ||
from src import functions | ||
from src.app import run | ||
|
||
def test_app_dim(session: Session): | ||
session.add_import(functions.__file__, 'src.functions') | ||
expected = session.create_dataframe( | ||
[["Welcome to Snowflake!"], ["Learn more: https://www.snowflake.com/snowpark/"]], | ||
["hello_world"]) | ||
|
||
actual = run(session) | ||
|
||
assert expected.collect() == actual.collect() |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
from src.udf.functions import combine | ||
""" | ||
Tests for the functions module. | ||
""" | ||
|
||
from src.functions import combine | ||
|
||
def test_combine(): | ||
expected = "hello world" | ||
actual = combine("hello ", "world") | ||
|
||
assert expected == actual |