Skip to content

Commit

Permalink
Issue #366 update to parameter/options change in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Feb 6, 2025
1 parent 836bf69 commit 0770cf9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
2 changes: 2 additions & 0 deletions openeo_driver/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ class OpenEoBackendImplementation:
"https://api.openeo.org/1.2.0",
# Support the "remote process definition" extension (originally known as the "remote-udp" extension)
"https://api.openeo.org/extensions/remote-process-definition/0.1.0",
# Processing Parameters extension
"https://api.openeo.org/extensions/processing-parameters/0.1.0",
# STAC API conformance classes
# "https://api.stacspec.org/v1.0.0/core", # TODO #363 can we claim this conformance class already?
"https://api.stacspec.org/v1.0.0/collections",
Expand Down
18 changes: 4 additions & 14 deletions openeo_driver/processgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class ProcessDefinition(NamedTuple):
# Definition what the process returns
returns: Optional[dict] = None

# TODO: official naming of these "processing parameter" related properties is undecided at the moment.
# see https://github.com/Open-EO/openeo-api/pull/471#discussion_r1904253964
default_job_options: Optional[dict] = None
default_synchronous_options: Optional[dict] = None

Expand Down Expand Up @@ -111,18 +109,10 @@ def _get_process_definition_from_url(process_id: str, url: str) -> ProcessDefini
message=f"No valid process definition for {process_id!r} found at {url!r}.",
)

# TODO: official property name for these "processing parameters" is undecided at the moment.
# see https://github.com/Open-EO/openeo-api/pull/471#discussion_r1904253964
if "default_job_parameters" in spec:
_log.warning("Extracting experimental 'default_job_parameters' from process definition.")
default_job_options = spec["default_job_parameters"]
else:
default_job_options = None
if "default_synchronous_parameters" in spec:
_log.warning("Extracting experimental 'default_synchronous_parameters' from process definition.")
default_synchronous_options = spec["default_synchronous_parameters"]
else:
default_synchronous_options = None
# Processing Parameters Extension support
# (conformance class `https://api.openeo.org/extensions/processing-parameters/0.1.0`)
default_job_options = spec.get("default_job_options", None)
default_synchronous_options = spec.get("default_synchronous_options", None)

return ProcessDefinition(
id=process_id,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_processgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ def test_extract_default_job_options_from_process_graph(requests_mock):
json={
"id": "add3",
"process_graph": {
"add": {"process_id": "add", "arguments": {"x": {"from_parameter": "x", "y": 3}, "result": True}}
"add": {"process_id": "add", "arguments": {"x": {"from_parameter": "x"}, "y": 3}, "result": True}
},
"parameters": [
{"name": "x", "schema": {"type": "number"}},
],
"returns": {"schema": {"type": "number"}},
"default_job_parameters": {
"default_job_options": {
"memory": "2GB",
"cpu": "yellow",
},
"default_synchronous_parameters": {
"default_synchronous_options": {
"cpu": "green",
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ def test_create_job_100_with_job_options_and_defaults_from_remote_process_defini
"returns": {"schema": {"type": "number"}},
}
if default_job_options is not None:
process_definition["default_job_parameters"] = default_job_options
process_definition["default_job_options"] = default_job_options
requests_mock.get("https://share.test/add3.json", json=process_definition)

pg = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4707,7 +4707,7 @@ def test_synchronous_processing_job_options_and_defaults_from_remote_process_def
"returns": {"schema": {"type": "number"}},
}
if default_job_options is not None:
process_definition["default_synchronous_parameters"] = default_job_options
process_definition["default_synchronous_options"] = default_job_options
requests_mock.get("https://share.test/add3.json", json=process_definition)

actual_job_options = []
Expand Down

0 comments on commit 0770cf9

Please sign in to comment.