ee-client 2.0.1__tar.gz → 2.0.3__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.
- {ee_client-2.0.1 → ee_client-2.0.3}/PKG-INFO +1 -1
- {ee_client-2.0.1 → ee_client-2.0.3}/ee_client.egg-info/PKG-INFO +1 -1
- {ee_client-2.0.1 → ee_client-2.0.3}/ee_client.egg-info/SOURCES.txt +5 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/__init__.py +1 -1
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/client.py +21 -84
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/data.py +38 -13
- ee_client-2.0.3/eeclient/export/__init__.py +2 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/export/image.py +15 -5
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/export/table.py +14 -5
- ee_client-2.0.3/eeclient/interfaces/__init__.py +25 -0
- ee_client-2.0.3/eeclient/interfaces/export.py +65 -0
- ee_client-2.0.3/eeclient/interfaces/operations.py +43 -0
- ee_client-2.0.3/eeclient/interfaces/tasks.py +13 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/tasks.py +19 -4
- {ee_client-2.0.1 → ee_client-2.0.3}/pyproject.toml +2 -2
- {ee_client-2.0.1 → ee_client-2.0.3}/tests/test_data.py +2 -2
- {ee_client-2.0.1 → ee_client-2.0.3}/LICENSE +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/README.rst +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/ee_client.egg-info/dependency_links.txt +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/ee_client.egg-info/requires.txt +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/ee_client.egg-info/top_level.txt +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/exceptions.py +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/helpers.py +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/models.py +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/eeclient/oauth_app.py +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/setup.cfg +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/tests/test_client.py +0 -0
- {ee_client-2.0.1 → ee_client-2.0.3}/tests/test_models.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ee-client
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: extends the capabilities of the earthengine-api by providing custom session management and client interactions
|
|
5
5
|
Author-email: Daniel Guerrero <dfgm2006@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/dfguerrerom/ee-client
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ee-client
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: extends the capabilities of the earthengine-api by providing custom session management and client interactions
|
|
5
5
|
Author-email: Daniel Guerrero <dfgm2006@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/dfguerrerom/ee-client
|
|
@@ -14,8 +14,13 @@ eeclient/helpers.py
|
|
|
14
14
|
eeclient/models.py
|
|
15
15
|
eeclient/oauth_app.py
|
|
16
16
|
eeclient/tasks.py
|
|
17
|
+
eeclient/export/__init__.py
|
|
17
18
|
eeclient/export/image.py
|
|
18
19
|
eeclient/export/table.py
|
|
20
|
+
eeclient/interfaces/__init__.py
|
|
21
|
+
eeclient/interfaces/export.py
|
|
22
|
+
eeclient/interfaces/operations.py
|
|
23
|
+
eeclient/interfaces/tasks.py
|
|
19
24
|
tests/test_client.py
|
|
20
25
|
tests/test_data.py
|
|
21
26
|
tests/test_models.py
|
|
@@ -7,18 +7,19 @@ import httpx
|
|
|
7
7
|
import logging
|
|
8
8
|
from contextlib import asynccontextmanager
|
|
9
9
|
|
|
10
|
-
from eeclient.export.table import table_to_asset, table_to_drive
|
|
11
|
-
from eeclient.export.image import image_to_asset, image_to_drive
|
|
12
10
|
from eeclient.exceptions import EEClientError, EERestException
|
|
13
|
-
from eeclient.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
from eeclient.models import GEEHeaders, GoogleTokens, SepalHeaders
|
|
12
|
+
|
|
13
|
+
import eeclient.export as _export_module
|
|
14
|
+
import eeclient.data as _operations_module
|
|
15
|
+
import eeclient.tasks as _tasks_module
|
|
16
|
+
|
|
17
|
+
from eeclient.interfaces import (
|
|
18
|
+
_ModuleProxy,
|
|
19
|
+
ExportProtocol,
|
|
20
|
+
OperationsProtocol,
|
|
21
|
+
TasksProtocol,
|
|
22
|
+
expose_module_methods,
|
|
22
23
|
)
|
|
23
24
|
|
|
24
25
|
logger = logging.getLogger("eeclient")
|
|
@@ -411,82 +412,18 @@ class EESession:
|
|
|
411
412
|
)
|
|
412
413
|
|
|
413
414
|
@property
|
|
414
|
-
def
|
|
415
|
-
|
|
416
|
-
return _Operations(self)
|
|
415
|
+
def export(self) -> ExportProtocol:
|
|
416
|
+
return _ModuleProxy(self, _export_module) # type: ignore
|
|
417
417
|
|
|
418
418
|
@property
|
|
419
|
-
def
|
|
420
|
-
return
|
|
419
|
+
def operations(self) -> OperationsProtocol:
|
|
420
|
+
return _ModuleProxy(self, _operations_module) # type: ignore
|
|
421
421
|
|
|
422
422
|
@property
|
|
423
|
-
def tasks(self):
|
|
424
|
-
return
|
|
423
|
+
def tasks(self) -> TasksProtocol:
|
|
424
|
+
return _ModuleProxy(self, _tasks_module) # type: ignore
|
|
425
425
|
|
|
426
426
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
async def get_assets_async(self, folder: str):
|
|
432
|
-
return await get_assets_async(
|
|
433
|
-
self._session,
|
|
434
|
-
folder=folder,
|
|
435
|
-
)
|
|
436
|
-
|
|
437
|
-
async def get_info(self, ee_object=None, workloadTag=None, serialized_object=None):
|
|
438
|
-
return await get_info(
|
|
439
|
-
self._session,
|
|
440
|
-
ee_object,
|
|
441
|
-
workloadTag,
|
|
442
|
-
serialized_object,
|
|
443
|
-
)
|
|
444
|
-
|
|
445
|
-
async def get_map_id(
|
|
446
|
-
self,
|
|
447
|
-
ee_image,
|
|
448
|
-
vis_params: MapTileOptions = {}, # type: ignore
|
|
449
|
-
bands=None,
|
|
450
|
-
format=None,
|
|
451
|
-
):
|
|
452
|
-
return await get_map_id(self._session, ee_image, vis_params, bands, format)
|
|
453
|
-
|
|
454
|
-
async def get_asset(self, asset_id: str, not_exists_ok: bool = False):
|
|
455
|
-
return await get_asset(self._session, asset_id, not_exists_ok)
|
|
456
|
-
|
|
457
|
-
async def create_folder(self, folder: str):
|
|
458
|
-
return await create_folder(self._session, folder)
|
|
459
|
-
|
|
460
|
-
async def delete_asset(self, asset_id):
|
|
461
|
-
return await delete_asset(self._session, asset_id)
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
class _Export:
|
|
465
|
-
def __init__(self, session):
|
|
466
|
-
self._session = session
|
|
467
|
-
|
|
468
|
-
async def table_to_drive(self, collection, **kwargs):
|
|
469
|
-
return await table_to_drive(self._session, collection, **kwargs)
|
|
470
|
-
|
|
471
|
-
async def table_to_asset(self, collection, **kwargs):
|
|
472
|
-
return await table_to_asset(self._session, collection, **kwargs)
|
|
473
|
-
|
|
474
|
-
async def image_to_drive(self, image, **kwargs):
|
|
475
|
-
return await image_to_drive(self._session, image, **kwargs)
|
|
476
|
-
|
|
477
|
-
async def image_to_asset(self, image, **kwargs):
|
|
478
|
-
return await image_to_asset(self._session, image, **kwargs)
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
class _Tasks:
|
|
482
|
-
def __init__(self, session):
|
|
483
|
-
self._session = session
|
|
484
|
-
|
|
485
|
-
async def get_tasks(self):
|
|
486
|
-
return await get_tasks(self._session)
|
|
487
|
-
|
|
488
|
-
async def get_task(self, task_id):
|
|
489
|
-
return await get_task(self._session, task_id)
|
|
490
|
-
|
|
491
|
-
async def get_task_by_name(self, asset_name):
|
|
492
|
-
return await get_task_by_name(self._session, asset_name)
|
|
427
|
+
expose_module_methods(_ModuleProxy, _export_module)
|
|
428
|
+
expose_module_methods(_ModuleProxy, _operations_module)
|
|
429
|
+
expose_module_methods(_ModuleProxy, _tasks_module)
|
|
@@ -22,7 +22,7 @@ from ee.data import TileFetcher
|
|
|
22
22
|
logger = logging.getLogger("eeclient")
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
async def
|
|
25
|
+
async def get_map_id_async(
|
|
26
26
|
client: "EESession",
|
|
27
27
|
ee_image: Image,
|
|
28
28
|
vis_params: Union[dict, MapTileOptions] = {},
|
|
@@ -74,7 +74,7 @@ async def get_map_id(
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
async def
|
|
77
|
+
async def get_info_async(
|
|
78
78
|
client: "EESession",
|
|
79
79
|
ee_object: Union[ComputedObject, None] = None,
|
|
80
80
|
workloadTag=None,
|
|
@@ -110,7 +110,7 @@ async def get_info(
|
|
|
110
110
|
return response["result"]
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
async def
|
|
113
|
+
async def get_asset_async(
|
|
114
114
|
client: "EESession", asset_id: str, not_exists_ok: bool = True
|
|
115
115
|
) -> Optional[dict]:
|
|
116
116
|
"""Async version of get_asset.
|
|
@@ -144,7 +144,7 @@ async def get_asset(
|
|
|
144
144
|
raise
|
|
145
145
|
|
|
146
146
|
|
|
147
|
-
async def
|
|
147
|
+
async def _list_assets_concurrently(client: "EESession", folders):
|
|
148
148
|
"""List assets concurrently.
|
|
149
149
|
|
|
150
150
|
Args:
|
|
@@ -182,7 +182,7 @@ async def get_assets_async(client: "EESession", folder: str = "") -> List[dict]:
|
|
|
182
182
|
current_folders = [
|
|
183
183
|
await folder_queue.get() for _ in range(folder_queue.qsize())
|
|
184
184
|
]
|
|
185
|
-
assets_groups = await
|
|
185
|
+
assets_groups = await _list_assets_concurrently(client, current_folders)
|
|
186
186
|
|
|
187
187
|
for assets in assets_groups:
|
|
188
188
|
for asset in assets:
|
|
@@ -195,7 +195,7 @@ async def get_assets_async(client: "EESession", folder: str = "") -> List[dict]:
|
|
|
195
195
|
return asset_list
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
async def
|
|
198
|
+
async def create_folder_async(client: "EESession", folder: Union[Path, str]) -> str:
|
|
199
199
|
"""Create a folder and its parents in Earth Engine if they don't exist.
|
|
200
200
|
|
|
201
201
|
Args:
|
|
@@ -217,7 +217,7 @@ async def create_folder(client: "EESession", folder: Union[Path, str]) -> str:
|
|
|
217
217
|
|
|
218
218
|
full_path = str(await client.get_assets_folder() / Path(folder))
|
|
219
219
|
|
|
220
|
-
if asset := await
|
|
220
|
+
if asset := await get_asset_async(client, full_path):
|
|
221
221
|
logger.debug(f"Folder already exists: {full_path}")
|
|
222
222
|
return full_path
|
|
223
223
|
|
|
@@ -232,7 +232,7 @@ async def create_folder(client: "EESession", folder: Union[Path, str]) -> str:
|
|
|
232
232
|
folder_id = f"projects/{{project}}/assets/{current}"
|
|
233
233
|
|
|
234
234
|
logger.debug(f"Checking if folder exists: {current}, {folder_id}")
|
|
235
|
-
asset = await
|
|
235
|
+
asset = await get_asset_async(client, folder_id)
|
|
236
236
|
if asset:
|
|
237
237
|
continue
|
|
238
238
|
else:
|
|
@@ -251,7 +251,7 @@ async def create_folder(client: "EESession", folder: Union[Path, str]) -> str:
|
|
|
251
251
|
return full_path
|
|
252
252
|
|
|
253
253
|
|
|
254
|
-
async def
|
|
254
|
+
async def delete_asset_async(client, asset_id: Union[str, Path]) -> None:
|
|
255
255
|
"""Delete an asset from Earth Engine."""
|
|
256
256
|
|
|
257
257
|
asset_id = str(asset_id)
|
|
@@ -272,7 +272,7 @@ async def delete_asset(client, asset_id: Union[str, Path]) -> None:
|
|
|
272
272
|
raise
|
|
273
273
|
|
|
274
274
|
|
|
275
|
-
async def
|
|
275
|
+
async def delete_folder_async(
|
|
276
276
|
client, folder_id: Union[str, Path], recursive: bool = False
|
|
277
277
|
) -> None:
|
|
278
278
|
"""Delete a folder asset. If recursive is True, first delete all child
|
|
@@ -297,13 +297,38 @@ async def delete_folder(
|
|
|
297
297
|
# Process deletion from the deepest assets to the shallowest.
|
|
298
298
|
for depth in sorted(depth_to_assets.keys(), reverse=True):
|
|
299
299
|
tasks = [
|
|
300
|
-
asyncio.create_task(
|
|
300
|
+
asyncio.create_task(delete_asset_async(client, asset["id"]))
|
|
301
301
|
for asset in depth_to_assets[depth]
|
|
302
302
|
]
|
|
303
303
|
# Await deletion of all assets at the current depth level.
|
|
304
304
|
await asyncio.gather(*tasks)
|
|
305
305
|
logger.info(f"Deleted all assets at depth {depth}")
|
|
306
306
|
|
|
307
|
-
await
|
|
307
|
+
await delete_asset_async(client, folder_id)
|
|
308
308
|
else:
|
|
309
|
-
await
|
|
309
|
+
await delete_asset_async(client, folder_id)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
# Backward compatibility aliases
|
|
313
|
+
async def get_map_id(*args, **kwargs):
|
|
314
|
+
return await get_map_id_async(*args, **kwargs)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
async def get_info(*args, **kwargs):
|
|
318
|
+
return await get_info_async(*args, **kwargs)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
async def get_asset(*args, **kwargs):
|
|
322
|
+
return await get_asset_async(*args, **kwargs)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
async def create_folder(*args, **kwargs):
|
|
326
|
+
return await create_folder_async(*args, **kwargs)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
async def delete_asset(*args, **kwargs):
|
|
330
|
+
return await delete_asset_async(*args, **kwargs)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
async def delete_folder(*args, **kwargs):
|
|
334
|
+
return await delete_folder_async(*args, **kwargs)
|
|
@@ -79,6 +79,7 @@ class PixelGrid(BaseModel):
|
|
|
79
79
|
|
|
80
80
|
@model_validator(mode="before")
|
|
81
81
|
def check_crs_exclusivity(cls, values):
|
|
82
|
+
log.debug(f">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {values}")
|
|
82
83
|
crs_code = values.get("crs_code")
|
|
83
84
|
crs_wkt = values.get("crs_wkt")
|
|
84
85
|
if crs_code is not None and crs_wkt is not None:
|
|
@@ -108,7 +109,7 @@ class ExtraExportOptions(BaseExportModel):
|
|
|
108
109
|
# TODO I didn't add dimensions...
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
async def
|
|
112
|
+
async def _export_image(
|
|
112
113
|
client: "EESession",
|
|
113
114
|
image,
|
|
114
115
|
*,
|
|
@@ -179,7 +180,7 @@ async def export_image(
|
|
|
179
180
|
return await client.rest_call("POST", url, data=request_params)
|
|
180
181
|
|
|
181
182
|
|
|
182
|
-
async def
|
|
183
|
+
async def image_to_drive_async(
|
|
183
184
|
client: "EESession",
|
|
184
185
|
image,
|
|
185
186
|
filename_prefix: str = "",
|
|
@@ -206,7 +207,7 @@ async def image_to_drive(
|
|
|
206
207
|
),
|
|
207
208
|
)
|
|
208
209
|
|
|
209
|
-
return await
|
|
210
|
+
return await _export_image(
|
|
210
211
|
client=client,
|
|
211
212
|
image=image,
|
|
212
213
|
drive_options=drive_options,
|
|
@@ -223,7 +224,7 @@ async def image_to_drive(
|
|
|
223
224
|
)
|
|
224
225
|
|
|
225
226
|
|
|
226
|
-
async def
|
|
227
|
+
async def image_to_asset_async(
|
|
227
228
|
client: "EESession",
|
|
228
229
|
image,
|
|
229
230
|
asset_id: str,
|
|
@@ -245,7 +246,7 @@ async def image_to_asset(
|
|
|
245
246
|
earth_engine_destination=EarthEngineDestination(name=asset_id),
|
|
246
247
|
)
|
|
247
248
|
|
|
248
|
-
return await
|
|
249
|
+
return await _export_image(
|
|
249
250
|
client=client,
|
|
250
251
|
image=image,
|
|
251
252
|
asset_options=asset_options,
|
|
@@ -260,3 +261,12 @@ async def image_to_asset(
|
|
|
260
261
|
crs=crs,
|
|
261
262
|
crs_transform=crs_transform,
|
|
262
263
|
)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
# Backward compatibility aliases
|
|
267
|
+
async def image_to_drive(*args, **kwargs):
|
|
268
|
+
return await image_to_drive_async(*args, **kwargs)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
async def image_to_asset(*args, **kwargs):
|
|
272
|
+
return await image_to_asset_async(*args, **kwargs)
|
|
@@ -62,7 +62,7 @@ class ExportOptions(BaseExportModel):
|
|
|
62
62
|
# See the api: https://developers.google.com/earth-engine/reference/rest/v1alpha/projects.table/export#TableFileExportOptions
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
async def
|
|
65
|
+
async def _export_table(
|
|
66
66
|
client: "EESession",
|
|
67
67
|
collection,
|
|
68
68
|
*,
|
|
@@ -110,7 +110,7 @@ async def export_table(
|
|
|
110
110
|
return await client.rest_call("POST", url, data=params)
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
async def
|
|
113
|
+
async def table_to_drive_async(
|
|
114
114
|
client: "EESession",
|
|
115
115
|
collection,
|
|
116
116
|
filename_prefix: str,
|
|
@@ -129,7 +129,7 @@ async def table_to_drive(
|
|
|
129
129
|
file_format=file_format, drive_destination=drive_destination
|
|
130
130
|
)
|
|
131
131
|
|
|
132
|
-
return await
|
|
132
|
+
return await _export_table(
|
|
133
133
|
client=client,
|
|
134
134
|
collection=collection,
|
|
135
135
|
drive_options=drive_options,
|
|
@@ -140,7 +140,7 @@ async def table_to_drive(
|
|
|
140
140
|
)
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
async def
|
|
143
|
+
async def table_to_asset_async(
|
|
144
144
|
client: "EESession",
|
|
145
145
|
collection,
|
|
146
146
|
asset_id: str,
|
|
@@ -156,7 +156,7 @@ async def table_to_asset(
|
|
|
156
156
|
earth_engine_destination=EarthEngineDestination(name=asset_id)
|
|
157
157
|
)
|
|
158
158
|
|
|
159
|
-
return await
|
|
159
|
+
return await _export_table(
|
|
160
160
|
client=client,
|
|
161
161
|
collection=collection,
|
|
162
162
|
asset_options=asset_options,
|
|
@@ -165,3 +165,12 @@ async def table_to_asset(
|
|
|
165
165
|
max_vertices=max_vertices,
|
|
166
166
|
priority=priority,
|
|
167
167
|
)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# Backward compatibility aliases
|
|
171
|
+
async def table_to_drive(*args, **kwargs):
|
|
172
|
+
return await table_to_drive_async(*args, **kwargs)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
async def table_to_asset(*args, **kwargs):
|
|
176
|
+
return await table_to_asset_async(*args, **kwargs)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from functools import wraps
|
|
2
|
+
import inspect
|
|
3
|
+
from .export import ExportProtocol # noqa: F401
|
|
4
|
+
from .operations import OperationsProtocol # noqa: F401
|
|
5
|
+
from .tasks import TasksProtocol # noqa: F401
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class _ModuleProxy:
|
|
9
|
+
def __init__(self, session, module):
|
|
10
|
+
self._session = session
|
|
11
|
+
self._module = module
|
|
12
|
+
|
|
13
|
+
def __repr__(self):
|
|
14
|
+
return f"<Proxy for {self._module.__name__}>"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def expose_module_methods(proxy_cls, module):
|
|
18
|
+
for name, func in inspect.getmembers(module, inspect.iscoroutinefunction):
|
|
19
|
+
|
|
20
|
+
@wraps(func)
|
|
21
|
+
async def method(self, *args, __func=func, **kwargs):
|
|
22
|
+
return await __func(self._session, *args, **kwargs)
|
|
23
|
+
|
|
24
|
+
method.__signature__ = inspect.signature(func) # type: ignore
|
|
25
|
+
setattr(proxy_cls, name, method)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from typing import Optional, Protocol, Union, Any
|
|
2
|
+
from eeclient.export.image import ImageFileFormat, PixelGrid, AffineTransform
|
|
3
|
+
from eeclient.export.table import TableFileFormat
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ExportProtocol(Protocol):
|
|
7
|
+
async def image_to_asset_async(
|
|
8
|
+
self,
|
|
9
|
+
image,
|
|
10
|
+
asset_id: str,
|
|
11
|
+
description: str = ...,
|
|
12
|
+
max_pixels: Optional[int] = ...,
|
|
13
|
+
grid: Optional[PixelGrid] = ...,
|
|
14
|
+
request_id: Optional[str] = ...,
|
|
15
|
+
workload_tag: Optional[str] = ...,
|
|
16
|
+
priority: Optional[int] = ...,
|
|
17
|
+
region: Union[Any, str] = ...,
|
|
18
|
+
scale: Optional[float] = ...,
|
|
19
|
+
crs: Optional[str] = ...,
|
|
20
|
+
crs_transform: Optional[AffineTransform] = ...,
|
|
21
|
+
) -> dict:
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
async def image_to_drive_async(
|
|
25
|
+
self,
|
|
26
|
+
image,
|
|
27
|
+
filename_prefix: str = ...,
|
|
28
|
+
folder: Optional[str] = ...,
|
|
29
|
+
file_format: ImageFileFormat = ...,
|
|
30
|
+
description: str = ...,
|
|
31
|
+
max_pixels: Optional[int] = ...,
|
|
32
|
+
grid: Optional[PixelGrid] = ...,
|
|
33
|
+
request_id: Optional[str] = ...,
|
|
34
|
+
workload_tag: Optional[str] = ...,
|
|
35
|
+
priority: Optional[int] = ...,
|
|
36
|
+
region: Union[Any, str] = ...,
|
|
37
|
+
scale: Optional[float] = ...,
|
|
38
|
+
crs: Optional[str] = ...,
|
|
39
|
+
crs_transform: Optional[AffineTransform] = ...,
|
|
40
|
+
) -> dict:
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
async def table_to_drive_async(
|
|
44
|
+
self,
|
|
45
|
+
collection,
|
|
46
|
+
filename_prefix: str,
|
|
47
|
+
file_format: TableFileFormat,
|
|
48
|
+
folder: Optional[str] = ...,
|
|
49
|
+
description: str = ...,
|
|
50
|
+
selectors: Optional[list] = ...,
|
|
51
|
+
max_vertices: Optional[int] = ...,
|
|
52
|
+
priority: Optional[int] = ...,
|
|
53
|
+
) -> dict:
|
|
54
|
+
...
|
|
55
|
+
|
|
56
|
+
async def table_to_asset(
|
|
57
|
+
self,
|
|
58
|
+
collection,
|
|
59
|
+
asset_id: str,
|
|
60
|
+
description: str = ...,
|
|
61
|
+
selectors: Optional[list] = ...,
|
|
62
|
+
max_vertices: Optional[int] = ...,
|
|
63
|
+
priority: Optional[int] = ...,
|
|
64
|
+
) -> dict:
|
|
65
|
+
...
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from typing import Protocol, Union, Optional, List
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from eeclient.models import MapTileOptions
|
|
4
|
+
from ee.image import Image
|
|
5
|
+
from ee.computedobject import ComputedObject
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OperationsProtocol(Protocol):
|
|
9
|
+
async def get_map_id_async(
|
|
10
|
+
self,
|
|
11
|
+
ee_image: Image,
|
|
12
|
+
vis_params: Union[dict, MapTileOptions] = {},
|
|
13
|
+
bands: Optional[str] = None,
|
|
14
|
+
format: Optional[str] = None,
|
|
15
|
+
) -> dict:
|
|
16
|
+
...
|
|
17
|
+
|
|
18
|
+
async def get_info_async(
|
|
19
|
+
self,
|
|
20
|
+
ee_object: Union[ComputedObject, None] = None,
|
|
21
|
+
workloadTag=None,
|
|
22
|
+
serialized_object=None,
|
|
23
|
+
) -> dict:
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
async def get_asset_async(
|
|
27
|
+
self, asset_id: str, not_exists_ok: bool = True
|
|
28
|
+
) -> Optional[dict]:
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
async def get_assets_async(self, folder: str = "") -> List[dict]:
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
async def create_folder_async(self, folder: Union[Path, str]) -> str:
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
async def delete_asset_async(self, asset_id: Union[str, Path]) -> None:
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
async def delete_folder_async(
|
|
41
|
+
self, folder_id: Union[str, Path], recursive: bool = False
|
|
42
|
+
) -> None:
|
|
43
|
+
...
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from typing import Protocol, Optional
|
|
2
|
+
from eeclient.tasks import TasksResponse, Task
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TasksProtocol(Protocol):
|
|
6
|
+
async def get_tasks_async(self) -> TasksResponse:
|
|
7
|
+
...
|
|
8
|
+
|
|
9
|
+
async def get_task_async(self, task_id: str) -> Optional[Task]:
|
|
10
|
+
...
|
|
11
|
+
|
|
12
|
+
async def get_task_by_name_async(self, asset_name: str) -> Optional[Task]:
|
|
13
|
+
...
|
|
@@ -63,7 +63,7 @@ class TasksResponse(CamelCaseModel):
|
|
|
63
63
|
operations: List[Task]
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
async def
|
|
66
|
+
async def get_tasks_async(client: "EESession") -> TasksResponse:
|
|
67
67
|
"""Search for the described task in the user Task list return None if
|
|
68
68
|
nothing is found.
|
|
69
69
|
|
|
@@ -79,7 +79,7 @@ async def get_tasks(client: "EESession") -> TasksResponse:
|
|
|
79
79
|
return operations_response
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
async def
|
|
82
|
+
async def get_task_async(client: "EESession", task_id: str):
|
|
83
83
|
"""Search for the described task in the user Task list return None if
|
|
84
84
|
nothing is found.
|
|
85
85
|
|
|
@@ -103,7 +103,9 @@ async def get_task(client: "EESession", task_id: str):
|
|
|
103
103
|
raise e
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
async def
|
|
106
|
+
async def get_task_by_name_async(
|
|
107
|
+
client: "EESession", asset_name: str
|
|
108
|
+
) -> Optional[Task]:
|
|
107
109
|
"""Search for the described task in the user Task list return None if
|
|
108
110
|
nothing is found.
|
|
109
111
|
|
|
@@ -113,8 +115,21 @@ async def get_task_by_name(client: "EESession", asset_name: str) -> Optional[Tas
|
|
|
113
115
|
Returns:
|
|
114
116
|
return the found task else None
|
|
115
117
|
"""
|
|
116
|
-
operations_response = await
|
|
118
|
+
operations_response = await get_tasks_async(client)
|
|
117
119
|
for task in operations_response.operations:
|
|
118
120
|
if task.metadata.description == asset_name:
|
|
119
121
|
return task
|
|
120
122
|
return None
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# Backward compatibility aliases
|
|
126
|
+
async def get_tasks(*args, **kwargs):
|
|
127
|
+
return await get_tasks_async(*args, **kwargs)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
async def get_task(*args, **kwargs):
|
|
131
|
+
return await get_task_async(*args, **kwargs)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
async def get_task_by_name(*args, **kwargs):
|
|
135
|
+
return await get_task_by_name_async(*args, **kwargs)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ee-client"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.3"
|
|
8
8
|
description = "extends the capabilities of the earthengine-api by providing custom session management and client interactions"
|
|
9
9
|
readme = { file = "README.rst", content-type = "text/x-rst" }
|
|
10
10
|
authors = [
|
|
@@ -66,7 +66,7 @@ branch = true
|
|
|
66
66
|
[tool.commitizen]
|
|
67
67
|
tag_format = "v$major.$minor.$patch$prerelease"
|
|
68
68
|
update_changelog_on_bump = false
|
|
69
|
-
version = "2.0.
|
|
69
|
+
version = "2.0.3"
|
|
70
70
|
version_files = [
|
|
71
71
|
"pyproject.toml:version",
|
|
72
72
|
"eeclient/__init__.py:__version__",
|
|
@@ -16,7 +16,7 @@ from eeclient.data import (
|
|
|
16
16
|
get_assets_async,
|
|
17
17
|
get_info,
|
|
18
18
|
get_map_id,
|
|
19
|
-
|
|
19
|
+
_list_assets_concurrently,
|
|
20
20
|
)
|
|
21
21
|
from eeclient.exceptions import EERestException
|
|
22
22
|
from eeclient.client import EESession
|
|
@@ -155,7 +155,7 @@ async def test_list_assets_concurrently(sepal_headers):
|
|
|
155
155
|
# Wait a moment for propagation.
|
|
156
156
|
await asyncio.sleep(2)
|
|
157
157
|
folders = [folder_id]
|
|
158
|
-
assets_lists = await
|
|
158
|
+
assets_lists = await _list_assets_concurrently(session, folders)
|
|
159
159
|
assert isinstance(assets_lists, list)
|
|
160
160
|
|
|
161
161
|
# Depending on your project, the list might be empty or not.
|
|
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
|
|
File without changes
|