Skip to content

Commit c29856c

Browse files
authored
Merge pull request #1092 from planetlabs/charcey/orders_subs_parity
Housekeeping: Add GEE delivery option for Subscription, OCS delivery option for Orders, remove PS2 target sensor for harmonize tool
2 parents 837b24d + 1bfc7fe commit c29856c

File tree

5 files changed

+113
-4
lines changed

5 files changed

+113
-4
lines changed

planet/order_request.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,38 @@ def google_earth_engine(project: str, collection: str) -> dict:
320320
return {'google_earth_engine': cloud_details}
321321

322322

323+
def oracle_cloud_storage(customer_access_key_id: str,
324+
customer_secret_key: str,
325+
bucket: str,
326+
region: str,
327+
namespace: str,
328+
path_prefix: Optional[str] = None) -> dict:
329+
"""Oracle Cloud Storage configuration.
330+
331+
Parameters:
332+
customer_access_key_id: Customer Access Key credentials.
333+
customer_secret_key: Customer Secret Key credentials.
334+
bucket: The name of the bucket that will receive the order output.
335+
region: The region where the bucket lives in Oracle.
336+
namespace: Object Storage namespace name.
337+
path_prefix: Custom string to prepend to the files delivered to the
338+
bucket. A slash (/) character will be treated as a "folder".
339+
Any other characters will be added as a prefix to the files.
340+
"""
341+
cloud_details = {
342+
'customer_access_key_id': customer_access_key_id,
343+
'customer_secret_key': customer_secret_key,
344+
'bucket': bucket,
345+
'region': region,
346+
'namespace': namespace
347+
}
348+
349+
if path_prefix:
350+
cloud_details['path_prefix'] = path_prefix
351+
352+
return {'oracle_cloud_storage': cloud_details}
353+
354+
323355
def _tool(name: str, parameters: dict) -> dict:
324356
"""Create the API spec representation of a tool.
325357
@@ -380,11 +412,14 @@ def composite_tool(group_by: Optional[str] = None) -> dict:
380412
Parameters:
381413
group_by: (Optional) Defines how items are grouped to create one or more composites.
382414
Supported values are:
383-
- "order": All input items are used to create a single composite output.
415+
- "order": All input items are used to create a single composite output. This is the default behavior.
384416
- "strip_id": Input items are grouped by their strip_id to create multiple composites.
385417
386418
Returns:
387419
dict: A dictionary representing the composite tool configuration.
420+
421+
Raises:
422+
planet.exceptions.ClientError: If group_by is not one of "order" or "strip_id".
388423
"""
389424
if group_by and group_by not in ["order", "strip_id"]:
390425
raise ClientError(

planet/specs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
SUPPORTED_ORDER_TYPES = ['full', 'partial']
3434
SUPPORTED_ARCHIVE_TYPES = ['zip']
3535
SUPPORTED_FILE_FORMATS = ['COG', 'PL_NITF']
36-
HARMONIZE_TOOL_TARGET_SENSORS = ('Sentinel-2', 'PS2')
36+
HARMONIZE_TOOL_TARGET_SENSORS = ['Sentinel-2']
3737
BAND_MATH_PIXEL_TYPE = ('Auto', '8U', '16U', '16S', '32R')
3838
BAND_MATH_PIXEL_TYPE_DEFAULT = 'Auto'
3939

@@ -112,9 +112,9 @@ def validate_supported_bundles(item_type, bundle, all_product_bundles):
112112

113113
supported_bundles = []
114114
for product_bundle in all_product_bundles:
115-
availible_item_types = set(
115+
available_item_types = set(
116116
spec['bundles'][product_bundle]['assets'].keys())
117-
if item_type.lower() in [x.lower() for x in availible_item_types]:
117+
if item_type.lower() in [x.lower() for x in available_item_types]:
118118
supported_bundles.append(product_bundle)
119119

120120
return _validate_field(bundle, supported_bundles, 'bundle')

planet/subscription_request.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,23 @@ def azure_blob_storage(account: str,
435435
return _delivery('azure_blob_storage', parameters)
436436

437437

438+
def google_earth_engine(project: str, collection: str,
439+
credentials: str) -> dict:
440+
"""Delivery to Google Earth Engine.
441+
442+
Parameters:
443+
project: GEE project name.
444+
collection: GEE Image Collection name.
445+
credentials: GEE service account credentials.
446+
"""
447+
parameters = {
448+
'project': project,
449+
'collection': collection,
450+
'credentials': credentials
451+
}
452+
return _delivery('google_earth_engine', parameters)
453+
454+
438455
def google_cloud_storage(credentials: str,
439456
bucket: str,
440457
path_prefix: Optional[str] = None) -> dict:

tests/unit/test_order_request.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@ def test_google_earth_engine():
240240
assert gee_config == expected
241241

242242

243+
def test_oracle_cloud_storage():
244+
ocs_config = order_request.oracle_cloud_storage('ocs_access_key_id',
245+
'ocs_secret_access_key',
246+
'bucket',
247+
'region',
248+
'namespace')
249+
250+
expected = {
251+
'oracle_cloud_storage': {
252+
'customer_access_key_id': 'ocs_access_key_id',
253+
'customer_secret_key': 'ocs_secret_access_key',
254+
'bucket': 'bucket',
255+
'region': 'region',
256+
'namespace': 'namespace'
257+
}
258+
}
259+
assert ocs_config == expected
260+
261+
243262
def test__tool():
244263
test_tool = order_request._tool('bandmath', 'jsonstring')
245264
assert test_tool == {'bandmath': 'jsonstring'}
@@ -267,6 +286,29 @@ def test_clip_tool_invalid(point_geom_geojson):
267286
order_request.clip_tool(point_geom_geojson)
268287

269288

289+
def test_composite_tool_no_group_by():
290+
composite_tool = order_request.composite_tool()
291+
expected = {'composite': {}}
292+
assert composite_tool == expected
293+
294+
295+
def test_composite_tool_group_by_strip_id():
296+
composite_tool = order_request.composite_tool(group_by='strip_id')
297+
expected = {'composite': {'group_by': 'strip_id'}}
298+
assert composite_tool == expected
299+
300+
301+
def test_composite_tool_group_by_order():
302+
composite_tool = order_request.composite_tool(group_by='order')
303+
expected = {'composite': {'group_by': 'order'}}
304+
assert composite_tool == expected
305+
306+
307+
def test_composite_tool_group_by_invalid():
308+
with pytest.raises(exceptions.ClientError):
309+
order_request.composite_tool(group_by='invalid')
310+
311+
270312
def test_reproject_tool():
271313
rt = order_request.reproject_tool(projection='proj', resolution=5)
272314
expected = {'reproject': {'projection': 'proj', 'resolution': 5}}

tests/unit/test_subscription_request.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ def test_azure_blob_storage_path_prefix_success():
307307
}
308308

309309

310+
def test_google_earth_engine_success():
311+
res = subscription_request.google_earth_engine(project='project',
312+
collection='collection',
313+
credentials='cred')
314+
315+
assert res == {
316+
"type": "google_earth_engine",
317+
"parameters": {
318+
"project": "project",
319+
"collection": "collection",
320+
"credentials": "cred"
321+
}
322+
}
323+
324+
310325
def test_google_cloud_storage_success():
311326
res = subscription_request.google_cloud_storage(credentials='cred',
312327
bucket='bucket')

0 commit comments

Comments
 (0)