cecil 0.0.17__tar.gz → 0.0.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cecil might be problematic. Click here for more details.
- {cecil-0.0.17 → cecil-0.0.18}/PKG-INFO +1 -1
- {cecil-0.0.17 → cecil-0.0.18}/src/cecil/client.py +14 -8
- {cecil-0.0.17 → cecil-0.0.18}/src/cecil/models.py +2 -2
- cecil-0.0.18/src/cecil/version.py +1 -0
- cecil-0.0.17/src/cecil/version.py +0 -1
- {cecil-0.0.17 → cecil-0.0.18}/.editorconfig +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/.gitignore +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/CONTRIBUTING.md +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/LICENSE.txt +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/Makefile +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/README.md +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/pyproject.toml +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/src/cecil/__init__.py +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/src/cecil/errors.py +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/tests/__init__.py +0 -0
- {cecil-0.0.17 → cecil-0.0.18}/tests/test_client.py +0 -0
|
@@ -6,6 +6,7 @@ import requests
|
|
|
6
6
|
import snowflake.connector
|
|
7
7
|
from pydantic import BaseModel
|
|
8
8
|
from requests import auth
|
|
9
|
+
from cryptography.hazmat.primitives import serialization
|
|
9
10
|
|
|
10
11
|
from .errors import (
|
|
11
12
|
Error,
|
|
@@ -26,7 +27,7 @@ from .models import (
|
|
|
26
27
|
RotateAPIKeyRequest,
|
|
27
28
|
SignUpRequest,
|
|
28
29
|
SignUpResponse,
|
|
29
|
-
|
|
30
|
+
SnowflakeUserCredentials,
|
|
30
31
|
Transformation,
|
|
31
32
|
TransformationCreate,
|
|
32
33
|
User,
|
|
@@ -41,7 +42,7 @@ class Client:
|
|
|
41
42
|
self._base_url = (
|
|
42
43
|
"https://api.cecil.earth" if env is None else f"https://{env}.cecil.earth"
|
|
43
44
|
)
|
|
44
|
-
self.
|
|
45
|
+
self._snowflake_user_creds = None
|
|
45
46
|
|
|
46
47
|
def create_aoi(self, name: str, geometry: Dict) -> AOI:
|
|
47
48
|
# TODO: validate geometry
|
|
@@ -93,14 +94,19 @@ class Client:
|
|
|
93
94
|
return [Transformation(**record) for record in res["records"]]
|
|
94
95
|
|
|
95
96
|
def query(self, sql: str) -> pd.DataFrame:
|
|
96
|
-
if self.
|
|
97
|
-
res = self._get(url="/v0/
|
|
98
|
-
self.
|
|
97
|
+
if self._snowflake_user_creds is None:
|
|
98
|
+
res = self._get(url="/v0/snowflake-user-credentials")
|
|
99
|
+
self._snowflake_user_creds = SnowflakeUserCredentials(**res)
|
|
100
|
+
|
|
101
|
+
private_key = serialization.load_pem_private_key(
|
|
102
|
+
self._snowflake_user_creds.private_key.get_secret_value().encode(),
|
|
103
|
+
password=None,
|
|
104
|
+
)
|
|
99
105
|
|
|
100
106
|
with snowflake.connector.connect(
|
|
101
|
-
account=self.
|
|
102
|
-
user=self.
|
|
103
|
-
|
|
107
|
+
account=self._snowflake_user_creds.account.get_secret_value(),
|
|
108
|
+
user=self._snowflake_user_creds.user.get_secret_value(),
|
|
109
|
+
private_key=private_key,
|
|
104
110
|
) as conn:
|
|
105
111
|
df = conn.cursor().execute(sql).fetch_pandas_all()
|
|
106
112
|
df.columns = [x.lower() for x in df.columns]
|
|
@@ -77,11 +77,11 @@ class TransformationCreate(BaseModel):
|
|
|
77
77
|
spatial_resolution: float
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
class
|
|
80
|
+
class SnowflakeUserCredentials(BaseModel):
|
|
81
81
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
82
82
|
account: SecretStr
|
|
83
83
|
user: SecretStr
|
|
84
|
-
|
|
84
|
+
private_key: SecretStr
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
class User(BaseModel):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.18"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.17"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|