Skip to main content

Workpeg function runtime and SDK

Project description

Workpeg SDK

Python SDK for building, packaging, and running Workpeg Functions and Pegs.

The SDK provides:

  • Project scaffolding
  • Local execution (fast + Docker runtime)
  • Docker-based packaging
  • Registry submission

Workpeg is designed as an execution layer, not just a code runner — functions evolve into Pegs that integrate into a larger system.

Repository https://gitlab.com/workpeg/workpeg-sdk


Installation

pip install workpeg

Or from source:

pip install -e .

Quick Start

1. Create a Function

workpeg new-function my-function

Structure:

my-function/
  app/
    __init__.py
    main.py

Example:

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

2. Run (Fast Local Runtime)

For quick iteration without Docker:

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

3. Build (Docker Image)

workpeg build

Optional tag:

workpeg build --tag my-image

This produces a runnable container for your function.


4. Run (Docker Runtime)

workpeg run --with docker

This will:

  • Build the image (if needed)
  • Start a container
  • Expose an HTTP endpoint

Default:

http://localhost:8000

Optional network (advanced)

workpeg run --with docker --network workpeg_net

Useful when integrating with other containers (e.g. your API service).


5. Submit to Registry

workpeg submit my-function:1.0.0

Authentication:

export WORKPEG_PK=<your-token>

Registry:

https://repo.workpeg.com

Runtime Modes

Workpeg supports multiple execution backends:

Runtime Purpose Status
docker Local development ✅ Available
cracker Firecracker microVMs 🚧 Planned

Select runtime:

workpeg run --with docker

If unspecified:

  1. Uses workpeg.json
  2. Falls back to cracker (future default)

Configuration

Optional config file:

workpeg.json

Example:

{
  "runtime": {
    "default": "docker",
    "docker": {
      "port": 8000
    }
  },
  "build": {
    "image": "my-custom-image"
  }
}

Function Contract

Your function must 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:

app.main:main

Override:

FUNCTION_ENTRYPOINT=app.main:handler workpeg runtime

Project Layout

my-function/
 ├─ app/
 │  ├─ __init__.py
 │  └─ main.py
 ├─ requirements.txt
 └─ workpeg.json (optional)

Docker Requirement (Important)

For workpeg build and workpeg run --with docker:

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

If using inside containers:

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

Philosophy

Workpeg is built around a simple progression:

Function → Package → Runtime → Peg → System
  • Functions are stateless execution units
  • Pegs add structure, state, and integrations
  • Workpeg orchestrates execution

Roadmap

Planned:

  • Firecracker runtime (production)
  • Warm container/microVM execution
  • Peg UI layer (Streamlit-like)
  • Deployment workflows
  • Isolation + sandboxing
  • Registry approvals & governance

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.4.1.tar.gz (21.8 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.4.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for workpeg-0.4.1.tar.gz
Algorithm Hash digest
SHA256 8015e92a460398bfc86b08bf94303fea3eb635db81b1ea8b2c1921cb4cdf281b
MD5 05adf9b0778e085099f879dc2bff24c7
BLAKE2b-256 97eae50c485f43efc933e1ab08203fe3d315a7e57f825ad2fc156abc19bca111

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workpeg-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 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.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e44219a95dc89006175336d6eed16b2e54cbae83a43d28f5156826c673efe18e
MD5 2414a763bd95a4ae710af1430b54cc87
BLAKE2b-256 719a09d06bc26b651f8a44361ce316fbd62611c7fd1ae1bf6f8b15994d195177

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