tethys.core.nodes.node_zero

Module Contents

class tethys.core.nodes.node_zero.ZeroNode(operator: Union[OperatorBase, Callable] = ..., **kwargs)[source]

Bases: tethys.core.regobjs.regobj_zero.ZeroRegistrableObject, tethys.core.nodes.node_base.NodeBase

The Node entity class of the Zero generation. The ZeroNode is a unit that process data.

Example:
node1 = ZeroNode(
    operator=PythonFunctionOperator(some_fn)
)
node1.process(stream)
node1.send(some_data)
Parameters

operator (OperatorBase) – Operator instance which has a process method and which the Node executes.

IN = <in>[source]

Virtual input gate node (CONSTANT)

OUT = <out>[source]

Virtual output gate node (CONSTANT)

CLASS_PATH = /nodes/[source]

ZeroNode instances collection path in the repository

FIELDS_SCHEMA[source]

ZeroNode fields validators

process(self, stream: Union['ZeroStream', str], wait_timeout: Union[int, float] = None, **kwargs)[source]

Read the stream and execute the operator for the stream’s data packet.

The node will stop the process if the stream closed or the stream’s session closed. If operator return value (!= None) then the node will send the value to the connected nodes (forward direction)

Parameters
  • stream (Union[ZeroStream, str]) – Stream with which the node will work.

  • wait_timeout (float) – pass to the stream.read() method

send(self, data_packet: Any, session: ZeroSession, many: bool = False, **kwargs)[source]

Send data_packet to the connected nodes through streams (forward direction) in the session context.

Parameters
  • data_packet – any data object or list of the data objects (with many=True)

  • session (ZeroSession) – ZeroSession instance

  • many (bool) – if many=True then data_packet’s elements will be sent one-by-one.