Skip to content

Commit 5a4115e

Browse files
committed
fixed docstings
1 parent 0bcfc1b commit 5a4115e

1 file changed

Lines changed: 33 additions & 37 deletions

File tree

python-sdk/exospherehost/node/BaseNode.py

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,68 @@
66
class BaseNode(ABC):
77
"""
88
Abstract base class for all nodes in the exospherehost system.
9-
10-
BaseNode provides the foundation for creating executable nodes that can be
11-
connected to a Runtime for distributed processing. Each node must implement
12-
the execute method and can optionally define Inputs and Outputs models.
13-
9+
10+
This class defines the interface and structure for executable nodes that can be
11+
managed by an Exosphere Runtime. Subclasses should define their own `Inputs` and
12+
`Outputs` models (as subclasses of pydantic.BaseModel) to specify the input and
13+
output schemas for the node, and must implement the `execute` method containing
14+
the node's main logic.
15+
1416
Attributes:
15-
unique_name (Optional[str]): A unique identifier for this node instance.
16-
If None, the class name will be used as the unique name.
17-
state (dict[str, Any]): A dictionary for storing node state between executions.
17+
inputs (Optional[BaseNode.Inputs]): The validated input data for the node execution.
1818
"""
1919

2020
def __init__(self):
2121
"""
2222
Initialize a BaseNode instance.
23-
24-
Args:
25-
unique_name (Optional[str], optional): A unique identifier for this node.
26-
If None, the class name will be used as the unique name. Defaults to None.
23+
24+
Sets the `inputs` attribute to None. The `inputs` attribute will be populated
25+
with validated input data before execution.
2726
"""
2827
self.inputs: Optional[BaseNode.Inputs] = None
2928

3029
class Inputs(BaseModel):
3130
"""
32-
Pydantic model for defining the input schema of a node.
33-
34-
Subclasses should override this class to define the expected input structure.
35-
This ensures type safety and validation of inputs before execution.
31+
Input schema for the node.
32+
33+
Subclasses should override this class to define the expected input fields.
3634
"""
3735
pass
3836

3937
class Outputs(BaseModel):
4038
"""
41-
Pydantic model for defining the output schema of a node.
42-
43-
Subclasses should override this class to define the expected output structure.
44-
This ensures type safety and validation of outputs after execution.
39+
Output schema for the node.
40+
41+
Subclasses should override this class to define the expected output fields.
4542
"""
4643
pass
4744

4845
async def _execute(self, inputs: Inputs) -> Outputs | List[Outputs]:
4946
"""
50-
Execute the node's main logic.
47+
Internal method to execute the node with validated inputs.
48+
49+
Args:
50+
inputs (Inputs): The validated input data for this execution.
51+
52+
Returns:
53+
Outputs | List[Outputs]: The output(s) produced by the node.
5154
"""
5255
self.inputs = inputs
5356
return await self.execute()
5457

5558
@abstractmethod
5659
async def execute(self) -> Outputs | List[Outputs]:
5760
"""
58-
Execute the node's main logic.
59-
60-
This is the core method that must be implemented by all concrete node classes.
61-
It receives inputs, processes them according to the node's logic, and returns
62-
outputs. The method can return either a single Outputs instance or a list
63-
of Outputs instances for batch processing.
64-
65-
Args:
66-
inputs (Inputs): The input data for this execution, validated against
67-
the Inputs model defined by the node.
68-
61+
Main logic for the node.
62+
63+
This method must be implemented by all subclasses. It should use `self.inputs`
64+
(populated with validated input data) to perform the node's computation and
65+
return either a single Outputs instance or a list of Outputs instances.
66+
6967
Returns:
70-
Outputs | List[Outputs]: The output data from this execution. Can be
71-
a single Outputs instance or a list of Outputs instances.
72-
68+
Outputs | List[Outputs]: The output(s) produced by the node.
69+
7370
Raises:
74-
Exception: Any exception that occurs during execution will be caught
75-
by the Runtime and reported as an error state.
71+
Exception: Any exception raised here will be caught and reported as an error state by the Runtime.
7672
"""
7773
raise NotImplementedError("execute method must be implemented by all concrete node classes")

0 commit comments

Comments
 (0)