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

Uploaded Python 3

File details

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

File metadata

  • Download URL: workpeg-0.3.0.tar.gz
  • Upload date:
  • Size: 19.6 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.0.tar.gz
Algorithm Hash digest
SHA256 f0cdc8cfe094da4f83e282e10c12f9a561243b267bef502ee84648f25f572e52
MD5 637e52b934bd5a94d90414a3b2b92910
BLAKE2b-256 6924188853408f1e2a226d18d5d76f4a98c274df2343976ca46efc93453a0d58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workpeg-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f03c4b1f97327ed2818252e40cfe583a1db9e8f0066a10fa6f7cb4b1c5727b22
MD5 6d7883895e5cbac1a20a82b1be5ac9ba
BLAKE2b-256 ad537609bbf5f4c3f3afaffc00041b632d23ae2708ea98c64af05738d3a1845b

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