cecil 0.0.15__tar.gz → 0.0.16__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.16/.editorconfig +16 -0
- cecil-0.0.16/.gitignore +11 -0
- cecil-0.0.16/Makefile +26 -0
- {cecil-0.0.15 → cecil-0.0.16}/PKG-INFO +12 -12
- {cecil-0.0.15 → cecil-0.0.16}/README.md +10 -10
- {cecil-0.0.15 → cecil-0.0.16}/pyproject.toml +2 -2
- {cecil-0.0.15 → cecil-0.0.16}/src/cecil/__init__.py +1 -0
- {cecil-0.0.15 → cecil-0.0.16}/src/cecil/client.py +21 -24
- {cecil-0.0.15 → cecil-0.0.16}/src/cecil/models.py +5 -28
- cecil-0.0.16/src/cecil/version.py +1 -0
- {cecil-0.0.15 → cecil-0.0.16}/tests/test_client.py +1 -13
- cecil-0.0.15/.gitignore +0 -6
- cecil-0.0.15/Makefile +0 -33
- cecil-0.0.15/__about__.py +0 -1
- {cecil-0.0.15 → cecil-0.0.16}/CONTRIBUTING.md +0 -0
- {cecil-0.0.15 → cecil-0.0.16}/LICENSE.txt +0 -0
- {cecil-0.0.15 → cecil-0.0.16}/src/cecil/errors.py +0 -0
- {cecil-0.0.15 → cecil-0.0.16}/tests/__init__.py +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
indent_style = space
|
|
8
|
+
indent_size = 4
|
|
9
|
+
tab_width = 4
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.tf]
|
|
13
|
+
indent_size = 2
|
|
14
|
+
|
|
15
|
+
[{*.go,Makefile}]
|
|
16
|
+
indent_style = tab
|
cecil-0.0.16/.gitignore
ADDED
cecil-0.0.16/Makefile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
HL = @printf "\033[36m>> $1\033[0m\n"
|
|
2
|
+
|
|
3
|
+
.PHONY: build
|
|
4
|
+
build:
|
|
5
|
+
$(call HL,build)
|
|
6
|
+
@hatch build
|
|
7
|
+
|
|
8
|
+
.PHONY: clean
|
|
9
|
+
clean:
|
|
10
|
+
$(call HL,clean)
|
|
11
|
+
@hatch clean
|
|
12
|
+
|
|
13
|
+
.PHONY: publish.prod
|
|
14
|
+
publish.prod: clean build
|
|
15
|
+
$(call HL,publish.prod)
|
|
16
|
+
@twine upload --repository pypi dist/*
|
|
17
|
+
|
|
18
|
+
.PHONY: publish.test
|
|
19
|
+
publish.test: clean build
|
|
20
|
+
$(call HL,publish.test)
|
|
21
|
+
@twine upload --repository testpypi dist/*
|
|
22
|
+
|
|
23
|
+
.PHONY: test
|
|
24
|
+
test:
|
|
25
|
+
$(call HL,test)
|
|
26
|
+
@hatch test -v
|
|
@@ -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
|
|
@@ -55,30 +55,30 @@ my_data_request = client.create_data_request(
|
|
|
55
55
|
dataset_id=planet_forest_carbon_diligence_id,
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
print(client.get_data_request(my_data_request.id)
|
|
58
|
+
print(client.get_data_request(my_data_request.id))
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
### Create a
|
|
61
|
+
### Create a transformation using the Cecil client
|
|
62
62
|
|
|
63
63
|
```python
|
|
64
|
-
|
|
64
|
+
my_transformation = client.create_transformation(
|
|
65
65
|
data_request_id=my_data_request.id,
|
|
66
66
|
crs="EPSG:4326",
|
|
67
|
-
|
|
67
|
+
spatial_resolution=0.005,
|
|
68
68
|
)
|
|
69
69
|
|
|
70
|
-
print(client.
|
|
70
|
+
print(client.get_transformation(my_transformation.id))
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
### Query data (once
|
|
73
|
+
### Query data (once transformation is completed)
|
|
74
74
|
|
|
75
75
|
```python
|
|
76
76
|
df = client.query(f'''
|
|
77
77
|
SELECT *
|
|
78
|
-
FROM
|
|
78
|
+
FROM
|
|
79
79
|
planet.forest_carbon_diligence
|
|
80
80
|
WHERE
|
|
81
|
-
|
|
81
|
+
transformation_id = '{my_transformation.id}'
|
|
82
82
|
''')
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -93,9 +93,9 @@ client.list_data_requests()
|
|
|
93
93
|
|
|
94
94
|
client.get_data_request(my_data_request.id)
|
|
95
95
|
|
|
96
|
-
client.
|
|
96
|
+
client.list_transformations()
|
|
97
97
|
|
|
98
|
-
client.
|
|
98
|
+
client.get_transformation(my_transformation.id)
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
## License
|
|
@@ -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(
|
|
@@ -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):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.16"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import responses
|
|
2
2
|
|
|
3
3
|
from src.cecil.client import Client
|
|
4
|
-
from src.cecil.models import DataRequest
|
|
4
|
+
from src.cecil.models import DataRequest
|
|
5
5
|
|
|
6
6
|
FROZEN_TIME = "2024-01-01T00:00:00.000Z"
|
|
7
7
|
|
|
@@ -20,8 +20,6 @@ def test_client_create_data_request():
|
|
|
20
20
|
"id": "id",
|
|
21
21
|
"aoiId": "aoi_id",
|
|
22
22
|
"datasetId": "dataset_id",
|
|
23
|
-
"subRequests": [],
|
|
24
|
-
"status": "processing",
|
|
25
23
|
"created_at": FROZEN_TIME,
|
|
26
24
|
"created_by": "user_id",
|
|
27
25
|
},
|
|
@@ -35,8 +33,6 @@ def test_client_create_data_request():
|
|
|
35
33
|
id="id",
|
|
36
34
|
aoiId="aoi_id",
|
|
37
35
|
datasetId="dataset_id",
|
|
38
|
-
subRequests=[],
|
|
39
|
-
status="processing",
|
|
40
36
|
created_at="2024-01-01T00:00:00.000Z",
|
|
41
37
|
created_by="user_id",
|
|
42
38
|
)
|
|
@@ -53,8 +49,6 @@ def test_client_list_data_requests():
|
|
|
53
49
|
"id": "data_request_id_1",
|
|
54
50
|
"aoiId": "aoi_id",
|
|
55
51
|
"datasetId": "dataset_id",
|
|
56
|
-
"subRequests": [], # TODO: Add some SubRequests
|
|
57
|
-
"status": "processing",
|
|
58
52
|
"created_at": "2024-09-19T04:45:57.561Z",
|
|
59
53
|
"created_by": "user_id",
|
|
60
54
|
},
|
|
@@ -62,8 +56,6 @@ def test_client_list_data_requests():
|
|
|
62
56
|
"id": "data_request_id_2",
|
|
63
57
|
"aoiId": "aoi_id",
|
|
64
58
|
"datasetId": "dataset_id",
|
|
65
|
-
"subRequests": [], # TODO: Add some SubRequests
|
|
66
|
-
"status": "completed",
|
|
67
59
|
"created_at": "2024-09-19T04:54:38.252Z",
|
|
68
60
|
"created_by": "user_id",
|
|
69
61
|
},
|
|
@@ -79,8 +71,6 @@ def test_client_list_data_requests():
|
|
|
79
71
|
id="data_request_id_1",
|
|
80
72
|
aoiId="aoi_id",
|
|
81
73
|
datasetId="dataset_id",
|
|
82
|
-
subRequests=[],
|
|
83
|
-
status=DataRequestStatus.PROCESSING,
|
|
84
74
|
created_at="2024-09-19T04:45:57.561Z",
|
|
85
75
|
created_by="user_id",
|
|
86
76
|
),
|
|
@@ -88,8 +78,6 @@ def test_client_list_data_requests():
|
|
|
88
78
|
id="data_request_id_2",
|
|
89
79
|
aoiId="aoi_id",
|
|
90
80
|
datasetId="dataset_id",
|
|
91
|
-
subRequests=[],
|
|
92
|
-
status=DataRequestStatus.COMPLETED,
|
|
93
81
|
created_at="2024-09-19T04:54:38.252Z",
|
|
94
82
|
created_by="user_id",
|
|
95
83
|
),
|
cecil-0.0.15/.gitignore
DELETED
cecil-0.0.15/Makefile
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
HL = @printf "\033[36m>> $1\033[0m\n"
|
|
2
|
-
|
|
3
|
-
default: help
|
|
4
|
-
|
|
5
|
-
.PHONY: help
|
|
6
|
-
help:
|
|
7
|
-
@echo "Usage: make <target>\n"
|
|
8
|
-
@grep -E ".+:\s.*?##" $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}'
|
|
9
|
-
|
|
10
|
-
.PHONY: build
|
|
11
|
-
build: clean test ## Build package
|
|
12
|
-
$(call HL,build)
|
|
13
|
-
hatch build
|
|
14
|
-
|
|
15
|
-
.PHONY: clean
|
|
16
|
-
clean: ## Clean dist
|
|
17
|
-
$(call HL,clean)
|
|
18
|
-
hatch clean
|
|
19
|
-
|
|
20
|
-
.PHONY: publish-test
|
|
21
|
-
publish-test: build ## Publish package to testpypi
|
|
22
|
-
$(call HL,publish-test)
|
|
23
|
-
twine upload --repository testpypi dist/*
|
|
24
|
-
|
|
25
|
-
.PHONY: publish-prod
|
|
26
|
-
publish-prod: build ## Publish package to pypi
|
|
27
|
-
$(call HL,publish-prod)
|
|
28
|
-
twine upload --repository pypi dist/*
|
|
29
|
-
|
|
30
|
-
.PHONY: test
|
|
31
|
-
test: ## Run tests
|
|
32
|
-
$(call HL,test)
|
|
33
|
-
hatch test -v
|
cecil-0.0.15/__about__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.15"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|