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

Uploaded Python 3

File details

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

File metadata

  • Download URL: workpeg-0.5.0.tar.gz
  • Upload date:
  • Size: 23.3 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.0.tar.gz
Algorithm Hash digest
SHA256 110e5513f5816b93487ed5ca673b2bfd069b0e72929316a66fc31a19c93447a6
MD5 b52615f7c695bf0b89536b5bf6f11ee2
BLAKE2b-256 c88158bca2baa56478cc3c66682ab459f40d5210003f505ea9702ab59114da34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workpeg-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 18.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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 844993bc0773eef2360623a3034c9418e1321a4019b1a3c12175003ed7c4791d
MD5 ab70998393daf89c5ff0ee7fe37af72a
BLAKE2b-256 012b804d2d92f8b3ccb9d771726181d7b9d65736b614ce0d1f1400463684b7d1

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