Provides the interfaces of writing Python User Defined Functions and Sinks for NumaFlow.
Project description
Python SDK for Numaflow
This SDK provides the interface for writing UDFs and UDSinks in Python.
Implement a User Defined Function (UDF)
from pynumaflow.function import Message, Messages, HTTPHandler
import random
def my_handler(key: bytes, value: bytes, _) -> Messages:
messages = Messages()
if random.randint(0, 10) % 2 == 0:
messages.append(Message.to_all(value))
else:
messages.append(Message.to_drop())
return messages
if __name__ == "__main__":
handler = HTTPHandler(my_handler)
handler.start()
Sample Image
A sample UDF Dockerfile is provided under examples.
Implement a User Defined Sink (UDSink)
from typing import List
from pynumaflow.sink import Message, Responses, Response, HTTPSinkHandler
def udsink_handler(messages: List[Message], __) -> Responses:
responses = Responses()
for msg in messages:
responses.append(Response.as_success(msg.id))
return responses
if __name__ == "__main__":
handler = HTTPSinkHandler(udsink_handler)
handler.start()
Sample Image
A sample UDSink Dockerfile is provided under examples.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pynumaflow-0.1.1.tar.gz
(13.0 kB
view hashes)
Built Distribution
pynumaflow-0.1.1-py3-none-any.whl
(18.7 kB
view hashes)
Close
Hashes for pynumaflow-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bc090a584d03cc029cda58b5f540c08e521096bf74b2fc10a88ff0ab17a4b09 |
|
MD5 | b13ec99c021ab3a8582bacd21a262fd4 |
|
BLAKE2b-256 | 25736927aa97fc72717103e8a5f97b338f020fdbd4ee0096c3c74cac5050d01a |