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.

Files changed (102) hide show
  1. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/METADATA +3 -3
  2. earthengine_api-1.7.4.dist-info/RECORD +109 -0
  3. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/WHEEL +1 -1
  4. ee/__init__.py +29 -28
  5. ee/_arg_types.py +7 -6
  6. ee/_cloud_api_utils.py +95 -78
  7. ee/_helpers.py +17 -13
  8. ee/_state.py +105 -0
  9. ee/_utils.py +2 -1
  10. ee/apifunction.py +21 -19
  11. ee/apitestcase.py +33 -38
  12. ee/batch.py +87 -77
  13. ee/blob.py +10 -12
  14. ee/classifier.py +57 -59
  15. ee/cli/commands.py +178 -114
  16. ee/cli/eecli.py +1 -1
  17. ee/cli/utils.py +61 -42
  18. ee/clusterer.py +39 -41
  19. ee/collection.py +64 -54
  20. ee/computedobject.py +19 -16
  21. ee/confusionmatrix.py +9 -9
  22. ee/customfunction.py +13 -12
  23. ee/data.py +220 -322
  24. ee/daterange.py +10 -10
  25. ee/deprecation.py +21 -13
  26. ee/deserializer.py +25 -20
  27. ee/dictionary.py +11 -11
  28. ee/ee_array.py +22 -20
  29. ee/ee_date.py +23 -23
  30. ee/ee_list.py +15 -16
  31. ee/ee_number.py +11 -21
  32. ee/ee_string.py +24 -32
  33. ee/ee_types.py +4 -4
  34. ee/element.py +15 -15
  35. ee/encodable.py +7 -4
  36. ee/errormargin.py +4 -4
  37. ee/feature.py +68 -71
  38. ee/featurecollection.py +41 -40
  39. ee/filter.py +90 -92
  40. ee/function.py +8 -8
  41. ee/geometry.py +95 -93
  42. ee/image.py +238 -236
  43. ee/image_converter.py +4 -4
  44. ee/imagecollection.py +30 -27
  45. ee/join.py +13 -15
  46. ee/kernel.py +55 -57
  47. ee/mapclient.py +9 -9
  48. ee/model.py +29 -31
  49. ee/oauth.py +76 -63
  50. ee/pixeltype.py +6 -6
  51. ee/projection.py +5 -4
  52. ee/reducer.py +41 -41
  53. ee/serializer.py +14 -14
  54. ee/table_converter.py +7 -6
  55. ee/terrain.py +7 -9
  56. ee/tests/_cloud_api_utils_test.py +21 -6
  57. ee/tests/_helpers_test.py +57 -4
  58. ee/tests/_state_test.py +49 -0
  59. ee/tests/algorithms.json +85 -2
  60. ee/tests/apifunction_test.py +5 -5
  61. ee/tests/batch_test.py +135 -57
  62. ee/tests/blob_test.py +5 -5
  63. ee/tests/classifier_test.py +3 -3
  64. ee/tests/clusterer_test.py +3 -3
  65. ee/tests/collection_test.py +48 -13
  66. ee/tests/confusionmatrix_test.py +3 -3
  67. ee/tests/data_test.py +484 -55
  68. ee/tests/daterange_test.py +4 -4
  69. ee/tests/deprecation_test.py +6 -4
  70. ee/tests/deserializer_test.py +64 -5
  71. ee/tests/dictionary_test.py +12 -12
  72. ee/tests/ee_array_test.py +3 -3
  73. ee/tests/ee_date_test.py +4 -4
  74. ee/tests/ee_list_test.py +3 -3
  75. ee/tests/ee_number_test.py +75 -30
  76. ee/tests/ee_string_test.py +11 -3
  77. ee/tests/ee_test.py +40 -22
  78. ee/tests/element_test.py +2 -2
  79. ee/tests/errormargin_test.py +1 -1
  80. ee/tests/feature_test.py +10 -10
  81. ee/tests/featurecollection_test.py +3 -3
  82. ee/tests/filter_test.py +4 -4
  83. ee/tests/function_test.py +5 -5
  84. ee/tests/geometry_point_test.py +3 -3
  85. ee/tests/geometry_test.py +93 -52
  86. ee/tests/image_converter_test.py +1 -3
  87. ee/tests/image_test.py +3 -3
  88. ee/tests/imagecollection_test.py +3 -3
  89. ee/tests/join_test.py +3 -3
  90. ee/tests/kernel_test.py +7 -3
  91. ee/tests/model_test.py +17 -5
  92. ee/tests/oauth_test.py +189 -7
  93. ee/tests/pixeltype_test.py +6 -7
  94. ee/tests/projection_test.py +5 -6
  95. ee/tests/reducer_test.py +16 -3
  96. ee/tests/serializer_test.py +39 -12
  97. ee/tests/table_converter_test.py +51 -7
  98. ee/tests/terrain_test.py +11 -3
  99. earthengine_api-1.5.13rc0.dist-info/RECORD +0 -107
  100. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/entry_points.txt +0 -0
  101. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/licenses/LICENSE +0 -0
  102. {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. Each item in the dictionary identifies
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, Dict, Optional, Set, Type
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: Dict[str, Any]
34
+ _signature: dict[str, Any]
35
35
 
36
36
  # A dictionary of functions defined by the API server.
37
- _api: Dict[str, ApiFunction] = {}
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: Set[str] = set()
41
+ _bound_signatures: set[str] = set()
42
42
 
43
43
  @_utils.accept_opt_prefix('opt_signature')
44
- def __init__(self, name: str, signature: Optional[Dict[str, Any]] = None):
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
- # For Python 3, __hash__ is needed because __eq__ is defined.
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: Dict[str, Any]) -> Any:
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) -> Dict[str, 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) -> Dict[str, Any]:
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) -> Dict[str, Dict[str, Any]]:
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 dict([(name, func.getSignature())
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) -> Dict[str, Any]:
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 dict([(name, func) for name, func in cls._api.items()
124
- if name not in cls._bound_signatures])
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) -> Optional[ApiFunction]:
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: Optional[str] = None,
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: Type[Any]) -> None:
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, Dict, Iterable, Optional
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: Optional[Dict[str, Any]] = None
19
+ _algorithms_cache: dict[str, Any] | None = None
17
20
 
