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.2.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.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: workpeg-0.5.2.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.2.tar.gz
Algorithm Hash digest
SHA256 41f36a896b393e1742baac0cb7e66a66dc864e70decaa06a363e6a06595dae3a
MD5 d260863551a423a833bf24c730f2f99d
BLAKE2b-256 b0e8b8bc35a0a1f42448e04e24e504db9979685f37ed4f6e4da1c57acdc0a9b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workpeg-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd5bbfb468ef7f8b7805369d9f8c8e3af95f29e8015549975ca7954afc02741a
MD5 ef7c6fa85df5adbb1457c822684b89bf
BLAKE2b-256 b1ba58597dc6815bc6bf6f1a9c30654cd3472a2017062b6161ebb983f3ed098c

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