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/tests/batch_test.py
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
"""Test for the ee.batch module."""
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
import unittest
|
|
7
7
|
from unittest import mock
|
|
8
8
|
|
|
9
9
|
import unittest
|
|
10
10
|
import ee
|
|
11
|
+
from ee import _state
|
|
11
12
|
from ee import apitestcase
|
|
12
13
|
from ee import batch
|
|
13
14
|
from ee import data
|
|
@@ -55,15 +56,25 @@ class TaskTest(unittest.TestCase):
|
|
|
55
56
|
|
|
56
57
|
def setUp(self):
|
|
57
58
|
super().setUp()
|
|
58
|
-
|
|
59
|
+
mock.patch.object(
|
|
60
|
+
_state,
|
|
61
|
+
'get_state',
|
|
62
|
+
return_value=_state.EEState(
|
|
63
|
+
initialized=True, cloud_api_user_project='test-project'
|
|
64
|
+
),
|
|
65
|
+
).start()
|
|
66
|
+
|
|
67
|
+
def tearDown(self):
|
|
68
|
+
super().tearDown()
|
|
69
|
+
mock.patch.stopall()
|
|
59
70
|
|
|
60
|
-
def
|
|
71
|
+
def test_start_without_config(self):
|
|
61
72
|
task = batch.Task('an id', 'a task type', 'a state')
|
|
62
|
-
self.assertIsNone(
|
|
73
|
+
self.assertIsNone(task.config)
|
|
63
74
|
with self.assertRaisesRegex(ee.EEException, 'Task config'):
|
|
64
75
|
task.start()
|
|
65
76
|
|
|
66
|
-
def
|
|
77
|
+
def test_start_unknown_task_type(self):
|
|
67
78
|
task_type = 'bad task type'
|
|
68
79
|
task = batch.Task('an id', task_type, 'a state', {'some': 'value'})
|
|
69
80
|
with self.assertRaisesRegex(
|
|
@@ -71,8 +82,9 @@ class TaskTest(unittest.TestCase):
|
|
|
71
82
|
):
|
|
72
83
|
task.start()
|
|
73
84
|
|
|
74
|
-
def
|
|
75
|
-
|
|
85
|
+
def test_status_with_id(self):
|
|
86
|
+
name = 'projects/test-project/operations/test_1'
|
|
87
|
+
task = batch.Task('an id', 'a task type', 'a state', name=name)
|
|
76
88
|
with mock.patch.object(
|
|
77
89
|
data, 'getOperation', return_value=RUNNING_OPERATION
|
|
78
90
|
) as m:
|
|
@@ -81,7 +93,7 @@ class TaskTest(unittest.TestCase):
|
|
|
81
93
|
m.call_args.args[0], 'projects/test-project/operations/test_1'
|
|
82
94
|
)
|
|
83
95
|
|
|
84
|
-
def
|
|
96
|
+
def test_status_with_name(self):
|
|
85
97
|
task = batch.Task(
|
|
86
98
|
None,
|
|
87
99
|
'a task type',
|
|
@@ -96,8 +108,9 @@ class TaskTest(unittest.TestCase):
|
|
|
96
108
|
m.call_args.args[0], 'projects/test-project/operations/test_1'
|
|
97
109
|
)
|
|
98
110
|
|
|
99
|
-
def
|
|
100
|
-
|
|
111
|
+
def test_status_with_id_state_unknown(self):
|
|
112
|
+
name = 'projects/test-project/operations/an id'
|
|
113
|
+
task = batch.Task('an id', 'a task type', 'a state', name=name)
|
|
101
114
|
with mock.patch.object(
|
|
102
115
|
data, 'getOperation', return_value=UNKNOWN_OPERATION
|
|
103
116
|
) as m:
|
|
@@ -106,29 +119,38 @@ class TaskTest(unittest.TestCase):
|
|
|
106
119
|
m.call_args.args[0], 'projects/test-project/operations/an id'
|
|
107
120
|
)
|
|
108
121
|
|
|
109
|
-
def
|
|
122
|
+
def test_status_without_id_or_name(self):
|
|
110
123
|
task = batch.Task(None, 'a task type', 'a state')
|
|
111
124
|
self.assertEqual('UNSUBMITTED', task.status()['state'])
|
|
112
125
|
|
|
113
|
-
def
|
|
114
|
-
|
|
126
|
+
def test_active(self):
|
|
127
|
+
name = 'projects/test-project/operations/an id'
|
|
128
|
+
task = batch.Task('an id', 'a task type', 'a state', name=name)
|
|
115
129
|
with mock.patch.object(
|
|
116
130
|
data, 'getOperation', return_value=RUNNING_OPERATION
|
|
117
131
|
):
|
|
118
132
|
self.assertTrue(task.active())
|
|
119
133
|
|
|
120
|
-
def
|
|
134
|
+
def test_not_active(self):
|
|
121
135
|
task = batch.Task('an id', 'a task type', 'a state')
|
|
122
136
|
with mock.patch.object(
|
|
123
137
|
data, 'getOperation', return_value=SUCCEEDED_OPERATION
|
|
124
138
|
):
|
|
125
139
|
self.assertFalse(task.active())
|
|
126
140
|
|
|
127
|
-
def
|
|
141
|
+
def test_success(self):
|
|
142
|
+
self.assertTrue(batch.Task.State.success(batch.Task.State.COMPLETED))
|
|
143
|
+
self.assertTrue(batch.Task.State.success('COMPLETED'))
|
|
144
|
+
for state in batch.Task.State:
|
|
145
|
+
if state != batch.Task.State.COMPLETED:
|
|
146
|
+
self.assertFalse(batch.Task.State.success(state))
|
|
147
|
+
self.assertFalse(batch.Task.State.success(state.value))
|
|
148
|
+
|
|
149
|
+
def test_repr_without_config(self):
|
|
128
150
|
task = batch.Task('an id', 'a task type', 'a state')
|
|
129
151
|
self.assertEqual('<Task "an id">', task.__repr__())
|
|
130
152
|
|
|
131
|
-
def
|
|
153
|
+
def test_repr_with_config(self):
|
|
132
154
|
an_id = None
|
|
133
155
|
task_type = 'a task type'
|
|
134
156
|
state = 'a state'
|
|
@@ -140,7 +162,7 @@ class TaskTest(unittest.TestCase):
|
|
|
140
162
|
f'<Task {task_type}: {description} ({state})>', task.__repr__()
|
|
141
163
|
)
|
|
142
164
|
|
|
143
|
-
def
|
|
165
|
+
def test_repr_with_id_and_config(self):
|
|
144
166
|
an_id = 'an id'
|
|
145
167
|
task_type = 'a task type'
|
|
146
168
|
state = 'a state'
|
|
@@ -155,23 +177,23 @@ class TaskTest(unittest.TestCase):
|
|
|
155
177
|
|
|
156
178
|
class ExportTest(unittest.TestCase):
|
|
157
179
|
|
|
158
|
-
def
|
|
180
|
+
def test_export_cannot_init(self):
|
|
159
181
|
with self.assertRaises(AssertionError):
|
|
160
182
|
batch.Export()
|
|
161
183
|
|
|
162
|
-
def
|
|
184
|
+
def test_export_image_cannot_init(self):
|
|
163
185
|
with self.assertRaises(AssertionError):
|
|
164
186
|
batch.Export.image.__init__('something')
|
|
165
187
|
|
|
166
|
-
def
|
|
188
|
+
def test_export_map_cannot_init(self):
|
|
167
189
|
with self.assertRaises(AssertionError):
|
|
168
190
|
batch.Export.map.__init__('something')
|
|
169
191
|
|
|
170
|
-
def
|
|
192
|
+
def test_export_table_cannot_init(self):
|
|
171
193
|
with self.assertRaises(AssertionError):
|
|
172
194
|
batch.Export.table.__init__('something')
|
|
173
195
|
|
|
174
|
-
def
|
|
196
|
+
def test_export_video_cannot_init(self):
|
|
175
197
|
with self.assertRaises(AssertionError):
|
|
176
198
|
batch.Export.video.__init__('something')
|
|
177
199
|
|
|
@@ -179,8 +201,8 @@ class ExportTest(unittest.TestCase):
|
|
|
179
201
|
class BatchTestCase(apitestcase.ApiTestCase):
|
|
180
202
|
"""A test case for batch functionality."""
|
|
181
203
|
|
|
182
|
-
start_call_params:
|
|
183
|
-
update_call_params:
|
|
204
|
+
start_call_params: Any | None
|
|
205
|
+
update_call_params: Any | None
|
|
184
206
|
|
|
185
207
|
def setUp(self):
|
|
186
208
|
super().setUp()
|
|
@@ -188,7 +210,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
188
210
|
self.start_call_params = None
|
|
189
211
|
self.update_call_params = None
|
|
190
212
|
|
|
191
|
-
def
|
|
213
|
+
def test_task_start_cloud_api(self):
|
|
192
214
|
"""Verifies that Task.start() calls the server appropriately."""
|
|
193
215
|
mock_cloud_api_resource = mock.MagicMock()
|
|
194
216
|
mock_cloud_api_resource.projects().table().export().execute.return_value = {
|
|
@@ -203,7 +225,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
203
225
|
self.assertTrue(export_args[1]['body']['requestId'])
|
|
204
226
|
self.assertEqual(export_args[1]['body']['description'], 'bar')
|
|
205
227
|
|
|
206
|
-
def
|
|
228
|
+
def test_task_cancel_cloud_api(self):
|
|
207
229
|
mock_cloud_api_resource = mock.MagicMock()
|
|
208
230
|
mock_cloud_api_resource.projects().operations().list().execute.return_value = {
|
|
209
231
|
'operations': [{
|
|
@@ -224,7 +246,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
224
246
|
cancel_args[1]['name'], 'projects/earthengine-legacy/operations/TEST1'
|
|
225
247
|
)
|
|
226
248
|
|
|
227
|
-
def
|
|
249
|
+
def test_export_image_trivial_region_cloud_api(self):
|
|
228
250
|
"""Verifies the task created by Export.image() with a trivial region."""
|
|
229
251
|
with apitestcase.UsingCloudApi():
|
|
230
252
|
region = [0, 0, 1, 0, 1, 1]
|
|
@@ -252,6 +274,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
252
274
|
'name': (
|
|
253
275
|
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
254
276
|
),
|
|
277
|
+
'overwrite': False,
|
|
255
278
|
}
|
|
256
279
|
},
|
|
257
280
|
'description': 'myExportImageTask',
|
|
@@ -259,7 +282,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
259
282
|
task.config,
|
|
260
283
|
)
|
|
261
284
|
|
|
262
|
-
def
|
|
285
|
+
def test_export_image_cloud_api(self):
|
|
263
286
|
"""Verifies the task created by Export.image()."""
|
|
264
287
|
with apitestcase.UsingCloudApi():
|
|
265
288
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -302,7 +325,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
302
325
|
task.config,
|
|
303
326
|
)
|
|
304
327
|
|
|
305
|
-
def
|
|
328
|
+
def test_export_image_cloud_api_invalid_skip_empty_tiles(self):
|
|
306
329
|
"""Verifies errors are thrown when incorrectly specifying skipEmptyTiles."""
|
|
307
330
|
with apitestcase.UsingCloudApi():
|
|
308
331
|
with self.assertRaisesRegex(
|
|
@@ -315,7 +338,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
315
338
|
skipEmptyTiles=True,
|
|
316
339
|
)
|
|
317
340
|
|
|
318
|
-
def
|
|
341
|
+
def test_export_image_with_tf_record_cloud_api(self):
|
|
319
342
|
"""Verifies the task created by Export.image()."""
|
|
320
343
|
with apitestcase.UsingCloudApi():
|
|
321
344
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -374,7 +397,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
374
397
|
task.config,
|
|
375
398
|
)
|
|
376
399
|
|
|
377
|
-
def
|
|
400
|
+
def test_export_image_to_asset_cloud_api(self):
|
|
378
401
|
"""Verifies the Asset export task created by Export.image.toAsset()."""
|
|
379
402
|
with apitestcase.UsingCloudApi():
|
|
380
403
|
config = dict(
|
|
@@ -403,6 +426,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
403
426
|
'name': (
|
|
404
427
|
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
405
428
|
),
|
|
429
|
+
'overwrite': False,
|
|
406
430
|
},
|
|
407
431
|
'pyramidingPolicyOverrides': {'B1': 'MIN'},
|
|
408
432
|
},
|
|
@@ -429,6 +453,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
429
453
|
'name': (
|
|
430
454
|
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
431
455
|
),
|
|
456
|
+
'overwrite': False,
|
|
432
457
|
},
|
|
433
458
|
'tileSize': {'value': 4},
|
|
434
459
|
},
|
|
@@ -438,7 +463,44 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
438
463
|
task_ordered.config,
|
|
439
464
|
)
|
|
440
465
|
|
|
441
|
-
|
|
466
|
+
task_with_overwrite = ee.batch.Export.image.toAsset(
|
|
467
|
+
image=config['image'],
|
|
468
|
+
assetId=config['assetId'],
|
|
469
|
+
overwrite=True,
|
|
470
|
+
)
|
|
471
|
+
self.assertTrue(
|
|
472
|
+
task_with_overwrite.config['assetExportOptions'][
|
|
473
|
+
'earthEngineDestination'
|
|
474
|
+
]['overwrite']
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
task_with_priority = ee.batch.Export.image.toAsset(
|
|
478
|
+
image=config['image'],
|
|
479
|
+
assetId=config['assetId'],
|
|
480
|
+
priority=999,
|
|
481
|
+
)
|
|
482
|
+
self.assertIsNone(task_with_priority.id)
|
|
483
|
+
self.assertIsNone(task_with_priority.name)
|
|
484
|
+
self.assertEqual('EXPORT_IMAGE', task_with_priority.task_type)
|
|
485
|
+
self.assertEqual('UNSUBMITTED', task_with_priority.state)
|
|
486
|
+
self.assertEqual(
|
|
487
|
+
{
|
|
488
|
+
'expression': expected_expression,
|
|
489
|
+
'description': 'myExportImageTask',
|
|
490
|
+
'assetExportOptions': {
|
|
491
|
+
'earthEngineDestination': {
|
|
492
|
+
'name': (
|
|
493
|
+
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
494
|
+
),
|
|
495
|
+
'overwrite': False,
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
'priority': {'value': 999},
|
|
499
|
+
},
|
|
500
|
+
task_with_priority.config,
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
def test_export_image_to_asset_cloud_api_with_tile_size(self):
|
|
442
504
|
"""Verifies the Asset export task created by Export.image.toAsset()."""
|
|
443
505
|
with apitestcase.UsingCloudApi():
|
|
444
506
|
config = dict(
|
|
@@ -467,6 +529,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
467
529
|
'name': (
|
|
468
530
|
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
469
531
|
),
|
|
532
|
+
'overwrite': False,
|
|
470
533
|
},
|
|
471
534
|
'tileSize': {'value': 4},
|
|
472
535
|
},
|
|
@@ -476,7 +539,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
476
539
|
task_ordered.config,
|
|
477
540
|
)
|
|
478
541
|
|
|
479
|
-
def
|
|
542
|
+
def test_export_image_to_cloud_storage_cloud_api(self):
|
|
480
543
|
"""Verifies the Cloud Storage export task created by Export.image()."""
|
|
481
544
|
with apitestcase.UsingCloudApi():
|
|
482
545
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -570,7 +633,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
570
633
|
task_with_priority.config,
|
|
571
634
|
)
|
|
572
635
|
|
|
573
|
-
def
|
|
636
|
+
def test_export_image_to_google_drive_cloud_api(self):
|
|
574
637
|
"""Verifies the Drive destined task created by Export.image.toDrive()."""
|
|
575
638
|
with apitestcase.UsingCloudApi():
|
|
576
639
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -676,7 +739,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
676
739
|
drive_task_with_priority.config,
|
|
677
740
|
)
|
|
678
741
|
|
|
679
|
-
def
|
|
742
|
+
def test_export_map_to_cloud_storage_cloud_api(self):
|
|
680
743
|
"""Verifies the task created by Export.map.toCloudStorage()."""
|
|
681
744
|
with apitestcase.UsingCloudApi():
|
|
682
745
|
config = dict(
|
|
@@ -809,7 +872,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
809
872
|
task_with_priority.config,
|
|
810
873
|
)
|
|
811
874
|
|
|
812
|
-
def
|
|
875
|
+
def test_export_map_to_cloud_storage_cloud_api_with_v1_parameters(self):
|
|
813
876
|
"""Verifies Export.map.toCloudStorage() tasks with v1 parameters."""
|
|
814
877
|
with apitestcase.UsingCloudApi():
|
|
815
878
|
config = dict(
|
|
@@ -865,7 +928,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
865
928
|
task_keyed.config,
|
|
866
929
|
)
|
|
867
930
|
|
|
868
|
-
def
|
|
931
|
+
def test_export_map_to_cloud_storage_cloud_api_with_v1alpha_parameters(self):
|
|
869
932
|
"""Verifies Export.map.toCloudStorage() tasks with v1alpha parameters."""
|
|
870
933
|
with apitestcase.UsingCloudApi():
|
|
871
934
|
task_keyed = ee.batch.Export.map.toCloudStorage(
|
|
@@ -894,7 +957,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
894
957
|
task_keyed.config,
|
|
895
958
|
)
|
|
896
959
|
|
|
897
|
-
def
|
|
960
|
+
def test_export_table_cloud_api(self):
|
|
898
961
|
"""Verifies the task created by Export.table()."""
|
|
899
962
|
with apitestcase.UsingCloudApi():
|
|
900
963
|
task = ee.batch.Export.table(
|
|
@@ -919,7 +982,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
919
982
|
task.config,
|
|
920
983
|
)
|
|
921
984
|
|
|
922
|
-
def
|
|
985
|
+
def test_export_table_cloud_api_bogus_parameter(self):
|
|
923
986
|
"""Verifies that bogus parameters are rejected."""
|
|
924
987
|
with apitestcase.UsingCloudApi():
|
|
925
988
|
with self.assertRaisesRegex(
|
|
@@ -929,7 +992,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
929
992
|
ee.FeatureCollection('drive test FC'), framesPerSecond=30
|
|
930
993
|
)
|
|
931
994
|
|
|
932
|
-
def
|
|
995
|
+
def test_export_table_selectors_cloud_api(self):
|
|
933
996
|
"""Verifies that table export accepts a list or tuple of selectors."""
|
|
934
997
|
with apitestcase.UsingCloudApi():
|
|
935
998
|
task = ee.batch.Export.table.toCloudStorage(
|
|
@@ -952,7 +1015,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
952
1015
|
)
|
|
953
1016
|
self.assertEqual(['ab', 'cd', 'ef'], task.config['selectors'])
|
|
954
1017
|
|
|
955
|
-
def
|
|
1018
|
+
def test_export_table_to_cloud_storage_cloud_api(self):
|
|
956
1019
|
"""Verifies the Cloud Storage task created by Export.table()."""
|
|
957
1020
|
with apitestcase.UsingCloudApi():
|
|
958
1021
|
task = ee.batch.Export.table.toCloudStorage(
|
|
@@ -1003,7 +1066,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1003
1066
|
task_with_priority.config,
|
|
1004
1067
|
)
|
|
1005
1068
|
|
|
1006
|
-
def
|
|
1069
|
+
def test_export_table_to_google_drive_cloud_api(self):
|
|
1007
1070
|
"""Verifies the Drive destined task created by Export.table.toDrive()."""
|
|
1008
1071
|
with apitestcase.UsingCloudApi():
|
|
1009
1072
|
test_collection = ee.FeatureCollection('foo')
|
|
@@ -1090,7 +1153,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1090
1153
|
)
|
|
1091
1154
|
self.assertEqual(expected_config_with_priority, task_with_priority.config)
|
|
1092
1155
|
|
|
1093
|
-
def
|
|
1156
|
+
def test_export_table_to_asset_cloud_api(self):
|
|
1094
1157
|
"""Verifies the export task created by Export.table.toAsset()."""
|
|
1095
1158
|
with apitestcase.UsingCloudApi():
|
|
1096
1159
|
task = ee.batch.Export.table.toAsset(
|
|
@@ -1111,11 +1174,25 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1111
1174
|
'name': (
|
|
1112
1175
|
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
1113
1176
|
),
|
|
1177
|
+
'overwrite': False,
|
|
1114
1178
|
}
|
|
1115
1179
|
},
|
|
1116
1180
|
},
|
|
1117
1181
|
task.config,
|
|
1118
1182
|
)
|
|
1183
|
+
|
|
1184
|
+
task_with_overwrite = ee.batch.Export.table.toAsset(
|
|
1185
|
+
collection=ee.FeatureCollection('foo'),
|
|
1186
|
+
description='foo',
|
|
1187
|
+
assetId='users/foo/bar',
|
|
1188
|
+
overwrite=True,
|
|
1189
|
+
)
|
|
1190
|
+
self.assertTrue(
|
|
1191
|
+
task_with_overwrite.config['assetExportOptions'][
|
|
1192
|
+
'earthEngineDestination'
|
|
1193
|
+
]['overwrite']
|
|
1194
|
+
)
|
|
1195
|
+
|
|
1119
1196
|
task_with_priority = ee.batch.Export.table.toAsset(
|
|
1120
1197
|
collection=ee.FeatureCollection('foo'),
|
|
1121
1198
|
description='foo',
|
|
@@ -1131,6 +1208,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1131
1208
|
'name': (
|
|
1132
1209
|
'projects/earthengine-legacy/assets/users/foo/bar'
|
|
1133
1210
|
),
|
|
1211
|
+
'overwrite': False,
|
|
1134
1212
|
}
|
|
1135
1213
|
},
|
|
1136
1214
|
'priority': {'value': 999},
|
|
@@ -1138,7 +1216,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1138
1216
|
task_with_priority.config,
|
|
1139
1217
|
)
|
|
1140
1218
|
|
|
1141
|
-
def
|
|
1219
|
+
def test_export_table_with_file_format_cloud_api(self):
|
|
1142
1220
|
"""Verifies the task created by Export.table() given a file format."""
|
|
1143
1221
|
with apitestcase.UsingCloudApi():
|
|
1144
1222
|
task = ee.batch.Export.table.toCloudStorage(
|
|
@@ -1165,7 +1243,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1165
1243
|
task.config,
|
|
1166
1244
|
)
|
|
1167
1245
|
|
|
1168
|
-
def
|
|
1246
|
+
def test_export_table_to_feature_view_cloud_api(self):
|
|
1169
1247
|
"""Verifies the export task created by Export.table.toFeatureView()."""
|
|
1170
1248
|
with apitestcase.UsingCloudApi():
|
|
1171
1249
|
task = ee.batch.Export.table.toFeatureView(
|
|
@@ -1228,7 +1306,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1228
1306
|
task_with_priority.config,
|
|
1229
1307
|
)
|
|
1230
1308
|
|
|
1231
|
-
def
|
|
1309
|
+
def test_export_table_to_feature_view_empty_params_cloud_api(self):
|
|
1232
1310
|
"""Verifies the export task created by Export.table.toFeatureView()."""
|
|
1233
1311
|
with apitestcase.UsingCloudApi():
|
|
1234
1312
|
task = ee.batch.Export.table.toFeatureView(
|
|
@@ -1260,7 +1338,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1260
1338
|
task.config,
|
|
1261
1339
|
)
|
|
1262
1340
|
|
|
1263
|
-
def
|
|
1341
|
+
def test_export_table_to_feature_view_all_ingestion_params(self):
|
|
1264
1342
|
"""Verifies the task ingestion params created by toFeatureView()."""
|
|
1265
1343
|
task = ee.batch.Export.table.toFeatureView(
|
|
1266
1344
|
collection=ee.FeatureCollection('foo'),
|
|
@@ -1306,7 +1384,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1306
1384
|
task.config['featureViewExportOptions']['ingestionTimeParameters'],
|
|
1307
1385
|
)
|
|
1308
1386
|
|
|
1309
|
-
def
|
|
1387
|
+
def test_export_table_to_feature_view_bad_rank_by_one_thing_rule(self):
|
|
1310
1388
|
"""Verifies a bad RankByOneThingRule throws an exception."""
|
|
1311
1389
|
with self.assertRaisesRegex(
|
|
1312
1390
|
ee.EEException, 'Ranking rule format is invalid.*'
|
|
@@ -1317,7 +1395,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1317
1395
|
ingestionTimeParameters={'thinningRanking': 'my-attribute BAD_DIR'},
|
|
1318
1396
|
)
|
|
1319
1397
|
|
|
1320
|
-
def
|
|
1398
|
+
def test_export_table_to_feature_view_bad_ranking_rule(self):
|
|
1321
1399
|
"""Verifies a bad RankingRule throws an exception."""
|
|
1322
1400
|
with self.assertRaisesRegex(
|
|
1323
1401
|
ee.EEException, 'Unable to build ranking rule from rules.*'
|
|
@@ -1328,7 +1406,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1328
1406
|
ingestionTimeParameters={'thinningRanking': {'key': 'val'}},
|
|
1329
1407
|
)
|
|
1330
1408
|
|
|
1331
|
-
def
|
|
1409
|
+
def test_export_table_to_feature_view_bad_ingestion_time_params(self):
|
|
1332
1410
|
"""Verifies a bad set of ingestion time params throws an exception."""
|
|
1333
1411
|
with self.assertRaisesRegex(
|
|
1334
1412
|
ee.EEException,
|
|
@@ -1343,7 +1421,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1343
1421
|
ingestionTimeParameters={'badThinningKey': {'key': 'val'}},
|
|
1344
1422
|
)
|
|
1345
1423
|
|
|
1346
|
-
def
|
|
1424
|
+
def test_export_table_to_big_query_required_params(self):
|
|
1347
1425
|
"""Verifies the export task created by Export.table.toBigQuery()."""
|
|
1348
1426
|
with apitestcase.UsingCloudApi():
|
|
1349
1427
|
task = ee.batch.Export.table.toBigQuery(
|
|
@@ -1396,7 +1474,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1396
1474
|
task_with_priority.config,
|
|
1397
1475
|
)
|
|
1398
1476
|
|
|
1399
|
-
def
|
|
1477
|
+
def test_export_table_to_big_query_all_params(self):
|
|
1400
1478
|
"""Verifies the export task created by Export.table.toBigQuery()."""
|
|
1401
1479
|
with apitestcase.UsingCloudApi():
|
|
1402
1480
|
task = ee.batch.Export.table.toBigQuery(
|
|
@@ -1433,7 +1511,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1433
1511
|
task.config,
|
|
1434
1512
|
)
|
|
1435
1513
|
|
|
1436
|
-
def
|
|
1514
|
+
def test_export_table_to_big_query_bad_table_name(self):
|
|
1437
1515
|
"""Verifies a bad table name throws an exception."""
|
|
1438
1516
|
with apitestcase.UsingCloudApi():
|
|
1439
1517
|
with self.assertRaisesRegex(
|
|
@@ -1456,7 +1534,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1456
1534
|
description='foo',
|
|
1457
1535
|
)
|
|
1458
1536
|
|
|
1459
|
-
def
|
|
1537
|
+
def test_export_video_cloud_api(self):
|
|
1460
1538
|
"""Verifies the task created by Export.video()."""
|
|
1461
1539
|
with apitestcase.UsingCloudApi():
|
|
1462
1540
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -1546,7 +1624,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1546
1624
|
collection, 'TestVideoName', config_with_bogus_option
|
|
1547
1625
|
)
|
|
1548
1626
|
|
|
1549
|
-
def
|
|
1627
|
+
def test_export_video_to_cloud_storage_cloud_api(self):
|
|
1550
1628
|
"""Verifies the task created by Export.video.toCloudStorage()."""
|
|
1551
1629
|
with apitestcase.UsingCloudApi():
|
|
1552
1630
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -1641,7 +1719,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1641
1719
|
)
|
|
1642
1720
|
self.assertEqual(expected_config_with_priority, task_with_priority.config)
|
|
1643
1721
|
|
|
1644
|
-
def
|
|
1722
|
+
def test_export_video_to_drive_cloud_api(self):
|
|
1645
1723
|
"""Verifies the task created by Export.video.toDrive()."""
|
|
1646
1724
|
with apitestcase.UsingCloudApi():
|
|
1647
1725
|
region = ee.Geometry.Rectangle(1, 2, 3, 4)
|
|
@@ -1734,7 +1812,7 @@ class BatchTestCase(apitestcase.ApiTestCase):
|
|
|
1734
1812
|
)
|
|
1735
1813
|
self.assertEqual(expected_config_with_priority, task_with_priority.config)
|
|
1736
1814
|
|
|
1737
|
-
def
|
|
1815
|
+
def test_export_workload_tag(self):
|
|
1738
1816
|
"""Verifies that the workload tag state is captured before start."""
|
|
1739
1817
|
mock_cloud_api_resource = mock.MagicMock()
|
|
1740
1818
|
mock_cloud_api_resource.projects().table().export().execute.return_value = {
|
ee/tests/blob_test.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""Test for the blob module."""
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
import unittest
|
|
8
8
|
import ee
|
|
@@ -12,8 +12,8 @@ URL = 'gs://ee-docs-demos/something'
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def make_expression_graph(
|
|
15
|
-
function_invocation_value:
|
|
16
|
-
) ->
|
|
15
|
+
function_invocation_value: dict[str, Any],
|
|
16
|
+
) -> dict[str, Any]:
|
|
17
17
|
return {
|
|
18
18
|
'result': '0',
|
|
19
19
|
'values': {'0': {'functionInvocationValue': function_invocation_value}},
|
|
@@ -75,9 +75,9 @@ class BlobTest(apitestcase.ApiTestCase):
|
|
|
75
75
|
self.assertEqual({'value': 'fakeValue'}, result.getInfo())
|
|
76
76
|
|
|
77
77
|
def test_wrong_arg_type(self):
|
|
78
|
-
message = '
|
|
78
|
+
message = r'url must be a string or ComputedObject: <class \'int\'> -> "13"'
|
|
79
79
|
with self.assertRaisesRegex(ValueError, message):
|
|
80
|
-
ee.Blob(
|
|
80
|
+
ee.Blob(13) # pytype: disable=wrong-arg-types
|
|
81
81
|
|
|
82
82
|
def test_does_not_start_with_gs(self):
|
|
83
83
|
url = 'http://example.com/something'
|
ee/tests/classifier_test.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
5
|
import sys
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
7
7
|
import unittest
|
|
8
8
|
|
|
9
9
|
import unittest
|
|
@@ -33,8 +33,8 @@ _CLASSIFIER_LOAD_A = {
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def make_expression_graph(
|
|
36
|
-
function_invocation_value:
|
|
37
|
-
) ->
|
|
36
|
+
function_invocation_value: dict[str, Any],
|
|
37
|
+
) -> dict[str, Any]:
|
|
38
38
|
return {
|
|
39
39
|
'result': '0',
|
|
40
40
|
'values': {'0': {'functionInvocationValue': function_invocation_value}},
|
ee/tests/clusterer_test.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
5
|
import sys
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
7
7
|
import unittest
|
|
8
8
|
|
|
9
9
|
import unittest
|
|
@@ -28,8 +28,8 @@ _WEKA_COBWEB_SERIALIZED = {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def make_expression_graph(
|
|
31
|
-
function_invocation_value:
|
|
32
|
-
) ->
|
|
31
|
+
function_invocation_value: dict[str, Any],
|
|
32
|
+
) -> dict[str, Any]:
|
|
33
33
|
return {
|
|
34
34
|
'result': '0',
|
|
35
35
|
'values': {'0': {'functionInvocationValue': function_invocation_value}},
|