towhee.hub.builtin.operators.runas_op.runas_op

class towhee.hub.builtin.operators.runas_op.runas_op(func: Callable)[source]

Bases: object

Convert a user-defined function as an operator and execute.

Parameters:

func (Callable) – The user-defined function.

Examples:

>>> from towhee.functional import DataCollection
>>> from towhee.functional.entity import Entity
>>> entities = [Entity(a=i, b=i) for i in range(5)]
>>> dc = DataCollection(entities)
>>> res = dc.runas_op['a', 'b'](func=lambda x: x - 1).to_list()
>>> res[0].a == res[0].b + 1
True

Methods

Attributes

metainfo

__init__(func: Callable)[source]

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