File size: 1,297 Bytes
b98ffbb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
from dora import DoraStatus
class Operator:
"""
Template docstring
"""
def __init__(self):
"""Called on initialisation"""
pass
def on_event(
self,
dora_event,
send_output,
) -> DoraStatus:
"""
Args:
dora_event: Event containing an `id`, `data` and `metadata`.
send_output Callable[[str, bytes | pa.Array, Optional[dict]], None]:
Function for sending output to the dataflow:
- First argument is the `output_id`
- Second argument is the data as either bytes or `pa.Array`
- Third argument is dora metadata dict
e.g.: `send_output("bbox", pa.array([100], type=pa.uint8()), dora_event["metadata"])`
Returns:
DoraStatus:
CONTINUE means that the operator will
keep listening for further inputs.
STOP means that the operator stop listening for inputs.
"""
if dora_event["type"] == "INPUT":
print(
f"Received input {dora_event['id']}, with data: {dora_event['value']}"
)
return DoraStatus.CONTINUE
def __del__(self):
"""Called before being deleted"""
pass
|