Skip to main content

Prefect event sensor and result storage for ZeroDB. Auto-provisioning, zero config.

Project description

zerodb-prefect

ZeroDB event sensor and result storage for Prefect.

PyPI License: MIT

Why use this?

Feature Description
Event sensor ZeroDB events trigger Prefect flows automatically
Result storage Store and retrieve flow results in ZeroDB tables
Auto-provision No signup needed -- ZeroDB project created on first use
Webhook + polling Two modes: poll event stream or receive webhooks
Credentials block Manage API keys with the ZeroDBCredentials class

Installation

pip install zerodb-prefect

Quick Start

Event Sensor

from zerodb_prefect import ZeroDBSensor

sensor = ZeroDBSensor(event_type='zerodb.vector.stored')

@sensor.on_event
def process_vector(event):
    print(f"New vector: {event.data}")
    return {'processed': event.data['vector_id']}

# Start polling for events
sensor.start()

Result Storage

from zerodb_prefect import ZeroDBBlock

block = ZeroDBBlock()

# Write results
block.write_path('/results/my-flow/run-1', {
    'status': 'complete',
    'rows_processed': 42,
})

# Read results
data = block.read_path('/results/my-flow/run-1')
print(data)  # {'status': 'complete', 'rows_processed': 42}

Credentials

from zerodb_prefect import ZeroDBCredentials

creds = ZeroDBCredentials(api_key='zdb_...', project_id='proj_...')
client = creds.get_client()  # Authenticated requests.Session

API Reference

ZeroDBSensor(event_type, **kwargs)

Poll ZeroDB events and trigger handlers.

Param Default Description
event_type required Event type to listen for
api_key auto ZeroDB API key
project_id auto ZeroDB project ID
poll_interval 5 Seconds between polls
batch_size 100 Max events per poll

Methods:

Method Description
@sensor.on_event Decorator to register handler
sensor.add_handler(func) Register handler (non-decorator)
sensor.poll() Manually poll for events
sensor.start() Start polling in background thread
sensor.stop() Stop polling
sensor.process_webhook(payload) Process webhook payload

ZeroDBBlock(**kwargs)

Store and retrieve Prefect flow results.

Method Description
write_path(path, content) Store content keyed by path
read_path(path) Read content by path
exists(path) Check if path exists
delete_path(path) Delete stored result
list_paths(prefix=None) List stored paths

ZeroDBCredentials(**kwargs)

Manage ZeroDB API credentials.

Method Description
get_client() Return authenticated requests.Session
get_headers() Return auth headers as dict

Configuration

Environment Variables

export ZERODB_API_KEY="your-api-key"
export ZERODB_PROJECT_ID="your-project-id"
# Optional
export ZERODB_BASE_URL="https://api.ainative.studio"

Auto-Provisioning

If no credentials are found, zerodb-prefect automatically creates a free ZeroDB project on first use. Credentials are saved to ~/.zerodb/config.json.

Use Cases

ML Pipeline Results

from zerodb_prefect import ZeroDBBlock

block = ZeroDBBlock()

# After training
block.write_path('/models/v2/metrics', {
    'accuracy': 0.94,
    'f1': 0.91,
    'training_time': 3600,
})

# In evaluation flow
metrics = block.read_path('/models/v2/metrics')

Event-Driven ETL

from zerodb_prefect import ZeroDBSensor, ZeroDBBlock

sensor = ZeroDBSensor(event_type='zerodb.file.uploaded')
block = ZeroDBBlock()

@sensor.on_event
def etl_pipeline(event):
    file_path = event.data.get('path')
    block.write_path(f'/etl/processed/{file_path}', {
        'source': file_path,
        'status': 'processed',
    })

sensor.start()

Powered by ZeroDB + AINative

Free database for AI agents. Auto-provisions in 200ms. No signup required.

Get started | Documentation | ZeroDB | GitHub

License

MIT

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

zerodb_prefect-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

zerodb_prefect-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file zerodb_prefect-0.1.0.tar.gz.

File metadata

  • Download URL: zerodb_prefect-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for zerodb_prefect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca5aed5f19a95de144c8fe351f8401ad8778e6e85a73b50ec35aedd4de00f58a
MD5 a65fea40dd9934d9ef26141af86c9981
BLAKE2b-256 7da39a81cc1a7639a0cd7cd955a1132a8732ad3a7f4a718752115a7255eff75f

See more details on using hashes here.

File details

Details for the file zerodb_prefect-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zerodb_prefect-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for zerodb_prefect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0a32176899cc9d824adf82f1464a6983afa4150552879b06004aabbb1499c3a
MD5 9e0853ad8fdda5be4c3314bafb7ec0b1
BLAKE2b-256 1897da516c65df63bd92d82094c422eac1537e8bf850dea731d1e23a71a66f61

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