Skip to main content

Highway Workflow Engine - Stabilize execution layer

Project description

Stabilize

Highway Workflow Engine - Stabilize execution layer.

A lightweight Python workflow execution engine with DAG-based stage orchestration.

Requirements

  • Python 3.11+
  • SQLite (included) or PostgreSQL 12+

Installation

pip install stabilize            # SQLite support only
pip install stabilize[postgres]  # PostgreSQL support

Features

  • Message-driven DAG execution engine
  • Parallel and sequential stage execution
  • Synthetic stages (before/after/onFailure)
  • PostgreSQL and SQLite persistence
  • Pluggable task system
  • Retry and timeout support

Quick Start

from stabilize import Workflow, StageExecution, TaskExecution, WorkflowStatus
from stabilize.persistence.sqlite import SqliteWorkflowStore
from stabilize.queue.sqlite_queue import SqliteQueue
from stabilize.queue.processor import QueueProcessor
from stabilize.orchestrator import Orchestrator
from stabilize.tasks.interface import Task
from stabilize.tasks.result import TaskResult
from stabilize.tasks.registry import TaskRegistry

# Define a custom task
class HelloTask(Task):
    def execute(self, stage: StageExecution) -> TaskResult:
        name = stage.context.get("name", "World")
        return TaskResult.success(outputs={"greeting": f"Hello, {name}!"})

# Create a workflow
workflow = Workflow.create(
    application="my-app",
    name="Hello Workflow",
    stages=[
        StageExecution(
            ref_id="1",
            type="hello",
            name="Say Hello",
            tasks=[
                TaskExecution.create(
                    name="Hello Task",
                    implementing_class="hello",
                    stage_start=True,
                    stage_end=True,
                ),
            ],
            context={"name": "Stabilize"},
        ),
    ],
)

# Setup persistence and queue
store = SqliteWorkflowStore(":memory:")
queue = SqliteQueue(":memory:")

# Register tasks
registry = TaskRegistry()
registry.register("hello", HelloTask)

# Create processor and orchestrator
processor = QueueProcessor.create(queue, store, registry)
orchestrator = Orchestrator(queue)

# Run workflow
store.store(workflow)
orchestrator.start(workflow)
processor.process_all(timeout=10.0)

# Check result
result = store.retrieve(workflow.id)
print(f"Status: {result.status}")  # WorkflowStatus.SUCCEEDED
print(f"Output: {result.stages[0].outputs}")  # {'greeting': 'Hello, Stabilize!'}

Parallel Stages

Stages with shared dependencies run in parallel:

#     Setup
#    /     \
#  Test   Lint
#    \     /
#    Deploy

workflow = Workflow.create(
    application="my-app",
    name="CI/CD Pipeline",
    stages=[
        StageExecution(ref_id="setup", type="setup", name="Setup", ...),
        StageExecution(ref_id="test", type="test", name="Test",
                      requisite_stage_ref_ids={"setup"}, ...),
        StageExecution(ref_id="lint", type="lint", name="Lint",
                      requisite_stage_ref_ids={"setup"}, ...),
        StageExecution(ref_id="deploy", type="deploy", name="Deploy",
                      requisite_stage_ref_ids={"test", "lint"}, ...),
    ],
)

Database Setup

SQLite

No setup required. Schema is created automatically.

PostgreSQL

Apply migrations using the CLI:

# Using mg.yaml in current directory
stabilize mg-up

# Using database URL
stabilize mg-up --db-url postgres://user:pass@host:5432/dbname

# Using environment variable
MG_DATABASE_URL=postgres://user:pass@host:5432/dbname stabilize mg-up

# Check migration status
stabilize mg-status

Example mg.yaml:

database:
  host: localhost
  port: 5432
  user: postgres
  password: postgres
  dbname: stabilize

CLI Reference

stabilize mg-up [--db-url URL]      Apply pending PostgreSQL migrations
stabilize mg-status [--db-url URL]  Show migration status

Naming Alignment with highway_dsl

highway_dsl stabilize
Workflow Workflow
TaskOperator Task interface
RetryPolicy RetryableTask
TimeoutPolicy OverridableTimeoutRetryableTask

Running Tests

# All tests (requires Docker for PostgreSQL)
pytest tests/ -v

# SQLite tests only (no Docker)
pytest tests/ -v -k sqlite

License

Apache 2.0

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

stabilize-0.9.0.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

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

stabilize-0.9.0-py3-none-any.whl (82.4 kB view details)

Uploaded Python 3

File details

Details for the file stabilize-0.9.0.tar.gz.

File metadata

  • Download URL: stabilize-0.9.0.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for stabilize-0.9.0.tar.gz
Algorithm Hash digest
SHA256 b7a9dca78164e047cd9eedff599c745fb5e6b0fdc454e8a03b515218b6bc1af2
MD5 774b58fc4683a8134a46ac7937d582b9
BLAKE2b-256 12b88da8b6ee6bed2656b5529c50bcef9ce085dcaeac0ce0d7cecace336615cc

See more details on using hashes here.

File details

Details for the file stabilize-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: stabilize-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 82.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for stabilize-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78e6951ddf8b82b95a723d593a8ed1aa0f61f8ccb2a31a780f1814c2555a1a4b
MD5 2e636e2853fcfc620029683b65ebd1ee
BLAKE2b-256 a7509ebde5c41bbebfc21544e9dafc80075db779877a3eab0fa1535b640ab3a1

See more details on using hashes here.

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