Dagster resource, ops, and sensors for OKRunit human-in-the-loop approval gates
Project description
OKRunit Dagster Integration
Dagster resource, ops, and sensors for OKRunit human-in-the-loop approval gates.
Installation
pip install dagster-okrunit
CLI Quickstart
# Start the Dagster dev server with OKRunit configured
dagster dev -m dagster_okrunit
# Launch the example approval gate job
dagster job launch -j deploy_with_approval \
--config '{"ops": {"approval_gate_op": {"config": {"title": "Deploy v2.3.1", "priority": "high"}}}}'
# Start the approval decision sensor
dagster sensor start approval_decided_sensor
# Check sensor status
dagster sensor list
# View job runs
dagster run list
# Tail logs for a run
dagster run logs <run-id>
Components
Resource
| Resource | Description |
|---|---|
OKRunitResource |
Configurable resource for OKRunit API calls |
Ops
| Op | Canonical Spec Module | Type | Description |
|---|---|---|---|
create_approval_op |
requestApproval | Action | Create a new approval request (auto-sets source: "dagster" and idempotency key) |
get_approval_op |
getApproval | Search | Fetch an approval request by ID |
list_approvals_op |
listApprovals | Search | Search and list approval requests with filters |
approval_gate_op |
requestApproval | Action | Create approval + poll until decided (blocks the op) |
add_comment_op |
addComment | Action | Add a comment to an approval request |
Sensors
| Sensor | Description |
|---|---|
approval_decided_sensor |
Triggers runs when approvals are approved or rejected |
Jobs
| Job | Description |
|---|---|
deploy_with_approval |
Example job gating on human approval |
Usage in Definitions
from dagster import Definitions
from dagster_okrunit import (
OKRunitResource,
approval_gate_op,
approval_decided_sensor,
deploy_with_approval,
)
defs = Definitions(
resources={
"okrunit": OKRunitResource(
api_key="gk_...",
api_url="https://app.okrunit.com",
),
},
jobs=[deploy_with_approval],
sensors=[approval_decided_sensor],
)
Custom Jobs
from dagster import job, op
from dagster_okrunit import approval_gate_op, OKRunitResource
@op
def run_deployment(context, approval: dict):
context.log.info(f"Deploying! Approved by {approval.get('decided_by_name')}")
@job(resource_defs={"okrunit": OKRunitResource(api_key="gk_...", api_url="https://app.okrunit.com")})
def my_deploy_pipeline():
approval = approval_gate_op()
run_deployment(approval)
Integration Details
- Source: All approval creation ops automatically set
sourceto"dagster". - Idempotency key format:
dagster-{timestamp}-{random}— auto-generated on everycreate_approvalcall. - Default title: If no title is provided, defaults to
"Approval request from dagster". - Priority validation: Must be one of
low,medium,high, orcritical. - newApproval trigger: Not yet implemented as a Dagster sensor. The
approval_decided_sensorcovers theapprovalDecidedtrigger only.
Environment Variables
Instead of hardcoding the API key, use Dagster's env var support:
from dagster import EnvVar
defs = Definitions(
resources={
"okrunit": OKRunitResource(
api_key=EnvVar("OKRUNIT_API_KEY"),
api_url=EnvVar("OKRUNIT_API_URL"),
),
},
)
export OKRUNIT_API_KEY="gk_..."
export OKRUNIT_API_URL="https://app.okrunit.com"
dagster dev
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
dagster_okrunit-0.1.0.tar.gz
(5.2 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 dagster_okrunit-0.1.0.tar.gz.
File metadata
- Download URL: dagster_okrunit-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216b04cf5d16ed7eb6ccc701eb19ae9fe36fab1fdd957a9e78a0535469e3f427
|
|
| MD5 |
330e1ed71abf711b383c48630eaf14e0
|
|
| BLAKE2b-256 |
0ec50c770f9cfe1e18dcf94cff3c03cf047843fc983a7cf5099783d1186eaebd
|
File details
Details for the file dagster_okrunit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dagster_okrunit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 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 |
738e8bdc36fb63310397a2004cc8e0b7bf84a196b55a39cb67a104563866404f
|
|
| MD5 |
5b39800656225d980a7defb527b41767
|
|
| BLAKE2b-256 |
ad171507cb63485466d0aa192b6d0ada75fb3684512bb0cd938e0545880abd75
|