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

Uploaded Python 3

File details

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

File metadata

  • Download URL: workpeg-0.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 847a6f9114988841cd9f419d5f8c8c6747779f8863d0322ac2fbccc4f0c4b726
MD5 2e6554fdbf8db8fe66dfbfd069a92ba8
BLAKE2b-256 c77f81aaba984aae9ef75ced69984d96565482bfc5e4222ab5429cbfde054e2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workpeg-0.4.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f11ff9fcd3c53952f40fb3ece5e67b91a50ffa0c91a046fc59f51bec10d9b59a
MD5 6de996f047096bff06b7e495cae9e3c8
BLAKE2b-256 f69811f16f2c8f4bb9705cc1c9e9310766ad6eb468a0bca831d824a8c5335dd2

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