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.post1.tar.gz (14.3 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.post1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zephflow-0.2.2rc8.post1.tar.gz
  • Upload date:
  • Size: 14.3 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.post1.tar.gz
Algorithm Hash digest
SHA256 66d0d38edf9be4947a04008a5e32b3537a6ea15935a57fc002e5f046ee3c3a65
MD5 6652b3ff027ea03a4ee79e6a2cc01f06
BLAKE2b-256 5e5b515eed7c3d0f2394bb334fc347751b8749b584ee18f57f8eee4b494700d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zephflow-0.2.2rc8.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 0540d7ba607ebb47710a8c05bd378518dec629bf6addb75a9177b36488254f22
MD5 f3e5a7803642160cd4e1b5de24ffa7c4
BLAKE2b-256 51fc9f63f006ce03a58eb7572826ff09ade6f6aad5fc715b3f8c2f4c06d4a35c

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