Skip to main content

pyoco-server (NATS backend for Pyoco)

pyoco-server is a lightweight distributed execution backend for Pyoco. It is optimized for internal systems (single organization, small ops team), not for a large strict multi-tenant platform.

Version: 0.5.1

Positioning

  • Role: distributed execution backend (HTTP Gateway + worker + NATS JetStream).
  • Optimization target: internal platform operations by one team.
  • Non-goal: strict multi-tenant isolation platform with strong audit separation.

Value proposition with nats-bootstrap

pyoco-server focuses on execution, while nats-bootstrap handles practical NATS operations with the same CLI family across local and cluster workflows.

  • Symmetric operations: up / join / status / doctor / backup / restore / leave / down / service are provided by nats-bootstrap.
  • Day-2 operations: lifecycle and recovery are scriptable from CLI.
  • Complexity level: designed to be operable by a small team.

Evidence (commands):

uv run nats-bootstrap --help
uv run nats-bootstrap up --help
uv run nats-bootstrap join --help
uv run nats-bootstrap status --help
uv run nats-bootstrap doctor --help
uv run nats-bootstrap backup --help
uv run nats-bootstrap restore --help
uv run nats-bootstrap leave --help
uv run nats-bootstrap down --help
uv run nats-bootstrap service --help

Fit / Non-fit

Fit:

  • One team operating one internal environment.
  • Internal platform where users submit jobs via HTTP.
  • Docker-centric deployment with NATS JetStream.
  • "Start small, then operate" use cases needing queue + latest status + basic ops.

Non-fit:

  • Strict multi-tenant boundary requirements (hard isolation per tenant).
  • Strong audit/compliance separation across organizations.
  • Very large-scale SLO/SLA platforms requiring advanced fairness and isolation.

Quickstart (shortest path)

For the shortest local path (single-node NATS managed together):

uv sync
uv run pyoco-server up --with-nats-bootstrap --host 127.0.0.1 --port 8000 --dashboard-lang auto
uv run pyoco-worker --nats-url nats://127.0.0.1:4222 --tags hello --worker-id w1

Then submit a YAML workflow:

cat > flow.yaml <<'YAML'
version: 1
flow:
  graph: |
    add_one >> to_text
  defaults:
    x: 1
tasks:
  add_one:
    callable: pyoco_server._workflow_test_tasks:add_one
  to_text:
    callable: pyoco_server._workflow_test_tasks:to_text
YAML

uv run pyoco-client --server http://127.0.0.1:8000 submit-yaml --workflow-file flow.yaml --flow-name main --tag hello
uv run pyoco-client --server http://127.0.0.1:8000 watch <run_id> --until-terminal --output status

For single-node or 3-node cluster startup details, see docs/quickstart.md.

Operational constraints (current behavior)

These are current constraints aligned with implemented behavior and nats-bootstrap 0.0.9 CLI/runtime behavior.

  1. backup / restore require nats CLI.
  • nats-bootstrap backup --help and restore --help expose --nats-cli-path.
  • If nats CLI cannot be resolved, command fails (nats cli not found).
  1. leave / controller are MVP-scoped.
  • leave requires --confirm and controller endpoint(s).
  • --controller must point to the endpoint started by nats-bootstrap controller start (not the NATS monitor port).
  • --stop-anyway allows success when controller is unavailable, but local stop is skipped in MVP behavior.
  • controller currently provides start operation.
  1. down depends on PID file in current directory.
  • down requires --confirm and ./nats-server.pid.
  • If PID file is missing/invalid, down fails.
  • If you need down, start NATS with PID output, e.g.:
uv run nats-bootstrap up -- -js -a 127.0.0.1 -p 4222 -m 8222 -P nats-server.pid
uv run nats-bootstrap down --confirm

Current state

This repo is under active construction. See docs/concept.md and docs/spec.md for current behavior and contracts.

CLI commands

  • pyoco-server: HTTP Gateway launcher
  • pyoco-worker: worker launcher
  • pyoco-client: HTTP client CLI (submit/get/list/watch/tasks/workers/metrics/wheels/wheel-history/wheel-upload/wheel-delete)
  • pyoco-server-admin: API key management CLI

.env is loaded automatically by NatsBackendConfig.from_env() (default file: .env). You can disable it with PYOCO_LOAD_DOTENV=0 or change the file path with PYOCO_ENV_FILE.

export PYOCO_NATS_URL="nats://127.0.0.1:4222"
uv run pyoco-server up --host 127.0.0.1 --port 8000 --dashboard-lang auto

Docs

  • Japanese README: README_ja.md
  • Concept: docs/concept.md
  • Spec (contract): docs/spec.md
  • Architecture: docs/architecture.md
  • Quickstart: docs/quickstart.md
  • Library API (Python): docs/library_api.md
  • Config (.env): docs/config.md
  • Roadmap: docs/plan.md

Development

Prerequisites:

  • Python 3.10+
  • uv

Install dependencies:

uv sync

Run tests (will start an ephemeral NATS server for integration tests):

uv run pytest

Tag routing

Runs are routed by subject:

  • publish to pyoco.work.<tag>
  • workers pull from one or more tags (OR semantics)

Wheel registry (optional)

pyoco-server exposes a wheel registry on /wheels backed by JetStream Object Store. Workers can opt in to sync and install wheels automatically before processing jobs. Workers download wheels when their worker tags intersect with wheel tags. Wheels without tags are treated as shared for all workers. Uploads must be a strict version bump per package (same/older version returns HTTP 409). Wheel upload/delete operations are recorded as history with request source metadata. Sync happens at worker startup and before the next polling cycle. Workers do not start wheel updates in the middle of an active run. When multiple versions exist, workers sync/install only the latest version per package.

export PYOCO_WHEEL_SYNC_ENABLED=1
uv run pyoco-worker --nats-url nats://127.0.0.1:4222 --tags cpu --worker-id w-cpu --wheel-sync
uv run pyoco-client --server http://127.0.0.1:8000 wheel-upload --wheel-file dist/my_ext-0.1.0-py3-none-any.whl --tags cpu,linux
uv run pyoco-client --server http://127.0.0.1:8000 wheels
uv run pyoco-client --server http://127.0.0.1:8000 wheel-history --limit 20

Release files for pyoco-server 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyoco-server 0.5.1
File Size Uploaded
pyoco_server-0.5.1.tar.gz 192.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyoco-server 0.5.1
File Interpreter ABI Platform
pyoco_server-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 266.6 kB

Release files / pyoco_server-0.5.1.tar.gz

Download URL pyoco_server-0.5.1.tar.gz
Size 192.2 kB
Tags Source
SHA-256 checksum
How to use checksums
866e20cbde3674a2ce2d2b059ae98f1e99aa66cb9c64945b4a5d6765ac75e2da
BLAKE2b-256 checksum
How to use checksums
912f11d6bcae4474a97ce901a750ed33573800b6c66795290af653ef5b9cb83d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / pyoco_server-0.5.1-py3-none-any.whl

Download URL pyoco_server-0.5.1-py3-none-any.whl
Size 74.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9190bee9747dad1c36c48a29f6c7af44659cf77035eaefa299ad1e62374ca42c
BLAKE2b-256 checksum
How to use checksums
693713e492094c182847c91ea1fcc3d3001ff71ec758e619b16c8ff278a1bee9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page