Skip to content

Commit

Permalink
feat!: bump python and requirements versions. Refactor connection par…
Browse files Browse the repository at this point in the history
…ameters to use format recommended by snowflake

* feat: bump python and requirements versions

* test: default owner bug in test table
  • Loading branch information
torbjomg authored Feb 22, 2024
1 parent 2ce0abe commit 1b05cda
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SNOWFLAKE_ACCOUNT=
SNOWFLAKE_UID=
SNOWFLAKE_PWD=
SNOWFLAKE_ROLE=
SNOWFLAKE_WH=
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,23 @@ In order to read data and deserialize your response you can use either the `fetc

No matter which approach you chose, both methods must be provided with a custom deserializer method, instructing the method on how to deserialize your response.

For more inspiration/documentation on how to achieve the deserialization above, please see the deserialization lambdas that are use in [these](./pyflake_client/tests/test_callable_anonymous_procedure.py) tests
For more inspiration/documentation on how to achieve the deserialization above, please see the deserialization lambdas that are use in [these](./pyflake_client/tests/test_callable_anonymous_procedure.py) tests

### Development

#### Tests
This project uses `pytest` as its testing framework.

To run the tests the file `.env` needs to be populated, this file can be created from the `.env.template` file:
`cp .env.template .env`, populate the following environment variables:
```shell
SNOWFLAKE_ACCOUNT=
SNOWFLAKE_UID=
SNOWFLAKE_PWD=
SNOWFLAKE_ROLE=
SNOWFLAKE_WH=
```
Note that SNOWFLAKE_HOST should no longer be used, format for SNOWFLAKE_ACCOUNT can be found by logging into your snowflake instance and running the following query:
```sql
SELECT CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME();
```
10 changes: 5 additions & 5 deletions dev.requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pytest==7.2.1
pytest-cov==4.0.0
dacite==1.7.0
snowflake-connector-python==3.1.0
snowflake-snowpark-python==1.6.1
pytest~=8.0.1
pytest-cov~=4.1.0
dacite~=1.8.1
snowflake-connector-python~=3.7.0
snowflake-snowpark-python~=1.12.1
2 changes: 0 additions & 2 deletions docker-compose.override.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
testing:
build:
Expand Down
4 changes: 1 addition & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
testing:
environment:
Expand All @@ -13,5 +11,5 @@ services:
context: .
dockerfile: Dockerfile
args:
PYTHON_TAG: 3.10.9-slim-bullseye
PYTHON_TAG: 3.11-slim-buster
REQUIREMENTS_FILE_PATH: requirements.txt
1 change: 0 additions & 1 deletion pyflake_client/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
@pytest.fixture(scope="session")
def flake() -> Generator[PyflakeClient, None, None]:
conn: SnowflakeConnection = snowflake.connector.connect(
host=os.getenv("SNOWFLAKE_HOST"),
account=os.getenv("SNOWFLAKE_ACCOUNT"),
user=os.getenv("SNOWFLAKE_UID"),
password=os.getenv("SNOWFLAKE_PWD"),
Expand Down
4 changes: 3 additions & 1 deletion pyflake_client/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import queue
from datetime import date
import os

from pyflake_client.client import PyflakeClient
from pyflake_client.models.assets.database import Database as DatabaseAsset
Expand Down Expand Up @@ -89,7 +90,8 @@ def test_create_table_without_owner(flake: PyflakeClient, assets_queue: queue.Li
assert t.database_name == database.db_name
assert t.schema_name == schema.schema_name
assert t.kind == "TABLE"
assert t.owner == "ACCOUNTADMIN"
# the role that created the table should by default be granted ownership
assert t.owner == os.environ.get("SNOWFLAKE_ROLE")
assert t.retention_time == 1
assert t.created_on.date() == date.today()
finally:
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dacite==1.7.0
snowflake-connector-python==3.1.0
snowflake-snowpark-python==1.6.1
dacite~=1.8.1
snowflake-connector-python~=3.7.0
snowflake-snowpark-python~=1.12.1
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
install_requires=required,
packages=setuptools.find_packages(exclude=["*tests*"]),
python_requires=">=3.9, <3.11",
python_requires=">=3.9, <3.12",
)

0 comments on commit 1b05cda

Please sign in to comment.