earthengine-api 1.5.24__tar.gz → 1.6.0__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 earthengine-api might be problematic. Click here for more details.
- {earthengine_api-1.5.24/earthengine_api.egg-info → earthengine_api-1.6.0}/PKG-INFO +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0/earthengine_api.egg-info}/PKG-INFO +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/__init__.py +11 -10
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/_arg_types.py +2 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/_cloud_api_utils.py +7 -6
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/_helpers.py +3 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/apifunction.py +11 -9
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/apitestcase.py +2 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/batch.py +46 -42
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/blob.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/classifier.py +57 -59
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/cli/commands.py +9 -7
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/cli/utils.py +13 -9
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/clusterer.py +39 -41
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/collection.py +42 -42
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/computedobject.py +10 -10
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/confusionmatrix.py +8 -8
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/customfunction.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/data.py +15 -14
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/daterange.py +9 -9
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/deprecation.py +13 -11
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/deserializer.py +5 -5
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/dictionary.py +11 -11
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_array.py +17 -17
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_date.py +22 -22
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_list.py +15 -15
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_number.py +5 -5
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_string.py +6 -6
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_types.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/element.py +14 -14
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/errormargin.py +3 -3
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/feature.py +67 -70
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/featurecollection.py +30 -32
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/filter.py +88 -90
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/function.py +3 -3
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/geometry.py +61 -62
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/image.py +216 -209
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/image_converter.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/imagecollection.py +23 -20
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/join.py +13 -15
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/kernel.py +55 -57
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/oauth.py +26 -20
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/pixeltype.py +5 -5
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/projection.py +4 -3
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/reducer.py +39 -41
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/serializer.py +4 -4
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/table_converter.py +3 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/terrain.py +6 -8
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/_cloud_api_utils_test.py +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/_helpers_test.py +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/batch_test.py +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/data_test.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_test.py +3 -3
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/errormargin_test.py +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/image_converter_test.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/pixeltype_test.py +1 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/projection_test.py +2 -3
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/table_converter_test.py +2 -2
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/pyproject.toml +1 -1
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/LICENSE +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/MANIFEST.in +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/README.md +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/earthengine_api.egg-info/SOURCES.txt +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/earthengine_api.egg-info/dependency_links.txt +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/earthengine_api.egg-info/entry_points.txt +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/earthengine_api.egg-info/requires.txt +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/earthengine_api.egg-info/top_level.txt +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/_utils.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/cli/__init__.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/cli/eecli.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/cli/eecli_wrapper.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/ee_exception.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/encodable.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/mapclient.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/model.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/py.typed +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/_utils_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/algorithms.json +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/apifunction_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/blob_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/classifier_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/cloud_api_discovery_document.json +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/clusterer_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/collection_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/computedobject_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/confusionmatrix_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/daterange_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/deprecation_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/deserializer_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/dictionary_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_array_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_date_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_list_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_number_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_string_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/ee_types_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/element_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/feature_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/featurecollection_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/filter_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/function_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/geometry_point_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/geometry_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/image_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/imagecollection_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/join_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/kernel_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/model_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/oauth_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/reducer_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/serializer_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/ee/tests/terrain_test.py +0 -0
- {earthengine_api-1.5.24 → earthengine_api-1.6.0}/setup.cfg +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"""The EE Python library."""
|
|
2
2
|
|
|
3
|
-
__version__ = '1.
|
|
3
|
+
__version__ = '1.6.0'
|
|
4
4
|
|
|
5
5
|
# Using lowercase function naming to match the JavaScript names.
|
|
6
6
|
# pylint: disable=g-bad-name
|
|
7
7
|
|
|
8
8
|
import collections
|
|
9
|
+
from collections.abc import Hashable, Sequence
|
|
9
10
|
import datetime
|
|
10
11
|
import inspect
|
|
11
12
|
import os
|
|
12
13
|
import re
|
|
13
|
-
from typing import Any,
|
|
14
|
+
from typing import Any, Optional, Type, Union
|
|
14
15
|
|
|
15
16
|
from google.oauth2 import service_account
|
|
16
17
|
|
|
@@ -311,7 +312,7 @@ def _Promote(arg: Optional[Any], a_class: str) -> Optional[Any]:
|
|
|
311
312
|
return Element(arg.func, arg.args, arg.varName)
|
|
312
313
|
else:
|
|
313
314
|
# No way to convert.
|
|
314
|
-
raise EEException('Cannot convert {
|
|
315
|
+
raise EEException(f'Cannot convert {arg} to Element.')
|
|
315
316
|
elif a_class == 'Geometry':
|
|
316
317
|
if isinstance(arg, Collection):
|
|
317
318
|
return ApiFunction.call_('Collection.geometry', arg)
|
|
@@ -340,7 +341,7 @@ def _Promote(arg: Optional[Any], a_class: str) -> Optional[Any]:
|
|
|
340
341
|
# Image.parseExpression().
|
|
341
342
|
return arg
|
|
342
343
|
else:
|
|
343
|
-
raise EEException('Argument is not a function: {
|
|
344
|
+
raise EEException(f'Argument is not a function: {arg}')
|
|
344
345
|
elif a_class == 'Dictionary':
|
|
345
346
|
if isinstance(arg, dict):
|
|
346
347
|
return arg
|
|
@@ -372,7 +373,7 @@ def _Promote(arg: Optional[Any], a_class: str) -> Optional[Any]:
|
|
|
372
373
|
# arg is the name of a method in a_class.
|
|
373
374
|
return getattr(cls, arg)()
|
|
374
375
|
else:
|
|
375
|
-
raise EEException('Unknown algorithm: {
|
|
376
|
+
raise EEException(f'Unknown algorithm: {a_class}.{arg}')
|
|
376
377
|
else:
|
|
377
378
|
# Client-side cast.
|
|
378
379
|
return cls(arg)
|
|
@@ -419,9 +420,9 @@ def _InitializeGeneratedClasses() -> None:
|
|
|
419
420
|
"""Generate classes for extra types that appear in the web API."""
|
|
420
421
|
signatures = ApiFunction.allSignatures()
|
|
421
422
|
# Collect the first part of all function names.
|
|
422
|
-
names =
|
|
423
|
+
names = {name.split('.')[0] for name in signatures}
|
|
423
424
|
# Collect the return types of all functions.
|
|
424
|
-
returns =
|
|
425
|
+
returns = {signatures[sig]['returns'] for sig in signatures}
|
|
425
426
|
|
|
426
427
|
want = [name for name in names.intersection(returns) if name not in globals()]
|
|
427
428
|
|
|
@@ -435,7 +436,7 @@ def _InitializeGeneratedClasses() -> None:
|
|
|
435
436
|
types._registerClasses(globals()) # pylint: disable=protected-access
|
|
436
437
|
|
|
437
438
|
|
|
438
|
-
def _MakeClass(name: str) ->
|
|
439
|
+
def _MakeClass(name: str) -> type[Any]:
|
|
439
440
|
"""Generates a dynamic API class for a given name."""
|
|
440
441
|
|
|
441
442
|
def init(self, *args, **kwargs):
|
|
@@ -480,11 +481,11 @@ def _MakeClass(name: str) -> Type[Any]:
|
|
|
480
481
|
if not onlyOneArg:
|
|
481
482
|
# We don't know what to do with multiple args.
|
|
482
483
|
raise EEException(
|
|
483
|
-
'Too many arguments for ee.{
|
|
484
|
+
f'Too many arguments for ee.{name}(): {args}')
|
|
484
485
|
elif firstArgIsPrimitive:
|
|
485
486
|
# Can't cast a primitive.
|
|
486
487
|
raise EEException(
|
|
487
|
-
'Invalid argument for ee.{
|
|
488
|
+
'Invalid argument for ee.{}(): {}. '
|
|
488
489
|
'Must be a ComputedObject.'.format(name, args))
|
|
489
490
|
|
|
490
491
|
result = args[0]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"""Internal types used to represent arguments to the API."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
from collections.abc import Sequence
|
|
4
5
|
import datetime
|
|
5
|
-
from typing import Any as AnyType,
|
|
6
|
+
from typing import Any as AnyType, Union
|
|
6
7
|
|
|
7
8
|
from ee import classifier
|
|
8
9
|
from ee import clusterer
|
|
@@ -6,12 +6,13 @@ parameters and result values.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import calendar
|
|
9
|
+
from collections.abc import Sequence
|
|
9
10
|
import copy
|
|
10
11
|
import datetime
|
|
11
12
|
import json
|
|
12
13
|
import os
|
|
13
14
|
import re
|
|
14
|
-
from typing import Any, Callable, Optional,
|
|
15
|
+
from typing import Any, Callable, Optional, Type, Union
|
|
15
16
|
import warnings
|
|
16
17
|
|
|
17
18
|
import google_auth_httplib2
|
|
@@ -56,7 +57,7 @@ class _Http:
|
|
|
56
57
|
body: Optional[str] = None,
|
|
57
58
|
headers: Optional[dict[str, str]] = None,
|
|
58
59
|
redirections: Optional[int] = None,
|
|
59
|
-
connection_type: Optional[
|
|
60
|
+
connection_type: Optional[type[Any]] = None,
|
|
60
61
|
) -> tuple[httplib2.Response, Any]:
|
|
61
62
|
"""Makes an HTTP request using httplib2 semantics."""
|
|
62
63
|
del connection_type # Ignored
|
|
@@ -434,7 +435,7 @@ def _convert_list_images_filter_params_to_list_assets_params(params) -> str:
|
|
|
434
435
|
# query in a set of double quotes. We trivially avoid doubly-escaping the
|
|
435
436
|
# quotes by replacing double quotes with single quotes.
|
|
436
437
|
region = region.replace('"', "'")
|
|
437
|
-
query_strings.append('intersects("{}")'
|
|
438
|
+
query_strings.append(f'intersects("{region}")')
|
|
438
439
|
del params['region']
|
|
439
440
|
if 'properties' in params:
|
|
440
441
|
if isinstance(params['properties'], list) and any(
|
|
@@ -534,9 +535,9 @@ def convert_asset_id_to_asset_name(asset_id: str) -> str:
|
|
|
534
535
|
if re.match(ASSET_NAME_PATTERN, asset_id) or is_asset_root(asset_id):
|
|
535
536
|
return asset_id
|
|
536
537
|
elif asset_id.split('/')[0] in ['users', 'projects']:
|
|
537
|
-
return 'projects/earthengine-legacy/assets/{}'
|
|
538
|
+
return f'projects/earthengine-legacy/assets/{asset_id}'
|
|
538
539
|
else:
|
|
539
|
-
return 'projects/earthengine-public/assets/{}'
|
|
540
|
+
return f'projects/earthengine-public/assets/{asset_id}'
|
|
540
541
|
|
|
541
542
|
|
|
542
543
|
def split_asset_name(asset_name: str) -> tuple[str, str]:
|
|
@@ -561,7 +562,7 @@ def convert_operation_name_to_task_id(operation_name: str) -> str:
|
|
|
561
562
|
|
|
562
563
|
def convert_task_id_to_operation_name(task_id: str) -> str:
|
|
563
564
|
"""Converts a task ID to an Operation name."""
|
|
564
|
-
return 'projects/{}/operations/{}'
|
|
565
|
+
return f'projects/{_cloud_api_user_project}/operations/{task_id}'
|
|
565
566
|
|
|
566
567
|
|
|
567
568
|
def convert_params_to_image_manifest(params: dict[str, Any]) -> dict[str, Any]:
|
|
@@ -7,10 +7,11 @@ referenced from there (e.g., "ee.profilePrinting").
|
|
|
7
7
|
# Using lowercase function naming to match the JavaScript names.
|
|
8
8
|
# pylint: disable=g-bad-name
|
|
9
9
|
|
|
10
|
+
from collections.abc import Iterator
|
|
10
11
|
import contextlib
|
|
11
12
|
import json
|
|
12
13
|
import sys
|
|
13
|
-
from typing import Any,
|
|
14
|
+
from typing import Any, Optional, TextIO, Union
|
|
14
15
|
|
|
15
16
|
from google.auth import crypt
|
|
16
17
|
from google.oauth2 import service_account
|
|
@@ -59,7 +60,7 @@ def ServiceAccountCredentials(
|
|
|
59
60
|
|
|
60
61
|
# Probably a PEM key - just read the file into 'key_data'.
|
|
61
62
|
if key_file:
|
|
62
|
-
with open(key_file
|
|
63
|
+
with open(key_file) as file_:
|
|
63
64
|
key_data = file_.read()
|
|
64
65
|
|
|
65
66
|
# Raw PEM key.
|
|
@@ -18,7 +18,7 @@ from __future__ import annotations
|
|
|
18
18
|
import copy
|
|
19
19
|
import keyword
|
|
20
20
|
import re
|
|
21
|
-
from typing import Any
|
|
21
|
+
from typing import Any
|
|
22
22
|
|
|
23
23
|
from ee import _utils
|
|
24
24
|
from ee import computedobject
|
|
@@ -41,7 +41,7 @@ class ApiFunction(function.Function):
|
|
|
41
41
|
_bound_signatures: set[str] = set()
|
|
42
42
|
|
|
43
43
|
@_utils.accept_opt_prefix('opt_signature')
|
|
44
|
-
def __init__(self, name: str, signature:
|
|
44
|
+
def __init__(self, name: str, signature: dict[str, Any] | None = None):
|
|
45
45
|
"""Creates a function defined by the EE API.
|
|
46
46
|
|
|
47
47
|
Args:
|
|
@@ -113,15 +113,17 @@ class ApiFunction(function.Function):
|
|
|
113
113
|
def allSignatures(cls) -> dict[str, dict[str, Any]]:
|
|
114
114
|
"""Returns a map from the name to signature for all API functions."""
|
|
115
115
|
cls.initialize()
|
|
116
|
-
return
|
|
117
|
-
for name, func in cls._api.items()])
|
|
116
|
+
return {name: func.getSignature() for name, func in cls._api.items()}
|
|
118
117
|
|
|
119
118
|
@classmethod
|
|
120
119
|
def unboundFunctions(cls) -> dict[str, Any]:
|
|
121
120
|
"""Returns the functions that have not been bound using importApi() yet."""
|
|
122
121
|
cls.initialize()
|
|
123
|
-
return
|
|
124
|
-
|
|
122
|
+
return {
|
|
123
|
+
name: func
|
|
124
|
+
for name, func in cls._api.items()
|
|
125
|
+
if name not in cls._bound_signatures
|
|
126
|
+
}
|
|
125
127
|
|
|
126
128
|
# TODO(user): Any -> ApiFunction for the return type.
|
|
127
129
|
@classmethod
|
|
@@ -142,7 +144,7 @@ class ApiFunction(function.Function):
|
|
|
142
144
|
return result
|
|
143
145
|
|
|
144
146
|
@classmethod
|
|
145
|
-
def lookupInternal(cls, name: str) ->
|
|
147
|
+
def lookupInternal(cls, name: str) -> ApiFunction | None:
|
|
146
148
|
"""Looks up an API function by name.
|
|
147
149
|
|
|
148
150
|
Args:
|
|
@@ -181,7 +183,7 @@ class ApiFunction(function.Function):
|
|
|
181
183
|
target: Any,
|
|
182
184
|
prefix: str,
|
|
183
185
|
type_name: str,
|
|
184
|
-
prepend:
|
|
186
|
+
prepend: str | None = None,
|
|
185
187
|
) -> None:
|
|
186
188
|
"""Adds all API functions that begin with a given prefix to a target class.
|
|
187
189
|
|
|
@@ -248,7 +250,7 @@ class ApiFunction(function.Function):
|
|
|
248
250
|
setattr(target, fname, bound_function)
|
|
249
251
|
|
|
250
252
|
@staticmethod
|
|
251
|
-
def clearApi(target:
|
|
253
|
+
def clearApi(target: type[Any]) -> None:
|
|
252
254
|
"""Removes all methods added by importApi() from a target class.
|
|
253
255
|
|
|
254
256
|
Args:
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"""A TestCase that initializes the library with standard API methods."""
|
|
2
2
|
|
|
3
|
+
from collections.abc import Iterable
|
|
3
4
|
import contextlib
|
|
4
5
|
import json
|
|
5
6
|
import os
|
|
6
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, Optional
|
|
7
8
|
|
|
8
9
|
from googleapiclient import discovery
|
|
9
10
|
|
|
@@ -9,10 +9,11 @@ The public function styling uses camelCase to match the JavaScript names.
|
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
11
11
|
|
|
12
|
+
from collections.abc import Sequence
|
|
12
13
|
import enum
|
|
13
14
|
import json
|
|
14
15
|
import re
|
|
15
|
-
from typing import Any
|
|
16
|
+
from typing import Any
|
|
16
17
|
|
|
17
18
|
from ee import _cloud_api_utils
|
|
18
19
|
from ee import data
|
|
@@ -54,14 +55,14 @@ class Task:
|
|
|
54
55
|
CANCELLED = 'CANCELLED'
|
|
55
56
|
|
|
56
57
|
@classmethod
|
|
57
|
-
def active(cls, state:
|
|
58
|
+
def active(cls, state: str | Task.State) -> bool:
|
|
58
59
|
"""Returns True if the given state is an active one."""
|
|
59
60
|
if isinstance(state, str):
|
|
60
61
|
state = cls(state)
|
|
61
62
|
return state in (cls.READY, cls.RUNNING, cls.CANCEL_REQUESTED)
|
|
62
63
|
|
|
63
64
|
@classmethod
|
|
64
|
-
def success(cls, state:
|
|
65
|
+
def success(cls, state: str | Task.State) -> bool:
|
|
65
66
|
"""Returns True if the given state indicates a completed task."""
|
|
66
67
|
if isinstance(state, str):
|
|
67
68
|
state = cls(state)
|
|
@@ -74,22 +75,22 @@ class Task:
|
|
|
74
75
|
FEATURE_VIEW = 'FEATURE_VIEW'
|
|
75
76
|
BIGQUERY = 'BIGQUERY'
|
|
76
77
|
|
|
77
|
-
config:
|
|
78
|
-
id:
|
|
79
|
-
name:
|
|
78
|
+
config: dict[str, Any] | None
|
|
79
|
+
id: str | None
|
|
80
|
+
name: str | None
|
|
80
81
|
state: State
|
|
81
82
|
task_type: Type
|
|
82
|
-
workload_tag:
|
|
83
|
+
workload_tag: int | str | None
|
|
83
84
|
|
|
84
|
-
_request_id:
|
|
85
|
+
_request_id: str | None
|
|
85
86
|
|
|
86
87
|
def __init__(
|
|
87
88
|
self,
|
|
88
|
-
task_id:
|
|
89
|
+
task_id: str | None,
|
|
89
90
|
task_type: Type,
|
|
90
91
|
state: State,
|
|
91
|
-
config:
|
|
92
|
-
name:
|
|
92
|
+
config: dict[str, Any] | None = None,
|
|
93
|
+
name: str | None = None,
|
|
93
94
|
):
|
|
94
95
|
"""Creates a Task with the given ID and configuration.
|
|
95
96
|
|
|
@@ -121,7 +122,7 @@ class Task:
|
|
|
121
122
|
self.name = name
|
|
122
123
|
|
|
123
124
|
@property
|
|
124
|
-
def operation_name(self) ->
|
|
125
|
+
def operation_name(self) -> str | None:
|
|
125
126
|
if self.name:
|
|
126
127
|
return self.name
|
|
127
128
|
if self.id:
|
|
@@ -152,8 +153,7 @@ class Task:
|
|
|
152
153
|
elif self.task_type == Task.Type.EXPORT_CLASSIFIER:
|
|
153
154
|
result = data.exportClassifier(self._request_id, self.config)
|
|
154
155
|
else:
|
|
155
|
-
raise ee_exception.EEException(
|
|
156
|
-
'Unknown Task type "{}"'.format(self.task_type))
|
|
156
|
+
raise ee_exception.EEException(f'Unknown Task type "{self.task_type}"')
|
|
157
157
|
if not self.id:
|
|
158
158
|
self.id = _cloud_api_utils.convert_operation_name_to_task_id(
|
|
159
159
|
result['name'])
|
|
@@ -204,11 +204,13 @@ class Task:
|
|
|
204
204
|
def __repr__(self) -> str:
|
|
205
205
|
"""Returns a string representation of the task."""
|
|
206
206
|
if self.config and self.id:
|
|
207
|
-
return '<Task
|
|
208
|
-
|
|
207
|
+
return '<Task {} {}: {} ({})>'.format(
|
|
208
|
+
self.id, self.task_type, self.config['description'], self.state
|
|
209
|
+
)
|
|
209
210
|
elif self.config:
|
|
210
|
-
return '<Task
|
|
211
|
-
|
|
211
|
+
return '<Task {}: {} ({})>'.format(
|
|
212
|
+
self.task_type, self.config['description'], self.state
|
|
213
|
+
)
|
|
212
214
|
else:
|
|
213
215
|
return '<Task "%s">' % self.id
|
|
214
216
|
|
|
@@ -231,7 +233,7 @@ class Export:
|
|
|
231
233
|
cls,
|
|
232
234
|
image: Any,
|
|
233
235
|
description: str = 'myExportImageTask',
|
|
234
|
-
config:
|
|
236
|
+
config: dict[str, Any] | None = None,
|
|
235
237
|
):
|
|
236
238
|
"""Creates a task to export an EE Image to Google Drive or Cloud Storage.
|
|
237
239
|
|
|
@@ -1231,8 +1233,7 @@ def _prepare_image_export_config(
|
|
|
1231
1233
|
if config:
|
|
1232
1234
|
if 'skipEmptyTiles' in config:
|
|
1233
1235
|
raise ValueError('skipEmptyTiles is only supported for GeoTIFF exports.')
|
|
1234
|
-
raise ee_exception.EEException(
|
|
1235
|
-
'Unknown configuration options: {}.'.format(config))
|
|
1236
|
+
raise ee_exception.EEException(f'Unknown configuration options: {config}.')
|
|
1236
1237
|
|
|
1237
1238
|
return request
|
|
1238
1239
|
|
|
@@ -1279,8 +1280,7 @@ def _prepare_map_export_config(
|
|
|
1279
1280
|
# for JSON encoding.
|
|
1280
1281
|
request['priority'] = {'value': int(config.pop('priority'))}
|
|
1281
1282
|
if config:
|
|
1282
|
-
raise ee_exception.EEException(
|
|
1283
|
-
'Unknown configuration options: {}.'.format(config))
|
|
1283
|
+
raise ee_exception.EEException(f'Unknown configuration options: {config}.')
|
|
1284
1284
|
return request
|
|
1285
1285
|
|
|
1286
1286
|
|
|
@@ -1351,8 +1351,7 @@ def _prepare_table_export_config(
|
|
|
1351
1351
|
request['priority'] = {'value': int(config.pop('priority'))}
|
|
1352
1352
|
|
|
1353
1353
|
if config:
|
|
1354
|
-
raise ee_exception.EEException(
|
|
1355
|
-
'Unknown configuration options: {}.'.format(config))
|
|
1354
|
+
raise ee_exception.EEException(f'Unknown configuration options: {config}.')
|
|
1356
1355
|
return request
|
|
1357
1356
|
|
|
1358
1357
|
|
|
@@ -1394,8 +1393,7 @@ def _prepare_video_export_config(
|
|
|
1394
1393
|
request['priority'] = {'value': int(config.pop('priority'))}
|
|
1395
1394
|
|
|
1396
1395
|
if config:
|
|
1397
|
-
raise ee_exception.EEException(
|
|
1398
|
-
'Unknown configuration options: {}.'.format(config))
|
|
1396
|
+
raise ee_exception.EEException(f'Unknown configuration options: {config}.')
|
|
1399
1397
|
return request
|
|
1400
1398
|
|
|
1401
1399
|
|
|
@@ -1427,7 +1425,8 @@ def _build_image_file_export_options(
|
|
|
1427
1425
|
config)
|
|
1428
1426
|
else:
|
|
1429
1427
|
raise ee_exception.EEException(
|
|
1430
|
-
'"{}" is not a valid export destination'
|
|
1428
|
+
f'"{export_destination}" is not a valid export destination'
|
|
1429
|
+
)
|
|
1431
1430
|
|
|
1432
1431
|
file_format_options = config.pop(IMAGE_FORMAT_OPTIONS_FIELD, {})
|
|
1433
1432
|
|
|
@@ -1499,7 +1498,8 @@ def _build_image_file_export_options(
|
|
|
1499
1498
|
|
|
1500
1499
|
if file_format_options:
|
|
1501
1500
|
raise ee_exception.EEException(
|
|
1502
|
-
'Unknown file format options: {}.'
|
|
1501
|
+
f'Unknown file format options: {file_format_options}.'
|
|
1502
|
+
)
|
|
1503
1503
|
|
|
1504
1504
|
return file_export_options
|
|
1505
1505
|
|
|
@@ -1531,7 +1531,8 @@ def _build_table_file_export_options(
|
|
|
1531
1531
|
config)
|
|
1532
1532
|
else:
|
|
1533
1533
|
raise ee_exception.EEException(
|
|
1534
|
-
'"{}" is not a valid export destination'
|
|
1534
|
+
f'"{export_destination}" is not a valid export destination'
|
|
1535
|
+
)
|
|
1535
1536
|
return file_export_options
|
|
1536
1537
|
|
|
1537
1538
|
|
|
@@ -1584,7 +1585,8 @@ def _build_video_file_export_options(
|
|
|
1584
1585
|
config)
|
|
1585
1586
|
else:
|
|
1586
1587
|
raise ee_exception.EEException(
|
|
1587
|
-
'"{}" is not a valid export destination'
|
|
1588
|
+
f'"{export_destination}" is not a valid export destination'
|
|
1589
|
+
)
|
|
1588
1590
|
return file_export_options
|
|
1589
1591
|
|
|
1590
1592
|
|
|
@@ -1773,10 +1775,11 @@ def _get_rank_by_one_thing_rule(rule_str: str) -> dict[str, Any]:
|
|
|
1773
1775
|
matches = re.findall(r'^([\S]+.*)\s+(ASC|DESC)$', rule_str.strip())
|
|
1774
1776
|
if not matches:
|
|
1775
1777
|
raise ee_exception.EEException(
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1778
|
+
'Ranking rule format is invalid. Each rule should be defined by a '
|
|
1779
|
+
'rule type and a direction (ASC or DESC), separated by a space. '
|
|
1780
|
+
'Valid rule types are: .geometryType, .minZoomLevel, or a feature '
|
|
1781
|
+
'property name.'
|
|
1782
|
+
)
|
|
1780
1783
|
|
|
1781
1784
|
output = {}
|
|
1782
1785
|
rule_type, rule_dir = matches[0]
|
|
@@ -1796,8 +1799,8 @@ def _get_rank_by_one_thing_rule(rule_str: str) -> dict[str, Any]:
|
|
|
1796
1799
|
|
|
1797
1800
|
|
|
1798
1801
|
def _get_ranking_rule(
|
|
1799
|
-
rules:
|
|
1800
|
-
) ->
|
|
1802
|
+
rules: str | list[str] | None,
|
|
1803
|
+
) -> dict[str, list[dict[str, Any]]] | None:
|
|
1801
1804
|
"""Returns a RankingRule dict created from the rank-by-one-thing rules.
|
|
1802
1805
|
|
|
1803
1806
|
Args:
|
|
@@ -1819,11 +1822,12 @@ def _get_ranking_rule(
|
|
|
1819
1822
|
return {'rankByOneThingRule': rank_by_one_thing_rules}
|
|
1820
1823
|
|
|
1821
1824
|
raise ee_exception.EEException(
|
|
1822
|
-
|
|
1823
|
-
|
|
1825
|
+
'Unable to build ranking rule from rules. Rules should '
|
|
1826
|
+
'either be a comma-separated string or list of strings.'
|
|
1827
|
+
)
|
|
1824
1828
|
|
|
1825
1829
|
|
|
1826
|
-
def _build_thinning_options(config: dict[str, Any]) ->
|
|
1830
|
+
def _build_thinning_options(config: dict[str, Any]) -> dict[str, Any] | None:
|
|
1827
1831
|
"""Returns a ThinningOptions dict created from the config.
|
|
1828
1832
|
|
|
1829
1833
|
Args:
|
|
@@ -1843,7 +1847,7 @@ def _build_thinning_options(config: dict[str, Any]) -> Optional[dict[str, Any]]:
|
|
|
1843
1847
|
return output
|
|
1844
1848
|
|
|
1845
1849
|
|
|
1846
|
-
def _build_ranking_options(config: dict[str, Any]) ->
|
|
1850
|
+
def _build_ranking_options(config: dict[str, Any]) -> dict[str, Any] | None:
|
|
1847
1851
|
"""Returns a RankingOptions dict created from the config.
|
|
1848
1852
|
|
|
1849
1853
|
Args:
|
|
@@ -2027,7 +2031,7 @@ def _canonicalize_parameters(config, destination):
|
|
|
2027
2031
|
|
|
2028
2032
|
|
|
2029
2033
|
def _canonicalize_region(
|
|
2030
|
-
region:
|
|
2034
|
+
region: str | geometry.Geometry | Any,
|
|
2031
2035
|
) -> geometry.Geometry:
|
|
2032
2036
|
"""Converts a region parameter to a form appropriate for export."""
|
|
2033
2037
|
region_error = ee_exception.EEException(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""A wrapper for Blobs."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
from ee import _arg_types
|
|
7
7
|
from ee import apifunction
|
|
@@ -84,7 +84,7 @@ class Blob(computedobject.ComputedObject):
|
|
|
84
84
|
return 'Blob'
|
|
85
85
|
|
|
86
86
|
def string(
|
|
87
|
-
self, encoding:
|
|
87
|
+
self, encoding: _arg_types.String | None = None
|
|
88
88
|
) -> ee_string.String:
|
|
89
89
|
"""Returns the contents of the blob as a String.
|
|
90
90
|
|