Skip to content

Commit 1373695

Browse files
committed
Finetune docs about result_node and PGNode.update_arguments
1 parent 4ec029f commit 1373695

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

docs/api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,11 @@ openeo.util
109109

110110
.. automodule:: openeo.util
111111
:members: to_bbox_dict, BBoxDict
112+
113+
114+
openeo.internal
115+
----------------
116+
117+
.. automodule:: openeo.internal.graph_building
118+
:members: PGNode
119+

openeo/internal/graph_building.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
3-
Process graph building functionality for 1.0.0-style process graphs and DataCube
4-
3+
Functionality for abstracting, building, manipulating and processing openEO process graphs.
54
"""
65
import abc
76
import collections
@@ -23,15 +22,11 @@ def from_node(self) -> "PGNode":
2322

2423
class PGNode(_FromNodeMixin):
2524
"""
26-
Wrapper for process node in a process graph (has process_id and arguments).
27-
28-
While this is a simple, thin container, it allows a bit more abstraction, basic encapsulation,
29-
type hinting and code intelligence in your IDE than something generic like a dict.
30-
31-
Also note that a full openEO "process graph" is essentially a directed acyclic graph of nodes
32-
pointing to each other. A process graph is practically equivalent with its "result" node,
33-
as it points (directly or recursively) to all the other nodes it depends on.
25+
A process node in a process graph: has at least a process_id and arguments.
3426
27+
Note that a full openEO "process graph" is essentially a directed acyclic graph of nodes
28+
pointing to each other. A full process graph is practically equivalent with its "result" node,
29+
as it points (directly or indirectly) to all the other nodes it depends on.
3530
"""
3631

3732
def __init__(self, process_id: str, arguments: dict = None, namespace: Union[str, None] = None, **kwargs):
@@ -69,7 +64,11 @@ def namespace(self) -> Union[str, None]:
6964
return self._namespace
7065

7166
def update_arguments(self, **kwargs):
72-
"""Change/Add/Update arguments of the process node"""
67+
"""
68+
Add/Update arguments of the process node.
69+
70+
.. versionadded:: 0.10.1
71+
"""
7372
self._arguments = {**self._arguments, **kwargs}
7473

7574
def _as_tuple(self):
@@ -102,7 +101,7 @@ def _deep_copy(x):
102101
return _deep_copy(self)
103102

104103
def flat_graph(self) -> dict:
105-
"""Get the process graph in flat dict representation"""
104+
"""Get the process graph in flat dict representation."""
106105
return GraphFlattener().flatten(node=self)
107106

108107
flatten = legacy_alias(flat_graph, name="flatten")
@@ -112,7 +111,7 @@ def to_process_graph_argument(value: Union['PGNode', str, dict]) -> dict:
112111
"""
113112
Normalize given argument properly to a "process_graph" argument
114113
to be used as reducer/subprocess for processes like
115-
'reduce_dimension', 'aggregate_spatial', 'apply', 'merge_cubes', 'resample_cube_temporal'
114+
``reduce_dimension``, ``aggregate_spatial``, ``apply``, ``merge_cubes``, ``resample_cube_temporal``
116115
"""
117116
if isinstance(value, str):
118117
# assume string with predefined reduce/apply process ("mean", "sum", ...)
@@ -127,7 +126,7 @@ def to_process_graph_argument(value: Union['PGNode', str, dict]) -> dict:
127126

128127
@staticmethod
129128
def from_flat_graph(flat_graph: dict, parameters: Optional[dict] = None) -> 'PGNode':
130-
"""Unflatten a given flat dict representation of a process graph and return result node"""
129+
"""Unflatten a given flat dict representation of a process graph and return result node."""
131130
return PGNodeGraphUnflattener.unflatten(flat_graph=flat_graph, parameters=parameters)
132131

133132

openeo/rest/_datacube.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ def connection(self) -> "Connection":
5858
return self._connection
5959

6060
def result_node(self) -> PGNode:
61-
"""Get the result node (:py:class:`PGNode`) of the process graph."""
61+
"""
62+
Get the current result node (:py:class:`PGNode`) of the process graph.
63+
64+
.. versionadded:: 0.10.1
65+
"""
6266
return self._pg
6367

6468
def from_node(self):

0 commit comments

Comments
 (0)