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.3.1.tar.gz (19.9 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.3.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for workpeg-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2a2c69d64b6690db0a173e817fcb375c8f96249a9f0b4c8f7c453c43cfaca842
MD5 69d93c09cb1ed70f145697cf6e581eeb
BLAKE2b-256 daf922403bc4203eb40da5b68d49544dbd022ea269edf2008df8b7cf1684791c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workpeg-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b6450a0d696855b854cba9e8660efce7778a5c0ca905202cf5a7a28d2dafa52
MD5 ae2facfce4c8c6f56b8639af422f7e65
BLAKE2b-256 66746e16e91b704948a3b716a7bf302d4be9ccd61a24704b4e4d04a5f8b60c59

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