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()

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

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

test_output(inputs: Any = None, schema=None)[source]

Subclass will implement this function to verify its output schema

Parameters

inputs – subclass will use this input data to call a specific function to get the result

Schema

the schema to verify if the result conforming with