earthengine-api 1.5.13rc0__py3-none-any.whl → 1.7.4__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 earthengine-api might be problematic. Click here for more details.
- {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/METADATA +3 -3
- earthengine_api-1.7.4.dist-info/RECORD +109 -0
- {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/WHEEL +1 -1
- ee/__init__.py +29 -28
- ee/_arg_types.py +7 -6
- ee/_cloud_api_utils.py +95 -78
- ee/_helpers.py +17 -13
- ee/_state.py +105 -0
- ee/_utils.py +2 -1
- ee/apifunction.py +21 -19
- ee/apitestcase.py +33 -38
- ee/batch.py +87 -77
- ee/blob.py +10 -12
- ee/classifier.py +57 -59
- ee/cli/commands.py +178 -114
- ee/cli/eecli.py +1 -1
- ee/cli/utils.py +61 -42
- ee/clusterer.py +39 -41
- ee/collection.py +64 -54
- ee/computedobject.py +19 -16
- ee/confusionmatrix.py +9 -9
- ee/customfunction.py +13 -12
- ee/data.py +220 -322
- ee/daterange.py +10 -10
- ee/deprecation.py +21 -13
- ee/deserializer.py +25 -20
- ee/dictionary.py +11 -11
- ee/ee_array.py +22 -20
- ee/ee_date.py +23 -23
- ee/ee_list.py +15 -16
- ee/ee_number.py +11 -21
- ee/ee_string.py +24 -32
- ee/ee_types.py +4 -4
- ee/element.py +15 -15
- ee/encodable.py +7 -4
- ee/errormargin.py +4 -4
- ee/feature.py +68 -71
- ee/featurecollection.py +41 -40
- ee/filter.py +90 -92
- ee/function.py +8 -8
- ee/geometry.py +95 -93
- ee/image.py +238 -236
- ee/image_converter.py +4 -4
- ee/imagecollection.py +30 -27
- ee/join.py +13 -15
- ee/kernel.py +55 -57
- ee/mapclient.py +9 -9
- ee/model.py +29 -31
- ee/oauth.py +76 -63
- ee/pixeltype.py +6 -6
- ee/projection.py +5 -4
- ee/reducer.py +41 -41
- ee/serializer.py +14 -14
- ee/table_converter.py +7 -6
- ee/terrain.py +7 -9
- ee/tests/_cloud_api_utils_test.py +21 -6
- ee/tests/_helpers_test.py +57 -4
- ee/tests/_state_test.py +49 -0
- ee/tests/algorithms.json +85 -2
- ee/tests/apifunction_test.py +5 -5
- ee/tests/batch_test.py +135 -57
- ee/tests/blob_test.py +5 -5
- ee/tests/classifier_test.py +3 -3
- ee/tests/clusterer_test.py +3 -3
- ee/tests/collection_test.py +48 -13
- ee/tests/confusionmatrix_test.py +3 -3
- ee/tests/data_test.py +484 -55
- ee/tests/daterange_test.py +4 -4
- ee/tests/deprecation_test.py +6 -4
- ee/tests/deserializer_test.py +64 -5
- ee/tests/dictionary_test.py +12 -12
- ee/tests/ee_array_test.py +3 -3
- ee/tests/ee_date_test.py +4 -4
- ee/tests/ee_list_test.py +3 -3
- ee/tests/ee_number_test.py +75 -30
- ee/tests/ee_string_test.py +11 -3
- ee/tests/ee_test.py +40 -22
- ee/tests/element_test.py +2 -2
- ee/tests/errormargin_test.py +1 -1
- ee/tests/feature_test.py +10 -10
- ee/tests/featurecollection_test.py +3 -3
- ee/tests/filter_test.py +4 -4
- ee/tests/function_test.py +5 -5
- ee/tests/geometry_point_test.py +3 -3
- ee/tests/geometry_test.py +93 -52
- ee/tests/image_converter_test.py +1 -3
- ee/tests/image_test.py +3 -3
- ee/tests/imagecollection_test.py +3 -3
- ee/tests/join_test.py +3 -3
- ee/tests/kernel_test.py +7 -3
- ee/tests/model_test.py +17 -5
- ee/tests/oauth_test.py +189 -7
- ee/tests/pixeltype_test.py +6 -7
- ee/tests/projection_test.py +5 -6
- ee/tests/reducer_test.py +16 -3
- ee/tests/serializer_test.py +39 -12
- ee/tests/table_converter_test.py +51 -7
- ee/tests/terrain_test.py +11 -3
- earthengine_api-1.5.13rc0.dist-info/RECORD +0 -107
- {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/entry_points.txt +0 -0
- {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/licenses/LICENSE +0 -0
- {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/top_level.txt +0 -0
ee/apifunction.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""A class for representing built-in EE API Function.
|
|
2
2
|
|
|
3
3
|
Earth Engine can dynamically produce a JSON array listing the
|
|
4
|
-
algorithms available to the user.
|
|
4
|
+
algorithms available to the user. Each item in the dictionary identifies
|
|
5
5
|
the name and return type of the algorithm, the name and type of its
|
|
6
6
|
arguments, whether they're required or optional, default values and docs
|
|
7
7
|
for each argument and the algorithms as a whole.
|
|
@@ -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
|
|
@@ -31,17 +31,17 @@ from ee import function
|
|
|
31
31
|
|
|
32
32
|
class ApiFunction(function.Function):
|
|
33
33
|
"""An object representing an EE API Function."""
|
|
34
|
-
_signature:
|
|
34
|
+
_signature: dict[str, Any]
|
|
35
35
|
|
|
36
36
|
# A dictionary of functions defined by the API server.
|
|
37
|
-
_api:
|
|
37
|
+
_api: dict[str, ApiFunction] = {}
|
|
38
38
|
|
|
39
39
|
# A set of algorithm names containing all algorithms that have been bound to
|
|
40
40
|
# a function so far using importApi().
|
|
41
|
-
_bound_signatures:
|
|
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:
|
|
@@ -60,7 +60,7 @@ class ApiFunction(function.Function):
|
|
|
60
60
|
return (isinstance(other, ApiFunction) and
|
|
61
61
|
self.getSignature() == other.getSignature())
|
|
62
62
|
|
|
63
|
-
#
|
|
63
|
+
# __hash__ is needed because __eq__ is defined.
|
|
64
64
|
# See https://docs.python.org/3/reference/datamodel.html#object.__hash__
|
|
65
65
|
def __hash__(self) -> int:
|
|
66
66
|
return hash(computedobject.ComputedObject.freeze(self.getSignature()))
|
|
@@ -84,7 +84,7 @@ class ApiFunction(function.Function):
|
|
|
84
84
|
return cls.lookup(name).call(*args, **kwargs)
|
|
85
85
|
|
|
86
86
|
@classmethod
|
|
87
|
-
def apply_(cls, name: str, named_args:
|
|
87
|
+
def apply_(cls, name: str, named_args: dict[str, Any]) -> Any:
|
|
88
88
|
"""Call a named API function with a dictionary of named arguments.
|
|
89
89
|
|
|
90
90
|
Args:
|
|
@@ -101,27 +101,29 @@ class ApiFunction(function.Function):
|
|
|
101
101
|
del encoder # Unused.
|
|
102
102
|
return self._signature['name']
|
|
103
103
|
|
|
104
|
-
def encode_cloud_invocation(self, encoder: Any) ->
|
|
104
|
+
def encode_cloud_invocation(self, encoder: Any) -> dict[str, Any]:
|
|
105
105
|
del encoder # Unused.
|
|
106
106
|
return {'functionName': self._signature['name']}
|
|
107
107
|
|
|
108
|
-
def getSignature(self) ->
|
|
108
|
+
def getSignature(self) -> dict[str, Any]:
|
|
109
109
|
"""Returns a description of the interface provided by this function."""
|
|
110
110
|
return self._signature
|
|
111
111
|
|
|
112
112
|
@classmethod
|
|
113
|
-
def allSignatures(cls) ->
|
|
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
|
-
def unboundFunctions(cls) ->
|
|
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:
|
ee/apitestcase.py
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
"""A TestCase that initializes the library with standard API methods."""
|
|
2
2
|
|
|
3
|
+
from collections.abc import Iterable
|
|
3
4
|
import contextlib
|
|
5
|
+
import copy
|
|
4
6
|
import json
|
|
5
7
|
import os
|
|
6
|
-
from typing import Any
|
|
8
|
+
from typing import Any
|
|
7
9
|
|
|
8
10
|
from googleapiclient import discovery
|
|
9
11
|
|
|
10
12
|
import unittest
|
|
11
13
|
import ee
|
|
12
14
|
from ee import _cloud_api_utils
|
|
15
|
+
from ee import _state
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
# Cached algorithms list
|
|
16
|
-
_algorithms_cache:
|
|
19
|
+
_algorithms_cache: dict[str, Any] | None = None
|
|
17
20
|
|
|
18
21
|
|
|
19
|
-
def GetAlgorithms() ->
|
|
22
|
+
def GetAlgorithms() -> dict[str, Any]:
|
|
20
23
|
"""Returns a static version of the ListAlgorithms call.
|
|
21
24
|
|
|
22
25
|
After ApiTestCase.setUp is called, ee.data.getAlgorithms() is patched to use
|
|
@@ -37,10 +40,10 @@ def GetAlgorithms() -> Dict[str, Any]:
|
|
|
37
40
|
|
|
38
41
|
class ApiTestCase(unittest.TestCase):
|
|
39
42
|
"""A TestCase that initializes the library with standard API methods."""
|
|
40
|
-
last_download_call:
|
|
41
|
-
last_thumb_call:
|
|
42
|
-
last_table_call:
|
|
43
|
-
last_mapid_call:
|
|
43
|
+
last_download_call: Any | None
|
|
44
|
+
last_thumb_call: Any | None
|
|
45
|
+
last_table_call: Any | None
|
|
46
|
+
last_mapid_call: Any | None
|
|
44
47
|
|
|
45
48
|
def setUp(self):
|
|
46
49
|
super().setUp()
|
|
@@ -52,13 +55,8 @@ class ApiTestCase(unittest.TestCase):
|
|
|
52
55
|
self.old_get_download_id = ee.data.getDownloadId
|
|
53
56
|
self.old_get_thumb_id = ee.data.getThumbId
|
|
54
57
|
self.old_get_table_download_id = ee.data.getTableDownloadId
|
|
55
|
-
# pylint: disable=protected-access
|
|
56
|
-
self.old_install_cloud_api_resource = ee.data._install_cloud_api_resource
|
|
57
|
-
self.old_cloud_api_resource = ee.data._cloud_api_resource
|
|
58
|
-
self.old_cloud_api_resource_raw = ee.data._cloud_api_resource_raw
|
|
59
|
-
self.old_initialized = ee.data._initialized
|
|
58
|
+
# pylint: disable-next=protected-access
|
|
60
59
|
self.old_fetch_data_catalog_stac = ee.deprecation._FetchDataCatalogStac
|
|
61
|
-
# pylint: enable=protected-access
|
|
62
60
|
self.InitializeApi()
|
|
63
61
|
|
|
64
62
|
def tearDown(self):
|
|
@@ -69,13 +67,9 @@ class ApiTestCase(unittest.TestCase):
|
|
|
69
67
|
ee.data.getDownloadId = self.old_get_download_id
|
|
70
68
|
ee.data.getThumbId = self.old_get_thumb_id
|
|
71
69
|
ee.data.getTableDownloadId = self.old_get_table_download_id
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
ee.data._cloud_api_resource = self.old_cloud_api_resource
|
|
75
|
-
ee.data._cloud_api_resource_raw = self.old_cloud_api_resource_raw
|
|
76
|
-
ee.data._initialized = self.old_initialized
|
|
70
|
+
_state.reset_state()
|
|
71
|
+
# pylint: disable-next=protected-access
|
|
77
72
|
ee.deprecation._FetchDataCatalogStac = self.old_fetch_data_catalog_stac
|
|
78
|
-
# pylint: enable=protected-access
|
|
79
73
|
|
|
80
74
|
def InitializeApi(self):
|
|
81
75
|
"""Initializes the library with standard API methods.
|
|
@@ -102,30 +96,30 @@ class ApiTestCase(unittest.TestCase):
|
|
|
102
96
|
ee.Initialize(None, '', project='my-project')
|
|
103
97
|
|
|
104
98
|
# We are mocking the url here so the unit tests are happy.
|
|
105
|
-
def _MockMapId(self, params:
|
|
99
|
+
def _MockMapId(self, params: dict[str, Any]) -> dict[str, str]:
|
|
106
100
|
self.last_mapid_call = {'url': '/mapid', 'data': params}
|
|
107
101
|
return {'mapid': 'fakeMapId', 'token': 'fakeToken'}
|
|
108
102
|
|
|
109
|
-
def _MockDownloadUrl(self, params:
|
|
103
|
+
def _MockDownloadUrl(self, params: dict[str, Any]) -> dict[str, str]:
|
|
110
104
|
self.last_download_call = {'url': '/download', 'data': params}
|
|
111
105
|
return {'docid': '1', 'token': '2'}
|
|
112
106
|
|
|
113
107
|
def _MockThumbUrl(
|
|
114
108
|
self,
|
|
115
|
-
params:
|
|
109
|
+
params: dict[str, Any],
|
|
116
110
|
# pylint: disable-next=invalid-name
|
|
117
|
-
thumbType:
|
|
118
|
-
) ->
|
|
111
|
+
thumbType: str | None = None,
|
|
112
|
+
) -> dict[str, str]:
|
|
119
113
|
del thumbType # Unused.
|
|
120
114
|
# Hang on to the call arguments.
|
|
121
115
|
self.last_thumb_call = {'url': '/thumb', 'data': params}
|
|
122
116
|
return {'thumbid': '3', 'token': '4'}
|
|
123
117
|
|
|
124
|
-
def _MockTableDownload(self, params:
|
|
118
|
+
def _MockTableDownload(self, params: dict[str, Any]) -> dict[str, str]:
|
|
125
119
|
self.last_table_call = {'url': '/table', 'data': params}
|
|
126
120
|
return {'docid': '5', 'token': '6'}
|
|
127
121
|
|
|
128
|
-
def _MockFetchDataCatalogStac(self) ->
|
|
122
|
+
def _MockFetchDataCatalogStac(self) -> dict[str, Any]:
|
|
129
123
|
return {}
|
|
130
124
|
|
|
131
125
|
|
|
@@ -147,27 +141,28 @@ def _GenerateCloudApiResource(mock_http: Any, raw: Any) -> discovery.Resource:
|
|
|
147
141
|
|
|
148
142
|
@contextlib.contextmanager # pytype: disable=wrong-arg-types
|
|
149
143
|
def UsingCloudApi(
|
|
150
|
-
cloud_api_resource:
|
|
151
|
-
cloud_api_resource_raw:
|
|
152
|
-
mock_http:
|
|
144
|
+
cloud_api_resource: Any | None = None,
|
|
145
|
+
cloud_api_resource_raw: Any | None = None,
|
|
146
|
+
mock_http: Any | None = None,
|
|
153
147
|
) -> Iterable[Any]: # pytype: disable=wrong-arg-types
|
|
154
148
|
"""Returns a context manager under which the Cloud API is enabled."""
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
# pylint: disable=protected-access
|
|
150
|
+
old_state = copy.copy(_state._state)
|
|
151
|
+
# pylint: enable=protected-access
|
|
158
152
|
try:
|
|
159
153
|
if cloud_api_resource is None:
|
|
160
154
|
cloud_api_resource = _GenerateCloudApiResource(mock_http, False)
|
|
161
155
|
if cloud_api_resource_raw is None:
|
|
162
156
|
cloud_api_resource_raw = _GenerateCloudApiResource(mock_http, True)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
state = _state.get_state()
|
|
158
|
+
state.cloud_api_resource = cloud_api_resource
|
|
159
|
+
state.cloud_api_resource_raw = cloud_api_resource_raw
|
|
160
|
+
state.initialized = True
|
|
166
161
|
yield
|
|
167
162
|
finally:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
# pylint: disable=protected-access
|
|
164
|
+
_state._state = old_state
|
|
165
|
+
# pylint: enable=protected-access
|
|
171
166
|
|
|
172
167
|
|
|
173
168
|
# A sample of encoded EE API JSON, used by SerializerTest and DeserializerTest.
|