Skip to main content

Workpeg function runtime and SDK

Project description

Workpeg SDK

Python SDK and CLI for building Workpeg Pegs and execution workloads.

Workpeg is a platform for developing portable micro-apps called Pegs. Pegs can be packaged, executed, distributed through the PegStore, and integrated into the broader Workpeg ecosystem.

The SDK currently focuses on function-based Peg development and local runtime tooling, while the CLI architecture is designed to expand into additional capabilities such as client applications, Peg packaging, registry tooling, runtime orchestration, and deployment infrastructure.

Current capabilities

  • Peg scaffolding
  • Function-based execution model
  • Fast local runtime
  • Persistent Docker runtime
  • Docker image packaging
  • Registry submission
  • Runtime configuration
  • Warm container execution

Repository

Workpeg SDK Repository


Installation

Install from PyPI:

pip install workpeg

Or install locally from source:

pip install -e .

Verify installation:

workpeg --version

CLI Architecture

Workpeg uses a namespace-oriented CLI inspired by tools like Docker.

Current namespace:

workpeg function ...

Future namespaces may include:

workpeg client ...
workpeg peg ...
workpeg registry ...
workpeg runtime ...

Get help:

workpeg --help
workpeg function --help

Quick Start

Create a Function Peg

Create a new function project:

workpeg function new hello

Generated structure:

hello/
├── app/
│   ├── __init__.py
│   └── main.py
├── tests/
├── Dockerfile
├── requirements.txt
├── workpeg.json
└── README.md

Example function:

def main(context, payload):
    return {
        "message": "Hello from Workpeg",
        "payload": payload,
    }

Fast Local Runtime

For rapid iteration without Docker:

echo '{"context": {}, "payload": {"name":"world"}}' \
  | workpeg function runtime

Example response:

{
  "status": "success",
  "result": {
    "message": "Hello from Workpeg",
    "payload": {
      "name": "world"
    }
  }
}

Persistent Runtime Server

Run the runtime as a warm HTTP server:

workpeg function runtime --server

Default endpoint:

http://0.0.0.0:8000

Invoke:

curl -X POST http://localhost:8000/invoke \
  -H "Content-Type: application/json" \
  -d '{"context": {}, "payload": {"hello":"world"}}'

Health check:

curl http://localhost:8000/healthz

Build Docker Image

Build a Peg runtime image:

workpeg function build

Specify custom tag:

workpeg function build --tag my-image

The build process produces a portable runtime container for the Peg.


Run Peg Runtime (Docker)

Run a warm containerized runtime:

workpeg function run --with docker

This:

  • Builds the image (unless disabled)
  • Starts a persistent runtime container
  • Exposes HTTP endpoints
  • Enables warm execution

Default endpoint:

http://localhost:8000

Docker Networking

Attach runtimes to a Docker network:

workpeg function run \
  --with docker \
  --network workpeg_net

Useful for inter-Peg communication and local ecosystem development:

http://peg-name:8000

This enables multiple Peg runtimes to coexist without port collisions.


Detached Warm Runtime Model

The Docker runtime uses persistent detached containers instead of one-shot execution.

This enables:

  • Warm execution
  • Faster repeated invocations
  • Health monitoring
  • Automatic restarts
  • Internal networking
  • Future orchestration support

Example execution model:

Function → Runtime Container → Peg → PegStore

Runtime Backends

Workpeg supports multiple execution backends.

Runtime Purpose Status
docker Local Peg development Available
cracker Firecracker microVM runtime Planned

Select backend:

workpeg function run --with docker

Runtime resolution order:

  1. CLI flag
  2. workpeg.json
  3. Fallback default (cracker)

Configuration

Optional project configuration:

workpeg.json

Example:

{
  "runtime": {
    "default": "docker",
    "docker": {
      "port": 8000,
      "network": "workpeg_net",
      "restart": "unless-stopped"
    }
  },
  "build": {
    "image": "my-custom-image"
  },
  "function": {
    "entrypoint": "app.main:main"
  }
}

Function Contract

Functions implement:

def main(context: dict, payload: dict):
    return {...}

Input:

{
  "context": {...},
  "payload": {...}
}

Success output:

{
  "status": "success",
  "result": {...}
}

Error output:

{
  "status": "error",
  "error_type": "...",
  "error": "..."
}

Entrypoint

Default entrypoint:

app.main:main

Override:

FUNCTION_ENTRYPOINT=app.main:handler \
  workpeg function runtime

Docker Requirements

Required for:

workpeg function build
workpeg function run --with docker

Requirements:

  • Docker installed
  • Docker daemon running
  • Docker CLI available on PATH

When running inside another container:

-v /var/run/docker.sock:/var/run/docker.sock

Philosophy

Workpeg is designed around composable executable applications.

Core progression:

Function → Runtime → Peg → PegStore → Ecosystem
  • Functions provide isolated execution units
  • Pegs package functionality into portable micro-apps
  • PegStore enables distribution
  • Workpeg provides the runtime and orchestration foundation

The long-term direction is a platform where developers can build, distribute, and execute intelligent applications inside a unified ecosystem.


Roadmap

Planned:

  • Firecracker runtime backend
  • Persistent microVM execution
  • PegStore tooling
  • Peg packaging workflows
  • Client app tooling
  • Runtime orchestration
  • Streaming execution
  • Registry approvals & governance
  • Distributed runtime scheduling

License

MIT License

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

workpeg-0.5.1.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

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

workpeg-0.5.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file workpeg-0.5.1.tar.gz.

File metadata

  • Download URL: workpeg-0.5.1.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for workpeg-0.5.1.tar.gz
Algorithm Hash digest
SHA256 d685904092f9f5cc18b9fd64ee9e4e872b616e2bdf58d21abec20f1031244c94
MD5 1fdc4ab4c955a82e0de44f0c23d608fc
BLAKE2b-256 90043c2027563e038305629e1c3e9ea0206435a284669008f95d09f76e3c7f6f

See more details on using hashes here.

File details

Details for the file workpeg-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: workpeg-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for workpeg-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c419486d8e9a58e7f8d3ed5ca4a15422d160240d5d41eefc30c3276d8242763d
MD5 ab96a4a954a0738e25537e5c60867941
BLAKE2b-256 db84880a06ae409f9fb4f42a89b18941428034b6eee264bf2af5b74de2d40117

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