earthengine-api 1.5.23__py3-none-any.whl → 1.5.24__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.23.dist-info → earthengine_api-1.5.24.dist-info}/METADATA +1 -1
- earthengine_api-1.5.24.dist-info/RECORD +107 -0
- ee/__init__.py +3 -3
- ee/_arg_types.py +6 -6
- ee/_cloud_api_utils.py +35 -35
- ee/_helpers.py +2 -2
- ee/apifunction.py +10 -10
- ee/apitestcase.py +9 -9
- ee/batch.py +39 -39
- ee/blob.py +2 -2
- ee/cli/commands.py +15 -15
- ee/cli/utils.py +5 -5
- ee/collection.py +3 -3
- ee/computedobject.py +6 -6
- ee/confusionmatrix.py +2 -2
- ee/customfunction.py +8 -8
- ee/data.py +55 -55
- ee/daterange.py +2 -2
- ee/deprecation.py +4 -4
- ee/dictionary.py +2 -2
- ee/ee_array.py +2 -2
- ee/ee_date.py +2 -2
- ee/ee_list.py +2 -3
- ee/element.py +3 -3
- ee/errormargin.py +2 -2
- ee/feature.py +5 -5
- ee/featurecollection.py +5 -5
- ee/function.py +5 -5
- ee/geometry.py +10 -10
- ee/image.py +19 -19
- ee/image_converter.py +2 -2
- ee/imagecollection.py +7 -7
- ee/oauth.py +4 -4
- ee/pixeltype.py +2 -2
- ee/projection.py +2 -2
- ee/serializer.py +5 -5
- ee/table_converter.py +4 -4
- ee/tests/blob_test.py +3 -3
- ee/tests/classifier_test.py +3 -3
- ee/tests/clusterer_test.py +3 -3
- ee/tests/confusionmatrix_test.py +3 -3
- ee/tests/daterange_test.py +4 -4
- ee/tests/deprecation_test.py +2 -2
- ee/tests/dictionary_test.py +3 -3
- 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 +3 -3
- ee/tests/ee_string_test.py +3 -3
- ee/tests/feature_test.py +4 -4
- ee/tests/featurecollection_test.py +3 -3
- ee/tests/filter_test.py +4 -4
- ee/tests/geometry_point_test.py +3 -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 +3 -3
- ee/tests/model_test.py +5 -5
- ee/tests/pixeltype_test.py +5 -5
- ee/tests/projection_test.py +3 -3
- ee/tests/reducer_test.py +3 -3
- ee/tests/serializer_test.py +4 -4
- ee/tests/table_converter_test.py +3 -3
- ee/tests/terrain_test.py +3 -3
- earthengine_api-1.5.23.dist-info/RECORD +0 -107
- {earthengine_api-1.5.23.dist-info → earthengine_api-1.5.24.dist-info}/WHEEL +0 -0
- {earthengine_api-1.5.23.dist-info → earthengine_api-1.5.24.dist-info}/entry_points.txt +0 -0
- {earthengine_api-1.5.23.dist-info → earthengine_api-1.5.24.dist-info}/licenses/LICENSE +0 -0
- {earthengine_api-1.5.23.dist-info → earthengine_api-1.5.24.dist-info}/top_level.txt +0 -0
ee/batch.py
CHANGED
|
@@ -12,7 +12,7 @@ from __future__ import annotations
|
|
|
12
12
|
import enum
|
|
13
13
|
import json
|
|
14
14
|
import re
|
|
15
|
-
from typing import Any,
|
|
15
|
+
from typing import Any, Optional, Sequence, Union
|
|
16
16
|
|
|
17
17
|
from ee import _cloud_api_utils
|
|
18
18
|
from ee import data
|
|
@@ -20,7 +20,7 @@ from ee import ee_exception
|
|
|
20
20
|
from ee import geometry
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def _transform_operation_to_task(operation:
|
|
23
|
+
def _transform_operation_to_task(operation: dict[str, Any]) -> Task:
|
|
24
24
|
"""Converts an operation to a task."""
|
|
25
25
|
status = _cloud_api_utils.convert_operation_to_task(operation)
|
|
26
26
|
return Task(
|
|
@@ -74,7 +74,7 @@ class Task:
|
|
|
74
74
|
FEATURE_VIEW = 'FEATURE_VIEW'
|
|
75
75
|
BIGQUERY = 'BIGQUERY'
|
|
76
76
|
|
|
77
|
-
config: Optional[
|
|
77
|
+
config: Optional[dict[str, Any]]
|
|
78
78
|
id: Optional[str]
|
|
79
79
|
name: Optional[str]
|
|
80
80
|
state: State
|
|
@@ -88,7 +88,7 @@ class Task:
|
|
|
88
88
|
task_id: Optional[str],
|
|
89
89
|
task_type: Type,
|
|
90
90
|
state: State,
|
|
91
|
-
config: Optional[
|
|
91
|
+
config: Optional[dict[str, Any]] = None,
|
|
92
92
|
name: Optional[str] = None,
|
|
93
93
|
):
|
|
94
94
|
"""Creates a Task with the given ID and configuration.
|
|
@@ -159,7 +159,7 @@ class Task:
|
|
|
159
159
|
result['name'])
|
|
160
160
|
self.name = result['name']
|
|
161
161
|
|
|
162
|
-
def status(self) ->
|
|
162
|
+
def status(self) -> dict[str, Any]:
|
|
163
163
|
"""Fetches the current status of the task.
|
|
164
164
|
|
|
165
165
|
Returns:
|
|
@@ -190,7 +190,7 @@ class Task:
|
|
|
190
190
|
data.cancelOperation(self.operation_name)
|
|
191
191
|
|
|
192
192
|
@staticmethod
|
|
193
|
-
def list() ->
|
|
193
|
+
def list() -> list[Task]:
|
|
194
194
|
"""Returns the tasks submitted to EE by the current user.
|
|
195
195
|
|
|
196
196
|
These include all currently running tasks as well as recently canceled or
|
|
@@ -231,7 +231,7 @@ class Export:
|
|
|
231
231
|
cls,
|
|
232
232
|
image: Any,
|
|
233
233
|
description: str = 'myExportImageTask',
|
|
234
|
-
config: Optional[
|
|
234
|
+
config: Optional[dict[str, Any]] = None,
|
|
235
235
|
):
|
|
236
236
|
"""Creates a task to export an EE Image to Google Drive or Cloud Storage.
|
|
237
237
|
|
|
@@ -1152,8 +1152,8 @@ NON_FILE_DESTINATIONS = frozenset([
|
|
|
1152
1152
|
|
|
1153
1153
|
|
|
1154
1154
|
def _prepare_image_export_config(
|
|
1155
|
-
image: Any, config:
|
|
1156
|
-
) ->
|
|
1155
|
+
image: Any, config: dict[str, Any], export_destination: str
|
|
1156
|
+
) -> dict[str, Any]:
|
|
1157
1157
|
"""Performs all preparation steps for an image export.
|
|
1158
1158
|
|
|
1159
1159
|
Args:
|
|
@@ -1238,8 +1238,8 @@ def _prepare_image_export_config(
|
|
|
1238
1238
|
|
|
1239
1239
|
|
|
1240
1240
|
def _prepare_map_export_config(
|
|
1241
|
-
image: Any, config:
|
|
1242
|
-
) ->
|
|
1241
|
+
image: Any, config: dict[str, Any]
|
|
1242
|
+
) -> dict[str, Any]:
|
|
1243
1243
|
"""Performs all preparation steps for a map export.
|
|
1244
1244
|
|
|
1245
1245
|
Args:
|
|
@@ -1285,8 +1285,8 @@ def _prepare_map_export_config(
|
|
|
1285
1285
|
|
|
1286
1286
|
|
|
1287
1287
|
def _prepare_table_export_config(
|
|
1288
|
-
collection: Any, config:
|
|
1289
|
-
) ->
|
|
1288
|
+
collection: Any, config: dict[str, Any], export_destination
|
|
1289
|
+
) -> dict[str, Any]:
|
|
1290
1290
|
"""Performs all preparation steps for a table export.
|
|
1291
1291
|
|
|
1292
1292
|
Args:
|
|
@@ -1357,8 +1357,8 @@ def _prepare_table_export_config(
|
|
|
1357
1357
|
|
|
1358
1358
|
|
|
1359
1359
|
def _prepare_video_export_config(
|
|
1360
|
-
collection: Any, config:
|
|
1361
|
-
) ->
|
|
1360
|
+
collection: Any, config: dict[str, Any], export_destination: str
|
|
1361
|
+
) -> dict[str, Any]:
|
|
1362
1362
|
"""Performs all preparation steps for a video export.
|
|
1363
1363
|
|
|
1364
1364
|
Args:
|
|
@@ -1400,8 +1400,8 @@ def _prepare_video_export_config(
|
|
|
1400
1400
|
|
|
1401
1401
|
|
|
1402
1402
|
def _build_image_file_export_options(
|
|
1403
|
-
config:
|
|
1404
|
-
) ->
|
|
1403
|
+
config: dict[str, Any], export_destination: str
|
|
1404
|
+
) -> dict[str, Any]:
|
|
1405
1405
|
"""Builds an ImageFileExportOptions from values in a config dict.
|
|
1406
1406
|
|
|
1407
1407
|
Args:
|
|
@@ -1505,8 +1505,8 @@ def _build_image_file_export_options(
|
|
|
1505
1505
|
|
|
1506
1506
|
|
|
1507
1507
|
def _build_table_file_export_options(
|
|
1508
|
-
config:
|
|
1509
|
-
) ->
|
|
1508
|
+
config: dict[str, Any], export_destination: str
|
|
1509
|
+
) -> dict[str, Any]:
|
|
1510
1510
|
"""Builds a TableFileExportOptions from values in a config dict.
|
|
1511
1511
|
|
|
1512
1512
|
Args:
|
|
@@ -1535,7 +1535,7 @@ def _build_table_file_export_options(
|
|
|
1535
1535
|
return file_export_options
|
|
1536
1536
|
|
|
1537
1537
|
|
|
1538
|
-
def _build_video_options(config:
|
|
1538
|
+
def _build_video_options(config: dict[str, Any]) -> dict[str, Any]:
|
|
1539
1539
|
"""Builds a VideoOptions from values in a config dict.
|
|
1540
1540
|
|
|
1541
1541
|
Args:
|
|
@@ -1558,8 +1558,8 @@ def _build_video_options(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1558
1558
|
|
|
1559
1559
|
|
|
1560
1560
|
def _build_video_file_export_options(
|
|
1561
|
-
config:
|
|
1562
|
-
) ->
|
|
1561
|
+
config: dict[str, Any], export_destination: str
|
|
1562
|
+
) -> dict[str, Any]:
|
|
1563
1563
|
"""Builds a VideoFileExportOptions from values in a config dict.
|
|
1564
1564
|
|
|
1565
1565
|
Args:
|
|
@@ -1589,8 +1589,8 @@ def _build_video_file_export_options(
|
|
|
1589
1589
|
|
|
1590
1590
|
|
|
1591
1591
|
def _prepare_classifier_export_config(
|
|
1592
|
-
classifier: Any, config:
|
|
1593
|
-
) ->
|
|
1592
|
+
classifier: Any, config: dict[str, Any], export_destination: str
|
|
1593
|
+
) -> dict[str, Any]:
|
|
1594
1594
|
"""Performs all preparation steps for a classifier export.
|
|
1595
1595
|
|
|
1596
1596
|
Args:
|
|
@@ -1620,7 +1620,7 @@ def _prepare_classifier_export_config(
|
|
|
1620
1620
|
return request
|
|
1621
1621
|
|
|
1622
1622
|
|
|
1623
|
-
def _build_drive_destination(config:
|
|
1623
|
+
def _build_drive_destination(config: dict[str, Any]) -> dict[str, Any]:
|
|
1624
1624
|
"""Builds a DriveDestination from values in a config dict.
|
|
1625
1625
|
|
|
1626
1626
|
Args:
|
|
@@ -1639,7 +1639,7 @@ def _build_drive_destination(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1639
1639
|
return drive_destination
|
|
1640
1640
|
|
|
1641
1641
|
|
|
1642
|
-
def _build_cloud_storage_destination(config:
|
|
1642
|
+
def _build_cloud_storage_destination(config: dict[str, Any]) -> dict[str, Any]:
|
|
1643
1643
|
"""Builds a CloudStorageDestination from values in a config dict.
|
|
1644
1644
|
|
|
1645
1645
|
Args:
|
|
@@ -1660,7 +1660,7 @@ def _build_cloud_storage_destination(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1660
1660
|
return destination
|
|
1661
1661
|
|
|
1662
1662
|
|
|
1663
|
-
def _build_bigquery_destination(config:
|
|
1663
|
+
def _build_bigquery_destination(config: dict[str, Any]) -> dict[str, Any]:
|
|
1664
1664
|
"""Builds a BigqueryDestination from values in a config dict.
|
|
1665
1665
|
|
|
1666
1666
|
Args:
|
|
@@ -1679,7 +1679,7 @@ def _build_bigquery_destination(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1679
1679
|
return destination
|
|
1680
1680
|
|
|
1681
1681
|
|
|
1682
|
-
def _build_tile_options(config:
|
|
1682
|
+
def _build_tile_options(config: dict[str, Any]) -> dict[str, Any]:
|
|
1683
1683
|
"""Builds a TileOptions from values in a config dict.
|
|
1684
1684
|
|
|
1685
1685
|
Args:
|
|
@@ -1722,7 +1722,7 @@ def _build_tile_options(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1722
1722
|
return tile_options
|
|
1723
1723
|
|
|
1724
1724
|
|
|
1725
|
-
def _build_earth_engine_destination(config:
|
|
1725
|
+
def _build_earth_engine_destination(config: dict[str, Any]) -> dict[str, Any]:
|
|
1726
1726
|
"""Builds an EarthEngineDestination from values in a config dict.
|
|
1727
1727
|
|
|
1728
1728
|
Args:
|
|
@@ -1740,7 +1740,7 @@ def _build_earth_engine_destination(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1740
1740
|
}
|
|
1741
1741
|
|
|
1742
1742
|
|
|
1743
|
-
def _build_feature_view_destination(config:
|
|
1743
|
+
def _build_feature_view_destination(config: dict[str, Any]) -> dict[str, Any]:
|
|
1744
1744
|
"""Builds a FeatureViewDestination from values in a config dict.
|
|
1745
1745
|
|
|
1746
1746
|
Args:
|
|
@@ -1758,7 +1758,7 @@ def _build_feature_view_destination(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
1758
1758
|
return feature_view_destination
|
|
1759
1759
|
|
|
1760
1760
|
|
|
1761
|
-
def _get_rank_by_one_thing_rule(rule_str: str) ->
|
|
1761
|
+
def _get_rank_by_one_thing_rule(rule_str: str) -> dict[str, Any]:
|
|
1762
1762
|
"""Returns a RankByOneThingRule dict created from the rank-by-one-thing rule.
|
|
1763
1763
|
|
|
1764
1764
|
Args:
|
|
@@ -1796,8 +1796,8 @@ def _get_rank_by_one_thing_rule(rule_str: str) -> Dict[str, Any]:
|
|
|
1796
1796
|
|
|
1797
1797
|
|
|
1798
1798
|
def _get_ranking_rule(
|
|
1799
|
-
rules: Optional[Union[str,
|
|
1800
|
-
) -> Optional[
|
|
1799
|
+
rules: Optional[Union[str, list[str]]]
|
|
1800
|
+
) -> Optional[dict[str, list[dict[str, Any]]]]:
|
|
1801
1801
|
"""Returns a RankingRule dict created from the rank-by-one-thing rules.
|
|
1802
1802
|
|
|
1803
1803
|
Args:
|
|
@@ -1823,7 +1823,7 @@ def _get_ranking_rule(
|
|
|
1823
1823
|
'either be a comma-separated string or list of strings.'))
|
|
1824
1824
|
|
|
1825
1825
|
|
|
1826
|
-
def _build_thinning_options(config:
|
|
1826
|
+
def _build_thinning_options(config: dict[str, Any]) -> Optional[dict[str, Any]]:
|
|
1827
1827
|
"""Returns a ThinningOptions dict created from the config.
|
|
1828
1828
|
|
|
1829
1829
|
Args:
|
|
@@ -1843,7 +1843,7 @@ def _build_thinning_options(config: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
|
|
1843
1843
|
return output
|
|
1844
1844
|
|
|
1845
1845
|
|
|
1846
|
-
def _build_ranking_options(config:
|
|
1846
|
+
def _build_ranking_options(config: dict[str, Any]) -> Optional[dict[str, Any]]:
|
|
1847
1847
|
"""Returns a RankingOptions dict created from the config.
|
|
1848
1848
|
|
|
1849
1849
|
Args:
|
|
@@ -1869,8 +1869,8 @@ def _build_ranking_options(config: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
|
|
1869
1869
|
|
|
1870
1870
|
|
|
1871
1871
|
def build_ingestion_time_parameters(
|
|
1872
|
-
input_params:
|
|
1873
|
-
) ->
|
|
1872
|
+
input_params: dict[str, Any]
|
|
1873
|
+
) -> dict[str, Any]:
|
|
1874
1874
|
"""Builds a FeatureViewIngestionTimeParameters from values in a params dict.
|
|
1875
1875
|
|
|
1876
1876
|
Args:
|
|
@@ -1898,7 +1898,7 @@ def build_ingestion_time_parameters(
|
|
|
1898
1898
|
return output_params
|
|
1899
1899
|
|
|
1900
1900
|
|
|
1901
|
-
def _create_export_task(config:
|
|
1901
|
+
def _create_export_task(config: dict[str, Any], task_type: Task.Type) -> Task:
|
|
1902
1902
|
"""Creates an export task.
|
|
1903
1903
|
|
|
1904
1904
|
Args:
|
|
@@ -1913,7 +1913,7 @@ def _create_export_task(config: Dict[str, Any], task_type: Task.Type) -> Task:
|
|
|
1913
1913
|
|
|
1914
1914
|
def _capture_parameters(
|
|
1915
1915
|
all_locals, parameters_to_exclude: Sequence[str]
|
|
1916
|
-
) ->
|
|
1916
|
+
) -> dict[str, Any]:
|
|
1917
1917
|
"""Creates a parameter dict by copying all non-None locals.
|
|
1918
1918
|
|
|
1919
1919
|
This is generally invoked as the first part of call processing, via
|
ee/blob.py
CHANGED
|
@@ -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, Optional
|
|
5
5
|
|
|
6
6
|
from ee import _arg_types
|
|
7
7
|
from ee import apifunction
|
|
@@ -46,7 +46,7 @@ class Blob(computedobject.ComputedObject):
|
|
|
46
46
|
"""
|
|
47
47
|
self.initialize()
|
|
48
48
|
|
|
49
|
-
args:
|
|
49
|
+
args: dict[str, Any] = {'url': url}
|
|
50
50
|
func = apifunction.ApiFunction(self.name())
|
|
51
51
|
|
|
52
52
|
if isinstance(url, str):
|
ee/cli/commands.py
CHANGED
|
@@ -16,7 +16,7 @@ import re
|
|
|
16
16
|
import shutil
|
|
17
17
|
import sys
|
|
18
18
|
import tempfile
|
|
19
|
-
from typing import Any,
|
|
19
|
+
from typing import Any, Sequence, Type, Union
|
|
20
20
|
import urllib.parse
|
|
21
21
|
|
|
22
22
|
# Prevent TensorFlow from logging anything at the native level.
|
|
@@ -129,7 +129,7 @@ def _add_overwrite_arg(parser: argparse.ArgumentParser) -> None:
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
def _upload(
|
|
132
|
-
args: argparse.Namespace, request:
|
|
132
|
+
args: argparse.Namespace, request: dict[str, Any], ingestion_function: Any
|
|
133
133
|
) -> None:
|
|
134
134
|
if 0 <= args.wait < 10:
|
|
135
135
|
raise ee.EEException('Wait time should be at least 10 seconds.')
|
|
@@ -142,7 +142,7 @@ def _upload(
|
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
# Argument types
|
|
145
|
-
def _comma_separated_strings(string: str) ->
|
|
145
|
+
def _comma_separated_strings(string: str) -> list[str]:
|
|
146
146
|
"""Parses an input consisting of comma-separated strings."""
|
|
147
147
|
error_msg = 'Argument should be a comma-separated list of strings: {}'
|
|
148
148
|
values = string.split(',')
|
|
@@ -151,7 +151,7 @@ def _comma_separated_strings(string: str) -> List[str]:
|
|
|
151
151
|
return values
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
def _comma_separated_numbers(string: str) ->
|
|
154
|
+
def _comma_separated_numbers(string: str) -> list[float]:
|
|
155
155
|
"""Parses an input consisting of comma-separated numbers."""
|
|
156
156
|
error_msg = 'Argument should be a comma-separated list of numbers: {}'
|
|
157
157
|
values = string.split(',')
|
|
@@ -170,7 +170,7 @@ def _comma_separated_numbers(string: str) -> List[float]:
|
|
|
170
170
|
return numbervalues
|
|
171
171
|
|
|
172
172
|
|
|
173
|
-
def _comma_separated_pyramiding_policies(string: str) ->
|
|
173
|
+
def _comma_separated_pyramiding_policies(string: str) -> list[str]:
|
|
174
174
|
"""Parses an input consisting of comma-separated pyramiding policies."""
|
|
175
175
|
error_msg = ('Argument should be a comma-separated list of: '
|
|
176
176
|
'{{"mean", "sample", "min", "max", "mode"}}: {}')
|
|
@@ -248,7 +248,7 @@ def _decode_date(string: str) -> Union[float, str]:
|
|
|
248
248
|
'Invalid value for property of type "date": "%s".' % string)
|
|
249
249
|
|
|
250
250
|
|
|
251
|
-
def _decode_property(string: str) ->
|
|
251
|
+
def _decode_property(string: str) -> tuple[str, Any]:
|
|
252
252
|
"""Decodes a general key-value property from a command-line argument.
|
|
253
253
|
|
|
254
254
|
Args:
|
|
@@ -311,7 +311,7 @@ def _add_property_flags(parser: argparse.ArgumentParser) -> None:
|
|
|
311
311
|
type=_decode_date)
|
|
312
312
|
|
|
313
313
|
|
|
314
|
-
def _decode_property_flags(args: argparse.Namespace) ->
|
|
314
|
+
def _decode_property_flags(args: argparse.Namespace) -> dict[str, Any]:
|
|
315
315
|
"""Decodes metadata properties from args as a name->value dict."""
|
|
316
316
|
property_list = list(args.property or [])
|
|
317
317
|
names = [name for name, _ in property_list]
|
|
@@ -336,8 +336,8 @@ def _pretty_print_json(json_obj: Any) -> None:
|
|
|
336
336
|
|
|
337
337
|
class Dispatcher:
|
|
338
338
|
"""Dispatches to a set of commands implemented as command classes."""
|
|
339
|
-
COMMANDS:
|
|
340
|
-
command_dict:
|
|
339
|
+
COMMANDS: list[Any]
|
|
340
|
+
command_dict: dict[str, Any]
|
|
341
341
|
dest: str
|
|
342
342
|
name: str
|
|
343
343
|
|
|
@@ -509,7 +509,7 @@ class AclChCommand:
|
|
|
509
509
|
ee.data.setAssetAcl(args.asset_id, json.dumps(acl))
|
|
510
510
|
|
|
511
511
|
def _set_permission(
|
|
512
|
-
self, permissions:
|
|
512
|
+
self, permissions: dict[str, str], grant: str, prefix: str
|
|
513
513
|
) -> None:
|
|
514
514
|
"""Sets the permission for a given user/group."""
|
|
515
515
|
parts = grant.rsplit(':', 1)
|
|
@@ -526,7 +526,7 @@ class AclChCommand:
|
|
|
526
526
|
permissions[prefixed_user] = role
|
|
527
527
|
|
|
528
528
|
def _remove_permission(
|
|
529
|
-
self, permissions:
|
|
529
|
+
self, permissions: dict[str, str], user: str, prefix: str
|
|
530
530
|
) -> None:
|
|
531
531
|
"""Removes permissions for a given user/group."""
|
|
532
532
|
prefixed_user = user
|
|
@@ -546,7 +546,7 @@ class AclChCommand:
|
|
|
546
546
|
else:
|
|
547
547
|
return 'user:'
|
|
548
548
|
|
|
549
|
-
def _parse_permissions(self, args: argparse.Namespace) ->
|
|
549
|
+
def _parse_permissions(self, args: argparse.Namespace) -> dict[str, str]:
|
|
550
550
|
"""Decodes and sanity-checks the permissions in the arguments."""
|
|
551
551
|
# A dictionary mapping from user ids to one of 'R', 'W', or 'D'.
|
|
552
552
|
permissions = {}
|
|
@@ -566,7 +566,7 @@ class AclChCommand:
|
|
|
566
566
|
return permissions
|
|
567
567
|
|
|
568
568
|
def _apply_permissions(
|
|
569
|
-
self, acl:
|
|
569
|
+
self, acl: dict[str, Union[bool, list[str]]], permissions: dict[str, str]
|
|
570
570
|
) -> None:
|
|
571
571
|
"""Applies the given permission edits to the given acl."""
|
|
572
572
|
for user, role in permissions.items():
|
|
@@ -1375,7 +1375,7 @@ class UploadImageCommand:
|
|
|
1375
1375
|
manifest = self.manifest_from_args(args)
|
|
1376
1376
|
_upload(args, manifest, ee.data.startIngestion)
|
|
1377
1377
|
|
|
1378
|
-
def manifest_from_args(self, args: argparse.Namespace) ->
|
|
1378
|
+
def manifest_from_args(self, args: argparse.Namespace) -> dict[str, Any]:
|
|
1379
1379
|
"""Constructs an upload manifest from the command-line flags."""
|
|
1380
1380
|
|
|
1381
1381
|
def is_tf_record(path: str) -> bool:
|
|
@@ -1490,7 +1490,7 @@ class UploadExternalImageCommand:
|
|
|
1490
1490
|
name = ee.data.startExternalImageIngestion(manifest, args.force)['name']
|
|
1491
1491
|
print('Created asset %s' % name)
|
|
1492
1492
|
|
|
1493
|
-
def manifest_from_args(self, args: argparse.Namespace) ->
|
|
1493
|
+
def manifest_from_args(self, args: argparse.Namespace) -> dict[str, Any]:
|
|
1494
1494
|
"""Constructs an upload manifest from the command-line flags."""
|
|
1495
1495
|
|
|
1496
1496
|
if args.manifest:
|
ee/cli/utils.py
CHANGED
|
@@ -13,7 +13,7 @@ import re
|
|
|
13
13
|
import tempfile
|
|
14
14
|
import threading
|
|
15
15
|
import time
|
|
16
|
-
from typing import Any, AnyStr,
|
|
16
|
+
from typing import Any, AnyStr, Iterable, Optional, Union
|
|
17
17
|
import urllib.parse
|
|
18
18
|
|
|
19
19
|
from google.cloud import storage
|
|
@@ -31,7 +31,7 @@ DEFAULT_EE_CONFIG_FILE_RELATIVE = os.path.join(
|
|
|
31
31
|
DEFAULT_EE_CONFIG_FILE = os.path.join(
|
|
32
32
|
HOMEDIR, DEFAULT_EE_CONFIG_FILE_RELATIVE)
|
|
33
33
|
|
|
34
|
-
CONFIG_PARAMS:
|
|
34
|
+
CONFIG_PARAMS: dict[str, Union[str, list[str], None]] = {
|
|
35
35
|
'account': None,
|
|
36
36
|
'cloud_api_key': None,
|
|
37
37
|
'private_key': None,
|
|
@@ -39,7 +39,7 @@ CONFIG_PARAMS: Dict[str, Union[str, List[str], None]] = {
|
|
|
39
39
|
'url': 'https://earthengine.googleapis.com',
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
TASK_FINISHED_STATES:
|
|
42
|
+
TASK_FINISHED_STATES: tuple[str, str, str] = (
|
|
43
43
|
ee.batch.Task.State.COMPLETED,
|
|
44
44
|
ee.batch.Task.State.FAILED,
|
|
45
45
|
ee.batch.Task.State.CANCELLED,
|
|
@@ -278,7 +278,7 @@ def wait_for_task(
|
|
|
278
278
|
|
|
279
279
|
|
|
280
280
|
def wait_for_tasks(
|
|
281
|
-
task_id_list:
|
|
281
|
+
task_id_list: list[str], timeout: float, log_progress: bool = False
|
|
282
282
|
) -> None:
|
|
283
283
|
"""For each task specified in task_id_list, wait for that task or timeout."""
|
|
284
284
|
|
|
@@ -309,7 +309,7 @@ def wait_for_tasks(
|
|
|
309
309
|
print(' %d tasks are still incomplete (timed-out)' % num_incomplete)
|
|
310
310
|
|
|
311
311
|
|
|
312
|
-
def expand_gcs_wildcards(source_files:
|
|
312
|
+
def expand_gcs_wildcards(source_files: list[str]) -> Iterable[str]:
|
|
313
313
|
"""Implements glob-like '*' wildcard completion for cloud storage objects.
|
|
314
314
|
|
|
315
315
|
Args:
|
ee/collection.py
CHANGED
|
@@ -6,7 +6,7 @@ This class is never intended to be instantiated by the user.
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import datetime
|
|
9
|
-
from typing import Any, Callable,
|
|
9
|
+
from typing import Any, Callable, Optional, Type, Union
|
|
10
10
|
|
|
11
11
|
from ee import _arg_types
|
|
12
12
|
from ee import _utils
|
|
@@ -37,7 +37,7 @@ class Collection(element.Element):
|
|
|
37
37
|
def __init__(
|
|
38
38
|
self,
|
|
39
39
|
func: function.Function,
|
|
40
|
-
args:
|
|
40
|
+
args: dict[str, Any],
|
|
41
41
|
varName: Optional[str] = None, # pylint: disable=invalid-name
|
|
42
42
|
):
|
|
43
43
|
"""Constructs a collection by initializing its ComputedObject."""
|
|
@@ -480,7 +480,7 @@ class Collection(element.Element):
|
|
|
480
480
|
return self.filter(ee_filter.Filter.metadata_(name, operator, value))
|
|
481
481
|
|
|
482
482
|
def filterBounds(
|
|
483
|
-
self, geometry: Union[
|
|
483
|
+
self, geometry: Union[dict[str, Any], ee_geometry.Geometry]
|
|
484
484
|
) -> Any:
|
|
485
485
|
"""Shortcut to add a geometry filter to a collection.
|
|
486
486
|
|
ee/computedobject.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any, Callable,
|
|
5
|
+
from typing import Any, Callable, Optional
|
|
6
6
|
|
|
7
7
|
from ee import _utils
|
|
8
8
|
from ee import data
|
|
@@ -48,7 +48,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass):
|
|
|
48
48
|
mapping calls do not use the same variable name.
|
|
49
49
|
"""
|
|
50
50
|
func: Optional[Any]
|
|
51
|
-
args: Optional[
|
|
51
|
+
args: Optional[dict[str, Any]]
|
|
52
52
|
varName: Optional[str] # pylint: disable=g-bad-name
|
|
53
53
|
|
|
54
54
|
# Tell pytype not to worry about dynamic attributes.
|
|
@@ -61,7 +61,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass):
|
|
|
61
61
|
def __init__(
|
|
62
62
|
self,
|
|
63
63
|
func: Optional[Any],
|
|
64
|
-
args: Optional[
|
|
64
|
+
args: Optional[dict[str, Any]],
|
|
65
65
|
varName: Optional[str] = None, # pylint: disable=g-bad-name
|
|
66
66
|
):
|
|
67
67
|
"""Creates a computed object.
|
|
@@ -106,7 +106,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass):
|
|
|
106
106
|
"""
|
|
107
107
|
return data.computeValue(self)
|
|
108
108
|
|
|
109
|
-
def encode(self, encoder: Optional[Callable[..., Any]]) ->
|
|
109
|
+
def encode(self, encoder: Optional[Callable[..., Any]]) -> dict[str, Any]:
|
|
110
110
|
"""Encodes the object in a format compatible with Serializer."""
|
|
111
111
|
if self.isVariable():
|
|
112
112
|
return {
|
|
@@ -135,7 +135,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass):
|
|
|
135
135
|
key: func
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
def encode_cloud_value(self, encoder: Any) ->
|
|
138
|
+
def encode_cloud_value(self, encoder: Any) -> dict[str, Any]:
|
|
139
139
|
if self.isVariable():
|
|
140
140
|
ref = self.varName
|
|
141
141
|
if ref is None and isinstance(
|
|
@@ -160,7 +160,7 @@ class ComputedObject(encodable.Encodable, metaclass=ComputedObjectMetaclass):
|
|
|
160
160
|
invocation = self.func.encode_cloud_invocation(encoder)
|
|
161
161
|
|
|
162
162
|
# Encode all arguments recursively.
|
|
163
|
-
encoded_args:
|
|
163
|
+
encoded_args: dict[str, Any] = {}
|
|
164
164
|
for name in sorted(self.args):
|
|
165
165
|
value = self.args[name]
|
|
166
166
|
if value is not None:
|
ee/confusionmatrix.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""A wrapper for ConfusionMatrices."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
-
from typing import Any,
|
|
4
|
+
from typing import Any, Optional, Union
|
|
5
5
|
|
|
6
6
|
from ee import _arg_types
|
|
7
7
|
from ee import apifunction
|
|
@@ -57,7 +57,7 @@ class ConfusionMatrix(computedobject.ComputedObject):
|
|
|
57
57
|
super().__init__(array.func, array.args, array.varName)
|
|
58
58
|
return
|
|
59
59
|
|
|
60
|
-
args:
|
|
60
|
+
args: dict[str, Any] = {'array': array}
|
|
61
61
|
if order is not None:
|
|
62
62
|
args['order'] = order
|
|
63
63
|
|
ee/customfunction.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Any, Callable,
|
|
5
|
+
from typing import Any, Callable, Optional
|
|
6
6
|
|
|
7
7
|
from ee import computedobject
|
|
8
8
|
from ee import ee_exception
|
|
@@ -20,9 +20,9 @@ from ee import serializer
|
|
|
20
20
|
class CustomFunction(function.Function, encodable.Encodable):
|
|
21
21
|
"""An object representing a custom EE Function."""
|
|
22
22
|
_body: Any
|
|
23
|
-
_signature:
|
|
23
|
+
_signature: dict[str, Any]
|
|
24
24
|
|
|
25
|
-
def __init__(self, signature:
|
|
25
|
+
def __init__(self, signature: dict[str, Any], body: Any):
|
|
26
26
|
"""Creates a function defined by a given expression with unbound variables.
|
|
27
27
|
|
|
28
28
|
The expression is created by evaluating the given function
|
|
@@ -47,14 +47,14 @@ class CustomFunction(function.Function, encodable.Encodable):
|
|
|
47
47
|
# The expression to evaluate.
|
|
48
48
|
self._body = body(*variables)
|
|
49
49
|
|
|
50
|
-
def encode(self, encoder: Callable[[Any], Any]) ->
|
|
50
|
+
def encode(self, encoder: Callable[[Any], Any]) -> dict[str, Any]:
|
|
51
51
|
return {
|
|
52
52
|
'type': 'Function',
|
|
53
53
|
'argumentNames': [x['name'] for x in self._signature['args']],
|
|
54
54
|
'body': encoder(self._body)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
def encode_cloud_value(self, encoder: Callable[[Any], Any]) ->
|
|
57
|
+
def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> dict[str, Any]:
|
|
58
58
|
return {
|
|
59
59
|
'functionDefinitionValue': {
|
|
60
60
|
'argumentNames': [x['name'] for x in self._signature['args']],
|
|
@@ -62,15 +62,15 @@ class CustomFunction(function.Function, encodable.Encodable):
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
def encode_invocation(self, encoder: Callable[[Any], Any]) ->
|
|
65
|
+
def encode_invocation(self, encoder: Callable[[Any], Any]) -> dict[str, Any]:
|
|
66
66
|
return self.encode(encoder)
|
|
67
67
|
|
|
68
68
|
def encode_cloud_invocation(
|
|
69
69
|
self, encoder: Callable[[Any], Any]
|
|
70
|
-
) ->
|
|
70
|
+
) -> dict[str, Any]:
|
|
71
71
|
return {'functionReference': encoder(self)}
|
|
72
72
|
|
|
73
|
-
def getSignature(self) ->
|
|
73
|
+
def getSignature(self) -> dict[str, Any]:
|
|
74
74
|
"""Returns a description of the interface provided by this function."""
|
|
75
75
|
return self._signature
|
|
76
76
|
|