18
21
 
19
- def GetAlgorithms() -> Dict[str, Any]:
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: Optional[Any]
41
- last_thumb_call: Optional[Any]
42
- last_table_call: Optional[Any]
43
- last_mapid_call: Optional[Any]
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
- # pylint: disable=protected-access
73
- ee.data._install_cloud_api_resource = self.old_install_cloud_api_resource
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: Dict[str, Any]) -> Dict[str, str]:
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: Dict[str, Any]) -> Dict[str, str]:
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: Dict[str, Any],
109
+ params: dict[str, Any],
116
110
  # pylint: disable-next=invalid-name
117
- thumbType: Optional[str] = None,
118
- ) -> Dict[str, str]:
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: Dict[str, Any]) -> Dict[str, str]:
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) -> Dict[str, Any]:
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: Optional[Any] = None,
151
- cloud_api_resource_raw: Optional[Any] = None,
152
- mock_http: Optional[Any] = None,
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
- old_cloud_api_resource = ee.data._cloud_api_resource # pylint: disable=protected-access
156
- old_cloud_api_resource_raw = ee.data._cloud_api_resource_raw # pylint: disable=protected-access
157
- old_initialized = ee.data._initialized # pylint: disable=protected-access
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
- ee.data._cloud_api_resource = cloud_api_resource # pylint: disable=protected-access
164
- ee.data._cloud_api_resource_raw = cloud_api_resource_raw # pylint: disable=protected-access
165
- ee.data._initialized = True # pylint: disable=protected-access
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
- ee.data._cloud_api_resource = old_cloud_api_resource # pylint: disable=protected-access
169
- ee.data._cloud_api_resource_raw = old_cloud_api_resource_raw # pylint: disable=protected-access
170
- ee.data._initialized = old_initialized # pylint: disable=protected-access
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.