h1st.core.node_containable module¶
-
class
h1st.core.node_containable.
NodeContainable
[source]¶ Bases:
object
Type of an instance to be added to a graph as a node must be the subclass of NodeContainable. .. code-block:: python
- caption
Example of using NodeContainable
import h1st as h1
- class GenerateWindowEvents(h1.NodeContainable):
- def call(self, command, inputs):
…
- class MyGraph(h1.Graph):
- def __init__(self):
- self
.start() .add(GenerateWindowEvents()) .end()
-
property
node
¶
-
property
graph
¶
-
call
(command: str, inputs: Dict) → Dict[source]¶ Will be invoked by a node when executing a graph.
- Subclass of NodeContainable may override the call() function:
import h1st as h1
- class MyClass(h1.NodeContainable)
- def call(self, command, inputs):
…
Or subclass may implement necessary functions which required for graph execution flows During executing, the function with name = value of command will be invoked
- class MyClass(h1.NodeContainable)
- def predict(self, inputs):
# this function will be invoked if a graph execution is for predict: # graph.predict(…) # or graph.execute(command=’predict’, input_data=…) …
- Parameters
command – to know which graph’s execution flow (predict, train, …) it is involving
- Inputs
input data to proceed accordingly to the flow
- Returns
result as a dictionary