Dead simple pipeline monitoring. Know when your pipelines die.
Project description
Deadpipe Python SDK
Dead simple pipeline monitoring. Know when your pipelines die.
Installation
pip install deadpipe
Quick Start
Option 1: Decorator (Recommended)
from deadpipe import Deadpipe
dp = Deadpipe("your-api-key")
@dp.heartbeat("daily-sales-etl")
def run_pipeline():
# Your pipeline code here
process_data()
return {"records_processed": 1500} # Optional: track records
# That's it! Deadpipe will ping on success or failure.
run_pipeline()
Option 2: Context Manager
from deadpipe import Deadpipe
dp = Deadpipe("your-api-key")
with dp.pipeline("hourly-sync"):
# Your code here
sync_data()
Option 3: Manual Ping
from deadpipe import Deadpipe
dp = Deadpipe("your-api-key")
try:
run_my_job()
dp.ping("my-job", status="success", records_processed=1000)
except Exception as e:
dp.ping("my-job", status="failed")
raise
Option 4: Environment Variable
Set DEADPIPE_API_KEY and use module-level functions:
import deadpipe
@deadpipe.heartbeat("my-pipeline")
def my_job():
pass
Async Support (FastAPI, aiohttp, asyncio)
For async applications, install with async extras:
pip install deadpipe[async]
Async Decorator
from deadpipe import AsyncDeadpipe
dp = AsyncDeadpipe("your-api-key")
@dp.heartbeat("async-pipeline")
async def my_async_job():
await fetch_data()
return {"records_processed": 500}
Async Context Manager
async with dp.pipeline("async-etl"):
await process_async_data()
Async Manual Ping
await dp.ping("my-job", status="success")
FastAPI Example
from fastapi import FastAPI
from deadpipe import AsyncDeadpipe
app = FastAPI()
dp = AsyncDeadpipe() # Uses DEADPIPE_API_KEY env var
@app.on_event("startup")
async def startup():
# Optionally track app startup
await dp.ping("fastapi-app", status="success")
@app.on_event("shutdown")
async def shutdown():
await dp.close() # Clean up HTTP session
@app.post("/process")
@dp.heartbeat("data-processor")
async def process_data():
result = await heavy_processing()
return {"records_processed": len(result)}
Session Management
AsyncDeadpipe uses connection pooling via aiohttp.ClientSession. For long-running apps, use as a context manager or call close():
# Option 1: Context manager (auto-closes)
async with AsyncDeadpipe("your-key") as dp:
await dp.ping("my-pipeline")
# Option 2: Manual close
dp = AsyncDeadpipe("your-key")
try:
await dp.ping("my-pipeline")
finally:
await dp.close()
Airflow Integration
from deadpipe import Deadpipe
dp = Deadpipe(api_key=Variable.get("DEADPIPE_API_KEY"))
@dp.heartbeat("{{ dag.dag_id }}")
def my_task():
...
Or add to the end of any task:
from deadpipe import ping
def my_task():
# ... your code ...
ping("daily-etl", status="success")
dbt Integration
Add to your dbt_project.yml on-run-end hook:
on-run-end:
- "{{ deadpipe_heartbeat('dbt-run') }}"
Or call from Python:
# In your dbt runner script
from deadpipe import Deadpipe
dp = Deadpipe("your-api-key")
with dp.pipeline("dbt-daily"):
subprocess.run(["dbt", "run"], check=True)
API Reference
Deadpipe(api_key, base_url, timeout)
Create a client instance.
api_key: Your API key (or setDEADPIPE_API_KEYenv var)base_url: Override for self-hosted (default:https://www.deadpipe.com/api/v1)timeout: Request timeout in seconds (default: 10)
dp.ping(pipeline_id, status, duration_ms, records_processed, app_name)
Send a heartbeat.
pipeline_id: Unique identifier for this pipelinestatus:"success"or"failed"duration_ms: How long the run took (optional)records_processed: Number of records (optional)app_name: Group pipelines under an app (optional)
@dp.heartbeat(pipeline_id, app_name, on_error)
Decorator that auto-sends heartbeats.
on_error: What to do on exception:"ping"(default): Send failed heartbeat, then re-raise"raise": Re-raise without heartbeat"ignore": Send success heartbeat anyway
with dp.pipeline(pipeline_id, app_name)
Context manager for heartbeats.
AsyncDeadpipe(api_key, base_url, timeout)
Async client with the same API as Deadpipe, but all methods are async:
await dp.ping(...)- Async heartbeat@dp.heartbeat(...)- Decorator for async functionsasync with dp.pipeline(...)- Async context managerawait dp.run(pipeline_id, fn, *args)- Run async function with heartbeatawait dp.close()- Close HTTP sessionasync with AsyncDeadpipe(...) as dp:- Auto-close on exit
Dependencies
- Sync: Zero dependencies (uses Python standard library only)
- Async: Requires
aiohttp(install withpip install deadpipe[async])
License
Deadpipe SDK License - see LICENSE file.
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 deadpipe-0.1.2.tar.gz.
File metadata
- Download URL: deadpipe-0.1.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8dca8ccaabce6c6211950788a986eb1b7b8f3db143a5d6b14bd6bae4855a5a1
|
|
| MD5 |
63862dbbea8c95fab2e3fb79a451e1cd
|
|
| BLAKE2b-256 |
8abc2d013d81876424cef3c57df2d8ecefcee120a9ae0a74d58904eaf3557fa2
|
File details
Details for the file deadpipe-0.1.2-py3-none-any.whl.
File metadata
- Download URL: deadpipe-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc6b51f32d3f1a5579d71953ccb5be8a949babcf9e0292ed2b4772139bc35d6b
|
|
| MD5 |
2e1c6e7931fb3218a97d923af0510f15
|
|
| BLAKE2b-256 |
2de4130bfc890d443a7ae1ca977c07a984b982ccee30587999a932a80a969f71
|