Python SDK and CLI for authoring, packaging, and publishing Pegasus workflows.
Project description
Pegasus Workflows SDK
pegasus-workflows-sdk is the Python SDK and CLI for authoring, packaging, and
publishing Pegasus workflows — Temporal workflows that automate
cross-domain operations (move lifecycle, billing follow-ups, dispatch
decisions) against the Pegasus public API.
Phase 1 ships the developer flow: write a workflow locally, run it against a Dockerized Temporal, package it, and upload it. There is no server-side execution yet — the API stores the artifact and lists it.
Install
pip install pegasus-workflows-sdk
This installs the pegasus-workflows CLI. Python 3.11+ is required. Pin the
version in your project's requirements for reproducible builds, e.g.
pegasus-workflows-sdk==0.1.0.
Interim / unreleased install (git)
The repository is public, so you can install straight from a tagged commit without waiting for a PyPI release — useful for an unreleased fix, or before the first PyPI publish lands:
pip install "pegasus-workflows-sdk @ git+https://github.com/DolasDev/pegasus@sdk-python-v0.1.0#subdirectory=packages/workflows-sdk-python"
Swap the @sdk-python-v0.1.0 tag for @main to track the latest unreleased
SDK. This clones the whole monorepo to build one subdirectory, so prefer the
PyPI install for everyday use.
Quick start
pegasus-workflows init demo
cd demo
pegasus-workflows test demo
pegasus-workflows package
pegasus-workflows push --token=vnd_... --base-url=http://localhost:3000
Authoring
Import the Temporal authoring primitives from pegasus_workflows and mark your
workflow class with @pegasus_workflow:
from datetime import timedelta
from pegasus_workflows import activity, pegasus_workflow, workflow
@activity.defn
async def greet(name: str) -> str:
return f"Hello, {name}!"
@pegasus_workflow(name="demo", version="0.1.0")
class HelloWorkflow:
@workflow.run
async def run(self, name: str = "world") -> str:
return await workflow.execute_activity(
greet, name, start_to_close_timeout=timedelta(seconds=10)
)
@pegasus_workflow wraps temporalio.workflow.defn and records the
(name, version) used by the manifest.
Input contract: how run() receives its argument
Your run() method receives a single positional argument whose shape depends on how the workflow
was started:
1. Trigger-fired (domain-event trigger) — the dispatcher passes the full event envelope:
{
"domainEventId": "<uuid>",
"eventType": "quote.accepted", # the event type that fired the trigger
"occurredAt": "<ISO-8601>",
"payload": {"quoteId": "<id>", "moveId": "<id>"} # entity ids, camelCase
}
Read entity ids from arg["payload"]["quoteId"] etc. The payload is a pointer, not a full snapshot
— always re-fetch authoritative state from the Pegasus API using those ids rather than relying on the
payload alone.
2. Manual run — POST /api/v1/workflows/:id/run passes:
{"executionId": "<uuid>", "input": <user-supplied dict>}
Read your business data from arg["input"] (e.g. arg["input"]["quote_id"]).
3. CLI test — pegasus-workflows test <name> passes a raw string for local-dev parity.
Your run() should handle all three shapes. A module-level helper (not a method) is the recommended
pattern — it stays unit-testable without a Temporal worker context:
def _resolve_quote_id(payload: dict | str) -> str:
if isinstance(payload, str):
return payload
event_payload = payload.get("payload") if isinstance(payload, dict) else None
if isinstance(event_payload, dict) and event_payload.get("quoteId"):
return str(event_payload["quoteId"])
inner = payload.get("input") if isinstance(payload, dict) else None
if isinstance(inner, dict) and inner.get("quote_id"):
return str(inner["quote_id"])
return "quote-unknown"
The manifest — pegasus-workflows.toml
Every project has a pegasus-workflows.toml at its root. Each [[workflow]]
table is packaged into its own artifact and uploaded as a distinct
(name, version) row:
[[workflow]]
name = "demo" # ^[a-z0-9][a-z0-9_-]{0,63}$
version = "0.1.0" # semver
entry_points = ["demo.workflow:HelloWorkflow"] # non-empty
source_dir = "demo" # optional, defaults to name
description = "..." # optional
These rules mirror the server's ManifestSchema exactly, so package/push
fail fast locally before any HTTP call.
CLI
| Command | What it does |
|---|---|
pegasus-workflows init <name> |
Scaffold a new workflow project. |
pegasus-workflows package |
Zip each declared workflow into dist/<name>-<version>.zip. |
pegasus-workflows push --token=<vnd_…> [--base-url=…] |
Package, then upload-url → S3 PUT → finalize. |
pegasus-workflows test <workflow> |
Start local Temporal and run the workflow with a stub input. |
pegasus-workflows integration-config validate <id> [-C <dir>] |
Dry-run the publish gate for a config (no write). |
pegasus-workflows integration-config publish <id> [-C <dir>] |
Gate then publish a new config version. |
pegasus-workflows integration-config pull <id> [-C <dir>] [--stdout] |
Fetch the active config; write the editable surface to disk. |
pegasus-workflows integration-config versions <id> |
List the config version history (newest first). |
pegasus-workflows integration-config rollback <id> <version> |
Re-publish a prior version (re-runs the gate). |
push reads the token from --token or the PEGASUS_WORKFLOW_TOKEN
environment variable. The token is a vnd_* Pegasus API key whose service
account holds the workflow_developer role.
Authoring an integration-validator config
The integration-config group manages an integration's declarative mapping +
rules (the DB-backed authoring surface; see
apps/api/src/handlers/integration-validation/config.ts). The editable surface
lives as three JSON files in a working directory (-C, default .):
mapping.json, rules.json, corpus.json. The round-trip is pull → edit →
validate → publish:
pegasus-workflows integration-config pull weichert -C ./weichert
# …edit mapping.json / rules.json…
pegasus-workflows integration-config validate weichert -C ./weichert
pegasus-workflows integration-config publish weichert -C ./weichert
publish/rollback require the token's tenant to be the platform tenant to
write GLOBAL (visibility is derived server-side) and to carry the
PublishIntegrationConfig action; they are gated by the server's
INTEGRATION_CONFIG_PUBLISH_ENABLED switch. validate and pull are
read-level and never gated.
Local Temporal
pegasus-workflows test needs a Temporal server. The repo root ships
docker-compose.temporal.yml (Temporal server + Temporal UI on 7233 / 8080)
purely as a local-dev aid — no production connection. test runs
docker compose -f docker-compose.temporal.yml up -d automatically if Temporal
is not already reachable on 127.0.0.1:7233. To start it by hand:
docker compose -f docker-compose.temporal.yml up -d
The Temporal Web UI is then at http://localhost:8080.
Release
The SDK is published to PyPI by .github/workflows/release-sdk-python.yml on
sdk-python-v* tags via PyPI trusted publishing (OIDC — no API token).
To cut a release:
- Bump
versioninpyproject.tomland commit it onmain. - Tag the release commit and push the tag, e.g.
git tag sdk-python-v0.1.0 && git push origin sdk-python-v0.1.0.
The workflow then lints, audits, tests, builds, and uploads the sdist + wheel.
One-time setup (before the first release): a PyPI project owner must add a
pending publisher at pegasus-workflows-sdk → Publishing → owner DolasDev,
repo pegasus, workflow release-sdk-python.yml, environment pypi. Until
that exists the publish job fails at the upload step, and tenants must use the
git install above.
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 pegasus_workflows_sdk-0.1.0.tar.gz.
File metadata
- Download URL: pegasus_workflows_sdk-0.1.0.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7be31c3fd85a5844c4244ae59d3f95f660b0d8e0627c48facaac5c38bb9dd435
|
|
| MD5 |
4502e23deae1e68ad3a7df170264033e
|
|
| BLAKE2b-256 |
a3852598cc1a957b451b5876f46b5de865f8f1ed7f605de5d45c95189a665c40
|
Provenance
The following attestation bundles were made for pegasus_workflows_sdk-0.1.0.tar.gz:
Publisher:
release-sdk-python.yml on DolasDev/pegasus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pegasus_workflows_sdk-0.1.0.tar.gz -
Subject digest:
7be31c3fd85a5844c4244ae59d3f95f660b0d8e0627c48facaac5c38bb9dd435 - Sigstore transparency entry: 1943625331
- Sigstore integration time:
-
Permalink:
DolasDev/pegasus@c475510410e2fb65b2b0b926249ac669a55f1943 -
Branch / Tag:
refs/tags/sdk-python-v0.1.0 - Owner: https://github.com/DolasDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk-python.yml@c475510410e2fb65b2b0b926249ac669a55f1943 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pegasus_workflows_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pegasus_workflows_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78011793b634fccd7c022ef9dc010ec4457bd257b8c515369631dcb160d7bd23
|
|
| MD5 |
7bc4a45bd9401f28d40caf677fc8e059
|
|
| BLAKE2b-256 |
0992a40f1b1ed8cc8da9f0b2765de89547bf63e0865b68251d997f0fcbfca05f
|
Provenance
The following attestation bundles were made for pegasus_workflows_sdk-0.1.0-py3-none-any.whl:
Publisher:
release-sdk-python.yml on DolasDev/pegasus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pegasus_workflows_sdk-0.1.0-py3-none-any.whl -
Subject digest:
78011793b634fccd7c022ef9dc010ec4457bd257b8c515369631dcb160d7bd23 - Sigstore transparency entry: 1943625442
- Sigstore integration time:
-
Permalink:
DolasDev/pegasus@c475510410e2fb65b2b0b926249ac669a55f1943 -
Branch / Tag:
refs/tags/sdk-python-v0.1.0 - Owner: https://github.com/DolasDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk-python.yml@c475510410e2fb65b2b0b926249ac669a55f1943 -
Trigger Event:
push
-
Statement type: