Skip to main content

Python runtime and authoring SDK for Gust DAGs, including parser and task invoker

Project description

gust_py

Python runtime/package for Gust DAG authoring, parsing, and task execution.

What This Project Provides

  • A Python authoring API:
    • Dag
    • @task(...)
    • log(...)
    • runtime calls: get_task_by_name_run(...), get_secret_by_name(...)
  • A parser that converts Python DAG files into a stable JSON spec.
  • A task invoker to execute one task from a DAG file.
  • A run-completion invoker to execute a DAG callback (run done).

Requirements

  • Python >=3.10
  • uv

Install

uv sync --dev

DAG Authoring API

from gust import Dag, task, get_task_by_name_run, get_secret_by_name, log


class MyDag(Dag):
    def __init__(self):
        super().__init__(schedule="daily", on_finished_callback="done_my_run")

    @task(downstream=("prepare",), save=True)
    def hello(self, ctx):
        run_id = ctx["run_id"]
        prepare_run = get_task_by_name_run("prepare", run_id)
        secret = get_secret_by_name("SUPER_SECRET")
        log(f"prepare={prepare_run}, secret_loaded={bool(secret)}")
        return {"ok": True}

    def done_my_run(self, status, run):
        log(f"run {run['run_id']} finished with status={status}", level="info")

Runtime Messaging Protocol

gust runtime messages use a framed protocol on stdio:

  1. 4-byte big-endian frame length
  2. UTF-8 JSON payload

Helpers:

  • send_frame(payload) writes one frame to stdout.
  • _read_frame() reads one frame from stdin.

Call helpers emit messages and wait for a response:

  • get_task_by_name_run(name, run_id) emits:
    • {"type": "call", "op": "get_task_by_name_run", "run_id": run_id, "name": name}
  • get_secret_by_name(name) emits:
    • {"type": "call", "op": "get_secret_by_name", "name": name}

Logging helper emits:

  • log(msg, level="info"):
    • {"type": "log", "level": level, "msg": msg}

CLI

The package exposes a gust CLI.

Parse DAGs

gust parse --file path/to/dag_file.py

Output is JSON (printed to stdout), one list entry per discovered DAG class.

Run a Task

gust task run \
  --file path/to/dag_file.py \
  --dag MyDag \
  --task hello \
  --ctx-json '{"run_id":"123"}'

Output is a framed JSON payload:

  • Success:
    • {"type":"result","ok":true,"data":{"value": ...}}
  • Error:
    • {"type":"result","ok":false,"error":{"message":"...","type":"...","details":"..."}}

Run Completion Callback

gust run done \
  --file path/to/dag_file.py \
  --dag MyDag \
  --fn-name done_my_run \
  --status ok \
  --run-id 123

Behavior:

  • On success: no payload output.
  • On failure: process exits with code 1.

Development

Run tests:

uv run pytest -q

Run lint:

uv run ruff check .

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

gust_py-0.1.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

gust_py-0.1.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file gust_py-0.1.2.tar.gz.

File metadata

  • Download URL: gust_py-0.1.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gust_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4aefec7e6d35d334f6df5aa4d2bd950dfe4bd665e5c6b6bf2d17dc4af5780eea
MD5 5b3b0648b1d914739cf52ebb8f98a54c
BLAKE2b-256 8693eb51edc52c56e367f5d1c9613e349bb12eedc2892eb20f9947a1d56b1d7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for gust_py-0.1.2.tar.gz:

Publisher: ci_publish.yml on marciok/gust_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gust_py-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gust_py-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gust_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a44be1f4ddac1e951e1f1e894c5b36dde62fa418b6a1c2d5ffff105fa38b170
MD5 5bec9b505b966283b6524aec0b13550f
BLAKE2b-256 f57df58caf788057e352f3d33f28067324692993173df58f58ed25c7b55f48dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for gust_py-0.1.2-py3-none-any.whl:

Publisher: ci_publish.yml on marciok/gust_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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