Skip to content

Commit 6796f0e

Browse files
committed
Issue #242/#248 bit of final fine-tuning
1 parent 6eb29c5 commit 6796f0e

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Add `options` argument to `DataCube.atmospheric_correction` ([Open-EO/openeo-python-driver#91](https://github.com/Open-EO/openeo-python-driver/issues/91))
1313
- Add `atmospheric_correction_options` and `cloud_detection_options` arguments to `DataCube.ard_surface_reflectance` ([Open-EO/openeo-python-driver#91](https://github.com/Open-EO/openeo-python-driver/issues/91))
14+
- UDP storing: add support for "returns", "categories", "examples" and "links" properties ([#242](https://github.com/Open-EO/openeo-python-client/issues/242))
1415

1516

1617
### Changed

openeo/rest/connection.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,13 @@ def save_user_defined_process(
719719
self, user_defined_process_id: str,
720720
process_graph: Union[dict, ProcessBuilderBase],
721721
parameters: List[Union[dict, Parameter]] = None,
722-
public: bool = False, summary: str = None, description: str = None,
723-
returns: Optional[dict] = None, categories: Optional[List[str]] = None,
724-
examples: Optional[List[dict]] = None, links: Optional[List[dict]] = None
722+
public: bool = False,
723+
summary: Optional[str] = None,
724+
description: Optional[str] = None,
725+
returns: Optional[dict] = None,
726+
categories: Optional[List[str]] = None,
727+
examples: Optional[List[dict]] = None,
728+
links: Optional[List[dict]] = None,
725729
) -> RESTUserDefinedProcess:
726730
"""
727731
Store a process graph and its metadata on the backend as a user-defined process for the authenticated user.
@@ -745,8 +749,10 @@ def save_user_defined_process(
745749
warnings.warn("Defining user-defined process {u!r} without parameters".format(u=user_defined_process_id))
746750
udp = RESTUserDefinedProcess(user_defined_process_id=user_defined_process_id, connection=self)
747751
udp.store(
748-
process_graph=process_graph, parameters=parameters, public=public, summary=summary, description=description,
749-
returns=returns, categories=categories, examples=examples, links=links)
752+
process_graph=process_graph, parameters=parameters, public=public,
753+
summary=summary, description=description,
754+
returns=returns, categories=categories, examples=examples, links=links
755+
)
750756
return udp
751757

752758
def list_user_defined_processes(self) -> List[dict]:

openeo/rest/datacube.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,9 +1563,16 @@ def send_job(
15631563
)
15641564

15651565
def save_user_defined_process(
1566-
self, user_defined_process_id: str, public: bool = False, summary: str=None, description: str=None,
1567-
returns: Optional[dict] = None, categories: Optional[List[str]] = None, examples: Optional[List[dict]] = None,
1568-
links: Optional[List[dict]] = None) -> RESTUserDefinedProcess:
1566+
self,
1567+
user_defined_process_id: str,
1568+
public: bool = False,
1569+
summary: Optional[str] = None,
1570+
description: Optional[str] = None,
1571+
returns: Optional[dict] = None,
1572+
categories: Optional[List[str]] = None,
1573+
examples: Optional[List[dict]] = None,
1574+
links: Optional[List[dict]] = None,
1575+
) -> RESTUserDefinedProcess:
15691576
"""
15701577
Saves this process graph in the backend as a user-defined process for the authenticated user.
15711578
@@ -1582,7 +1589,8 @@ def save_user_defined_process(
15821589
return self._connection.save_user_defined_process(
15831590
user_defined_process_id=user_defined_process_id,
15841591
process_graph=self.flat_graph(), public=public, summary=summary, description=description,
1585-
returns=returns, categories=categories, examples=examples, links=links)
1592+
returns=returns, categories=categories, examples=examples, links=links,
1593+
)
15861594

15871595
def execute(self) -> Dict:
15881596
"""Executes the process graph of the imagery. """

openeo/rest/udp.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def build_process_dict(
2323
returns: Optional[dict] = None,
2424
categories: Optional[List[str]] = None,
2525
examples: Optional[List[dict]] = None,
26-
links: Optional[List[dict]] = None
26+
links: Optional[List[dict]] = None,
2727
) -> dict:
2828
"""
2929
Build a dictionary describing a process with metadaa (`process_graph`, `parameters`, `description`, ...)
@@ -70,15 +70,22 @@ def _repr_html_(self):
7070
return render_component('process', data=process, parameters = {'show-graph': True, 'provide-download': False})
7171

7272
def store(
73-
self, process_graph: Union[dict, ProcessBuilderBase], parameters: List[Union[Parameter, dict]] = None,
74-
public: bool = False, summary: str = None, description: str = None, returns: Optional[dict] = None,
75-
categories: Optional[List[str]] = None, examples: Optional[List[dict]] = None, links: Optional[List[dict]] = None
73+
self,
74+
process_graph: Union[dict, ProcessBuilderBase],
75+
parameters: List[Union[Parameter, dict]] = None,
76+
public: bool = False,
77+
summary: Optional[str] = None,
78+
description: Optional[str] = None,
79+
returns: Optional[dict] = None,
80+
categories: Optional[List[str]] = None,
81+
examples: Optional[List[dict]] = None,
82+
links: Optional[List[dict]] = None,
7683
):
7784
"""Store a process graph and its metadata on the backend as a user-defined process"""
7885
process = build_process_dict(
7986
process_graph=process_graph, parameters=parameters,
8087
summary=summary, description=description, returns=returns,
81-
categories=categories, examples=examples, links=links
88+
categories=categories, examples=examples, links=links,
8289
)
8390

8491
# TODO: this "public" flag is not standardized yet EP-3609, https://github.com/Open-EO/openeo-api/issues/310

tests/rest/test_udp.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,24 @@ def check_body(request):
6969
"public": False,
7070
"summary": "A summary",
7171
"description": "A description",
72+
"returns": {"schema": {"type": ["number", "null"]}},
7273
"categories": ["math", "simple"],
74+
"examples": [{"arguments": {"x": 5, "y": 2.5}, "returns": 7.5}, ],
7375
"links": [{"link1": "openeo.cloud", "link2": "openeo.vito.be"}],
74-
"examples": [{"arguments":{"x": 5,"y": 2.5},"returns": 7.5},],
75-
"returns": {"schema":{"type": ["number","null"]}}
7676
}
7777
return True
7878

7979
adapter = requests_mock.put(API_URL + "/process_graphs/two", additional_matcher=check_body)
8080

8181
udp = con100.save_user_defined_process(
82-
"two", two, summary = "A summary", categories = ["math", "simple"],
83-
links = [{"link1": "openeo.cloud", "link2": "openeo.vito.be"}],
84-
examples = [{"arguments":{"x": 5,"y": 2.5},"returns": 7.5},],
85-
description = "A description", returns = {"schema":{"type": ["number","null"]}})
82+
"two", two,
83+
summary="A summary",
84+
description="A description",
85+
returns={"schema": {"type": ["number", "null"]}},
86+
categories=["math", "simple"],
87+
examples=[{"arguments": {"x": 5, "y": 2.5}, "returns": 7.5}, ],
88+
links=[{"link1": "openeo.cloud", "link2": "openeo.vito.be"}],
89+
)
8690
assert isinstance(udp, RESTUserDefinedProcess)
8791
assert adapter.called
8892

0 commit comments

Comments
 (0)