Create simple event-driven, distributed data pipelines in Python
Project description
Qanat
Qanat: Create simple event-driven, distributed data pipelines in Python.
Qanat is a lightweight tool for setting up event-driven, distributed data pipelines with ease. It lets you link together components into a type-checked, decoupled pipeline, with inter-process communication handled automatically through MQTT (in the future RabbitMQ?) and serialization handled through JSON.
Usage Example
from qanat import QanatPipeline
from dataclasses import dataclass
from typing import List
@dataclass
class Frame:
image: bytes
timestamp: str
@dataclass
class Detection:
type: str
confidence: float
@dataclass
class DetectionResults:
objects: List[Detection]
frame_timestamp: str
# Initialize the pipeline with the MQTT broker connection
pipeline = QanatPipeline(broker="mqtt://broker.hivemq.com:1883")
@pipeline.component(output="qanat-demo/frames/raw")
def frame_producer() -> Frame:
"""
Simulates producing a frame and its metadata.
"""
image_data = b'some_image_data' # Replace with actual image data
return Frame(image=image_data, timestamp="2021-07-01T00:00:00Z")
@pipeline.component(
input="qanat-demo/frames/raw",
output="qanat-demo/detections/results"
)
def detector(frame: Frame) -> DetectionResults:
"""
Processes a frame and detects objects, outputting detection results.
"""
detected_objects = [Detection(type="smoke", confidence=0.98)]
return DetectionResults(objects=detected_objects, frame_timestamp=frame.timestamp)
@pipeline.component(input="qanat-demo/detections/results")
def result_publisher(detection_results: DetectionResults):
"""
Publishes the detection results.
"""
print(f"Publishing results: {detection_results}")
# Start the event loop for testing and demonstration
if __name__ == "__main__":
# For demo or testing purposes, this runs all components in the pipeline
pipeline.start_event_loop() # Blocks until the event loop terminates
# In real-world distributed usage, you would start three separate processes,
# one for each component, e.g.:
# frame_producer.start() # Blocks until this specific component terminates
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyqanat-0.0.0.tar.gz.
File metadata
- Download URL: pyqanat-0.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b4121f792847d293622c3fba58bcb26937ddc1c9b39ed8318d2be92665901e3
|
|
| MD5 |
1cf766009ccc932a795f7b157325cb29
|
|
| BLAKE2b-256 |
4544f3a051697902b88f6407ac4ccd13c13a78468c7a9370a6bbd1c8d54956a5
|
File details
Details for the file pyqanat-0.0.0-py3-none-any.whl.
File metadata
- Download URL: pyqanat-0.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab437df6f6ce2aa9785fc90acb296eb05a43d6431a3ac43560a1c78cfa95ad40
|
|
| MD5 |
a587b5596b5b3cd1ec70a6e418466b66
|
|
| BLAKE2b-256 |
c1985e04804916af2e8b4c54b83e40a667b9fe0d78709b2ff54e32c19416a997
|