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.2rc9.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.2rc9-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zephflow-0.2.2rc9.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.2rc9.tar.gz
Algorithm Hash digest
SHA256 cdd90991fdb178720f7f00bf3cfe4a57050a1a4716ba7aaf306ca7c97f3a55ca
MD5 f263dd7aa32a4d787d4d040cbd71f7e1
BLAKE2b-256 bffab6181e3480dac43a9eb034c94cebc9467db23161bd037cdf9030239dc12c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zephflow-0.2.2rc9-py3-none-any.whl
  • Upload date:
  • Size: 14.8 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.2rc9-py3-none-any.whl
Algorithm Hash digest
SHA256 68f7eb56c9b5015d0b283c25bf8d9c482280c30431a67fa01682efc39190002b
MD5 4bf02ee2b47d689dca4b95dc670421b2
BLAKE2b-256 d285a0c4855d6bef6212f5164757d29009b82fa8f5e81c49f7fa380799fbc1d7

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