Prefect tasks and flows for OKRunit human-in-the-loop approval gates
Project description
OKRunit Prefect Integration
Prefect tasks and flows for OKRunit human-in-the-loop approval gates.
Installation
pip install prefect-okrunit
CLI Setup
# Store your API key as a Prefect secret block
prefect block register -m prefect.blocks.system
prefect secret create okrunit-api-key --value "gk_..."
# Or set via environment variable
export OKRUNIT_API_KEY="gk_..."
CLI Usage
Run the Approval Gate Flow
# Create an approval and wait for a decision
prefect flow-run create okrunit-approval-gate \
--param title="Deploy v2.3.1 to production" \
--param priority=high \
--param description="Release includes new payment flow" \
--param timeout_seconds=1800
Deploy as a Scheduled Flow
# Deploy the approval gate flow
prefect deploy integrations/prefect/flows.py:approval_gate \
--name "production-deploy-gate" \
--pool default-agent-pool
# Trigger a deployment run
prefect deployment run okrunit-approval-gate/production-deploy-gate \
--param title="Deploy v2.3.1" \
--param priority=critical
Monitor
# List recent flow runs
prefect flow-run ls --flow-name okrunit-approval-gate
# View a specific run
prefect flow-run inspect <flow-run-id>
# Stream logs
prefect flow-run logs <flow-run-id> --follow
Platform Behavior
- Source: Automatically set to
"prefect"on all approval creation requests. - Idempotency key: Auto-generated with the format
prefect-{timestamp}-{random}(e.g.,prefect-1711100000-a3f8b2c1). - Default title: If no title is provided, defaults to
"Approval request from prefect". - Priority validation: Must be one of
low,medium,high, orcritical. - Triggers not yet implemented: The canonical
newApprovalandapprovalDecidedtriggers are not yet implemented in this integration. Only task-based actions and searches are available.
Tasks
The following tasks map to the canonical spec module types defined in integrations/shared/module-specs.md:
| Task | Canonical Module | Type | Description |
|---|---|---|---|
create_approval |
requestApproval | Action | Create a new approval request (auto-sets source: "prefect" and idempotency key) |
get_approval |
getApproval | Search | Fetch an approval request by ID |
list_approvals |
listApprovals | Search | Search/list approval requests with filters |
add_comment |
addComment | Action | Add a comment to an approval request |
Flows
| Flow | Description |
|---|---|
approval_gate |
Create approval + poll until decided (approve/reject/timeout) |
Usage in Code
from prefect_okrunit import approval_gate, create_approval, get_approval
from prefect import flow
@flow
async def deploy_pipeline():
# Gate deployment on human approval
result = await approval_gate(
title="Deploy v2.3.1 to production",
priority="high",
description="Release includes new payment flow",
timeout_seconds=1800,
)
# result contains the full approval object
print(f"Approved by {result['decided_by_name']}")
# Continue with deployment...
Individual Tasks
from prefect_okrunit import create_approval, get_approval, list_approvals, add_comment
@flow
async def my_flow():
# Create an approval
approval = await create_approval(
title="Delete old records",
priority="critical",
)
# Check status
status = await get_approval(approval["id"])
# List pending approvals
pending = await list_approvals(status="pending", priority="high")
# Add a comment
await add_comment(approval["id"], comment="Automated check passed")
Authentication
Tasks resolve the API key in this order:
- Explicit
api_keyparameter - Prefect Secret block named
okrunit-api-key
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
prefect_okrunit-0.1.0.tar.gz
(6.1 kB
view details)
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 prefect_okrunit-0.1.0.tar.gz.
File metadata
- Download URL: prefect_okrunit-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39ad65590aed6901d347a7498de1a1145a069ce864fa61afc8b18c465b9c2432
|
|
| MD5 |
9778d022723a2ebb7104c66a3ac55048
|
|
| BLAKE2b-256 |
925e2877c1aa719024158dc6afebf2c958a60fed8b2262de0079a9674e2df6c0
|
File details
Details for the file prefect_okrunit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prefect_okrunit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
687bf4ebe70bda3973961c19b741175127d0df92f0edc682ac39cd7bfa044dd3
|
|
| MD5 |
3ba51033ef7ddf835e01a9664787a712
|
|
| BLAKE2b-256 |
02d5f690865116c46b33ac1335a5c5402d862eeac8b54eae0d462460db174a82
|