cecil 0.0.15__py3-none-any.whl → 0.0.16__py3-none-any.whl
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/__init__.py +1 -0
- cecil/client.py +21 -24
- cecil/models.py +5 -28
- cecil/version.py +1 -0
- {cecil-0.0.15.dist-info → cecil-0.0.16.dist-info}/METADATA +12 -12
- cecil-0.0.16.dist-info/RECORD +9 -0
- {cecil-0.0.15.dist-info → cecil-0.0.16.dist-info}/WHEEL +1 -1
- cecil-0.0.15.dist-info/RECORD +0 -8
- {cecil-0.0.15.dist-info → cecil-0.0.16.dist-info}/licenses/LICENSE.txt +0 -0
cecil/__init__.py
CHANGED
cecil/client.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Dict, List
|
|
3
|
-
|
|
4
2
|
import requests
|
|
5
3
|
import snowflake.connector
|
|
4
|
+
|
|
6
5
|
from pydantic import BaseModel
|
|
7
6
|
from requests import auth
|
|
7
|
+
from typing import Dict, List
|
|
8
8
|
|
|
9
9
|
from .errors import (
|
|
10
10
|
Error,
|
|
@@ -18,8 +18,8 @@ from .models import (
|
|
|
18
18
|
AOICreate,
|
|
19
19
|
DataRequest,
|
|
20
20
|
DataRequestCreate,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
Transformation,
|
|
22
|
+
TransformationCreate,
|
|
23
23
|
RecoverAPIKey,
|
|
24
24
|
RecoverAPIKeyRequest,
|
|
25
25
|
RotateAPIKey,
|
|
@@ -27,8 +27,7 @@ from .models import (
|
|
|
27
27
|
SnowflakeCredentials,
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
SDK_VERSION = "0.0.15"
|
|
30
|
+
from .version import __version__
|
|
32
31
|
|
|
33
32
|
# TODO: Documentation (Google style)
|
|
34
33
|
# TODO: Add HTTP retries
|
|
@@ -38,9 +37,7 @@ class Client:
|
|
|
38
37
|
def __init__(self, env=None):
|
|
39
38
|
self._api_auth = None
|
|
40
39
|
self._base_url = (
|
|
41
|
-
"https://api.cecil.earth"
|
|
42
|
-
if env is None
|
|
43
|
-
else f"https://{env}-api.cecil.earth"
|
|
40
|
+
"https://api.cecil.earth" if env is None else f"https://{env}.cecil.earth"
|
|
44
41
|
)
|
|
45
42
|
self._snowflake_creds = None
|
|
46
43
|
|
|
@@ -72,27 +69,27 @@ class Client:
|
|
|
72
69
|
res = self._get(url="/v0/data-requests")
|
|
73
70
|
return [DataRequest(**record) for record in res["records"]]
|
|
74
71
|
|
|
75
|
-
def
|
|
76
|
-
self, data_request_id: str, crs: str,
|
|
77
|
-
) ->
|
|
78
|
-
# TODO: check if data request is completed before creating
|
|
72
|
+
def create_transformation(
|
|
73
|
+
self, data_request_id: str, crs: str, spatial_resolution: float
|
|
74
|
+
) -> Transformation:
|
|
75
|
+
# TODO: check if data request is completed before creating transformation
|
|
79
76
|
res = self._post(
|
|
80
|
-
url="/v0/
|
|
81
|
-
model=
|
|
77
|
+
url="/v0/transformations",
|
|
78
|
+
model=TransformationCreate(
|
|
82
79
|
data_request_id=data_request_id,
|
|
83
80
|
crs=crs,
|
|
84
|
-
|
|
81
|
+
spatial_resolution=spatial_resolution,
|
|
85
82
|
),
|
|
86
83
|
)
|
|
87
|
-
return
|
|
84
|
+
return Transformation(**res)
|
|
88
85
|
|
|
89
|
-
def
|
|
90
|
-
res = self._get(url=f"/v0/
|
|
91
|
-
return
|
|
86
|
+
def get_transformation(self, id: str) -> Transformation:
|
|
87
|
+
res = self._get(url=f"/v0/transformations/{id}")
|
|
88
|
+
return Transformation(**res)
|
|
92
89
|
|
|
93
|
-
def
|
|
94
|
-
res = self._get(url="/v0/
|
|
95
|
-
return [
|
|
90
|
+
def list_transformations(self) -> List[Transformation]:
|
|
91
|
+
res = self._get(url="/v0/transformations")
|
|
92
|
+
return [Transformation(**record) for record in res["records"]]
|
|
96
93
|
|
|
97
94
|
def query(self, sql):
|
|
98
95
|
if self._snowflake_creds is None:
|
|
@@ -128,7 +125,7 @@ class Client:
|
|
|
128
125
|
if skip_auth is False:
|
|
129
126
|
self._set_auth()
|
|
130
127
|
|
|
131
|
-
headers = {"cecil-python-sdk-version":
|
|
128
|
+
headers = {"cecil-python-sdk-version": __version__}
|
|
132
129
|
|
|
133
130
|
try:
|
|
134
131
|
r = requests.request(
|
cecil/models.py
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import datetime
|
|
2
|
-
from
|
|
3
|
-
from typing import Dict, List, Optional
|
|
2
|
+
from typing import Dict
|
|
4
3
|
|
|
5
4
|
from pydantic import BaseModel, ConfigDict, SecretStr
|
|
6
5
|
from pydantic.alias_generators import to_camel
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
class SubRequestStatus(str, Enum):
|
|
10
|
-
COMPLETED = "completed"
|
|
11
|
-
FAILED = "failed"
|
|
12
|
-
PROCESSING = "processing"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class DataRequestStatus(str, Enum):
|
|
16
|
-
COMPLETED = "completed"
|
|
17
|
-
FAILED = "failed"
|
|
18
|
-
PROCESSING = "processing"
|
|
19
|
-
|
|
20
|
-
|
|
21
8
|
class AOI(BaseModel):
|
|
22
9
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
23
10
|
id: str
|
|
@@ -34,21 +21,11 @@ class AOICreate(BaseModel):
|
|
|
34
21
|
geometry: Dict
|
|
35
22
|
|
|
36
23
|
|
|
37
|
-
class SubRequest(BaseModel):
|
|
38
|
-
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
39
|
-
external_id: str
|
|
40
|
-
description: str
|
|
41
|
-
status: SubRequestStatus
|
|
42
|
-
error_message: Optional[str]
|
|
43
|
-
|
|
44
|
-
|
|
45
24
|
class DataRequest(BaseModel):
|
|
46
25
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
47
26
|
id: str
|
|
48
27
|
aoi_id: str
|
|
49
28
|
dataset_id: str
|
|
50
|
-
sub_requests: List[SubRequest]
|
|
51
|
-
status: DataRequestStatus
|
|
52
29
|
created_at: datetime.datetime
|
|
53
30
|
created_by: str
|
|
54
31
|
|
|
@@ -78,21 +55,21 @@ class RotateAPIKeyRequest(BaseModel):
|
|
|
78
55
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
79
56
|
|
|
80
57
|
|
|
81
|
-
class
|
|
58
|
+
class Transformation(BaseModel):
|
|
82
59
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
83
60
|
id: str
|
|
84
61
|
data_request_id: str
|
|
85
62
|
crs: str
|
|
86
|
-
|
|
63
|
+
spatial_resolution: float
|
|
87
64
|
created_at: datetime.datetime
|
|
88
65
|
created_by: str
|
|
89
66
|
|
|
90
67
|
|
|
91
|
-
class
|
|
68
|
+
class TransformationCreate(BaseModel):
|
|
92
69
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
93
70
|
data_request_id: str
|
|
94
71
|
crs: str
|
|
95
|
-
|
|
72
|
+
spatial_resolution: float
|
|
96
73
|
|
|
97
74
|
|
|
98
75
|
class SnowflakeCredentials(BaseModel):
|
cecil/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.16"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cecil
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.16
|
|
4
4
|
Summary: Python SDK for Cecil Earth
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -71,30 +71,30 @@ my_data_request = client.create_data_request(
|
|
|
71
71
|
dataset_id=planet_forest_carbon_diligence_id,
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
-
print(client.get_data_request(my_data_request.id)
|
|
74
|
+
print(client.get_data_request(my_data_request.id))
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
### Create a
|
|
77
|
+
### Create a transformation using the Cecil client
|
|
78
78
|
|
|
79
79
|
```python
|
|
80
|
-
|
|
80
|
+
my_transformation = client.create_transformation(
|
|
81
81
|
data_request_id=my_data_request.id,
|
|
82
82
|
crs="EPSG:4326",
|
|
83
|
-
|
|
83
|
+
spatial_resolution=0.005,
|
|
84
84
|
)
|
|
85
85
|
|
|
86
|
-
print(client.
|
|
86
|
+
print(client.get_transformation(my_transformation.id))
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
### Query data (once
|
|
89
|
+
### Query data (once transformation is completed)
|
|
90
90
|
|
|
91
91
|
```python
|
|
92
92
|
df = client.query(f'''
|
|
93
93
|
SELECT *
|
|
94
|
-
FROM
|
|
94
|
+
FROM
|
|
95
95
|
planet.forest_carbon_diligence
|
|
96
96
|
WHERE
|
|
97
|
-
|
|
97
|
+
transformation_id = '{my_transformation.id}'
|
|
98
98
|
''')
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -109,9 +109,9 @@ client.list_data_requests()
|
|
|
109
109
|
|
|
110
110
|
client.get_data_request(my_data_request.id)
|
|
111
111
|
|
|
112
|
-
client.
|
|
112
|
+
client.list_transformations()
|
|
113
113
|
|
|
114
|
-
client.
|
|
114
|
+
client.get_transformation(my_transformation.id)
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
## License
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
cecil/__init__.py,sha256=AEcRl73BDSAQe6W0d1PDD87IEcumARtREl7dCVa_YQY,86
|
|
2
|
+
cecil/client.py,sha256=hykvGQrpuAEQR_TawLKCwc_mWsjD72uxAZHaOTZjf1M,5764
|
|
3
|
+
cecil/errors.py,sha256=r9NNRtv_oO_hblnh-VOlAf767cJqmlnbJfHB63OA_zY,1538
|
|
4
|
+
cecil/models.py,sha256=xkjrLAOenJboRtzRPihT-C8jpadngePz4KzLNJoemHM,2012
|
|
5
|
+
cecil/version.py,sha256=8ss7zPyQ3YfaQJw9IIGX35NOL7ASZ7-LErAxKnQDN7c,23
|
|
6
|
+
cecil-0.0.16.dist-info/METADATA,sha256=7f2D9tc10goXMoeFgZqjHWeENrVyUq6H0OXmma75eWY,2659
|
|
7
|
+
cecil-0.0.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
cecil-0.0.16.dist-info/licenses/LICENSE.txt,sha256=mUexcmfYx3bG1VIzAdQTOf_NzStYw6-QkKVdUY_d4i4,1066
|
|
9
|
+
cecil-0.0.16.dist-info/RECORD,,
|
cecil-0.0.15.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
cecil/__init__.py,sha256=9-O5DAnOHvBuzPAjkK10GiOnCY9rb4SW1k0CIrHorr0,53
|
|
2
|
-
cecil/client.py,sha256=4ft1FL6KePfleTf-oepi10yRJ3RdVeZ0qNRdFyLm6c8,5783
|
|
3
|
-
cecil/errors.py,sha256=r9NNRtv_oO_hblnh-VOlAf767cJqmlnbJfHB63OA_zY,1538
|
|
4
|
-
cecil/models.py,sha256=6p9AedCDdkK-ptK2r5pc9AKG8rgZHw-YYDvRgXPAQqI,2544
|
|
5
|
-
cecil-0.0.15.dist-info/METADATA,sha256=wnQowxMqcWRjlNsThxwypFnck_TuDDFmNCzZr34_Y54,2677
|
|
6
|
-
cecil-0.0.15.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
7
|
-
cecil-0.0.15.dist-info/licenses/LICENSE.txt,sha256=mUexcmfYx3bG1VIzAdQTOf_NzStYw6-QkKVdUY_d4i4,1066
|
|
8
|
-
cecil-0.0.15.dist-info/RECORD,,
|
|
File without changes
|