Skip to main content

Python SDK for ZephFlow data processing pipelines

Project description

ZephFlow Python SDK

PyPI version Python Versions License

Python SDK for building and running ZephFlow data processing pipelines. ZephFlow provides a powerful, intuitive API for stream processing, data transformation, and event-driven architectures.

Features

  • Simple, fluent API for building data processing pipelines
  • Powerful filtering using JSONPath expressions
  • Data transformation with the eval expression language
  • Flow composition - merge and combine multiple flows
  • Error handling with assertions and error tracking
  • Multiple sink options for outputting processed data
  • Java-based engine for high performance processing

Documentation

For comprehensive documentation, tutorials, and API reference, visit: https://docs.fleak.ai/zephflow

Prerequisites

  • Python 3.8 or higher
  • Java 21 or higher (required for the processing engine)

Installation

Install ZephFlow using pip:

pip install zephflow

Quick Start

Here's a simple example to get you started with ZephFlow:

import zephflow

# Create a flow that filters and transforms events
flow = (
    zephflow.ZephFlow.start_flow()
    .filter("$.value > 10")  # Keep only events with value > 10
    .eval("""
        dict(
            id=$.id,
            doubled_value=$.value * 2,
            category=case(
                $.value < 20 => 'medium',
                _ => 'high'
            )
        )
    """)
    .stdout_sink("JSON_OBJECT")  # Output to console
)

# Process some events
events = [
    {"id": 1, "value": 5},   # Will be filtered out
    {"id": 2, "value": 15},  # Will be processed
    {"id": 3, "value": 25}   # Will be processed
]

result = flow.process(events)
print(f"Processed {result.getOutputEvents().size()} events")

Core Concepts

Filtering

Use JSONPath expressions to filter events:

flow = (
    zephflow.ZephFlow.start_flow()
    .filter("$.priority == 'high' && $.value >= 100")
)

Transformation

Transform data using the eval expression language:

flow = (
    zephflow.ZephFlow.start_flow()
    .eval("""
        dict(
            timestamp=now(),
            original_id=$.id,
            processed_value=$.value * 1.1,
            status='processed'
        )
    """)
)

Merging Flows

Combine multiple flows for complex processing logic:

high_priority = zephflow.ZephFlow.start_flow().filter("$.priority == 'high'")
large_value = zephflow.ZephFlow.start_flow().filter("$.value >= 1000")

merged = zephflow.ZephFlow.merge(high_priority, large_value)

Error Handling

Add assertions to validate data and handle errors:

flow = (
  zephflow.ZephFlow.start_flow()
  .assertion("$.required_field != null")
  .assertion("$.value >= 0")
  .eval("dict(id=$.id, validated_value=$.value)")
)

result = flow.process(events, include_error_by_step=True)
if result.getErrorByStep().size() > 0:
  print("Some events failed validation")

Examples

For more detailed examples, check out Quick Start Example - Basic filtering and transformation

Environment Variables

  • ZEPHFLOW_MAIN_JAR - Path to a custom ZephFlow JAR file (optional)
  • ZEPHFLOW_JAR_DIR - Directory for storing downloaded JAR files (optional)

Support

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About Fleak

ZephFlow is developed and maintained by Fleak Tech Inc., building the future of data processing and streaming analytics.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zephflow-0.2.2rc8.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zephflow-0.2.2rc8-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file zephflow-0.2.2rc8.tar.gz.

File metadata

  • Download URL: zephflow-0.2.2rc8.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for zephflow-0.2.2rc8.tar.gz
Algorithm Hash digest
SHA256 04d876be8172342e21782d1a0a9f1a6593267095df4e0a18597771951f611299
MD5 45be2c6686d92f175b656924ba8ca567
BLAKE2b-256 bce3f4ca7a22d9552e28793ad3a76ea1dfecce93f8d4214852f602e7682b619d

See more details on using hashes here.

File details

Details for the file zephflow-0.2.2rc8-py3-none-any.whl.

File metadata

  • Download URL: zephflow-0.2.2rc8-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for zephflow-0.2.2rc8-py3-none-any.whl
Algorithm Hash digest
SHA256 78f75024795645ee5af679176b36ccb186323c8cf9f3271bc14c48ea3435bca2
MD5 00c2b472733ec54c24df598f64e93db9
BLAKE2b-256 32d52e94122c39f6575e2c63a1c441752311d4601e74ee5a212f7877260306a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page