towhee.operator.base.Operator

class towhee.operator.base.Operator[source]

Bases: ABC

Operator base class, implements __init__ and __call__,

Examples

class AddOperator(Operator):
def __init__(self, factor: int):

self._factor = factor

def __call__(self, num) -> NamedTuple(“Outputs”, [(“sum”, int)]):

Outputs = NamedTuple(“Outputs”, [(“sum”, int)]) return Outputs(self._factor + num)

Methods

Attributes

flag

key

shared_type

abstract __call__()[source]

The framework calls __call__ function repeatedly for every input data.

Args:

Returns:

Raises:

An exception during __init__ can terminate the graph run.

abstract __init__()[source]

Init operator, before a graph starts, the framework will call Operator __init__ function.

Args:

Raises:

An exception during __init__ can terminate the graph run.