h1flow.h1step_containable

Module Contents

Classes

NodeContainable

Type of an instance to be added to a graph as a node must be the subclass of NodeContainable.

class h1flow.h1step_containable.NodeContainable

Bases: h1st.trust.trustable.Trustable

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.core 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(self) Node
property graph(self) Graph
call(self, command: str, inputs: Dict) Dict

Will be invoked by a node when executing a graph.

Subclass of NodeContainable may override the call() function:

import h1st.core 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 dict