Add your description here
Project description
This is a python package, called gen_worker, which provides the worker runtime SDK:
- Orchestrator gRPC client + job loop
- Function discovery via @worker_function
- ActionContext + errors + progress events
- Model downloading from the Cozy hub (async + retries + progress)
- Output uploads (presigned PUT or S3 creds)
Torch-based model memory management is optional and installed via extras.
Files in src/gen_worker/pb must be auto-generated in the gen-orchestrator repo, using the proto files. Go in there and run task proto
Install modes:
- Core only:
gen-worker - Torch runtime add-on:
gen-worker[torch](torch + torchvision + torchaudio + safetensors + flashpack + numpy)
Example tenant projects live in ../worker-example-functions. They use:
pyproject.toml+uv.lockfor dependencies (no requirements.txt)cozy.tomlTOML manifest for deployment config (functions.modules, runtime.base_image, etc.)
Dependency policy:
- Require
pyproject.tomland/oruv.lock - Do not use
requirements.txt - Put Cozy deployment config in
cozy.toml
Example:
[functions]
modules = ["functions"]
[runtime]
base_image = "ghcr.io/cozy/python-worker:cuda12.1-torch2.6"
Function signature:
from gen_worker import worker_function, ResourceRequirements, ActionContext
@worker_function(ResourceRequirements(model_family="sdxl", requires_gpu=True))
def generate(ctx: ActionContext, payload: dict) -> dict:
return {"ok": True}
Dynamic checkpoints:
- Use
ResourceRequirements(model_family=...)to declare a family (e.g., "sdxl") - Pass the exact checkpoint at runtime via request payload (e.g.,
model_ref)
Build contract (gen-builder):
- Tenant code +
pyproject.toml/uv.lock+cozy.tomlare packaged together - gen-builder layers tenant code + deps on top of a python-worker base image
- gen-orchestrator deploys the resulting worker image
Env hints:
SCHEDULER_ADDRsets the primary scheduler address.SCHEDULER_ADDRS(comma-separated) provides seed addresses for leader discovery.WORKER_JWTis accepted as the auth token ifAUTH_TOKENis not set.SCHEDULER_JWKS_URLenables verification ofWORKER_JWTbefore connecting.- JWT verification uses RSA and requires PyJWT crypto support (installed by default via
PyJWT[crypto]). WORKER_MAX_INPUT_BYTES,WORKER_MAX_OUTPUT_BYTES,WORKER_MAX_UPLOAD_BYTEScap payload sizes.WORKER_MAX_CONCURRENCYlimits concurrent runs;ResourceRequirements(max_concurrency=...)limits per-function.COZY_HUB_URLbase URL for Cozy hub downloads (used by core downloader).COZY_HUB_TOKENoptional bearer token for Cozy hub downloads.MODEL_MANAGER_CLASSoptional ModelManager plugin (module:Class) loaded at startup.
Error hints:
- Use
gen_worker.errors.RetryableErrorin worker functions to flag retryable failures.
Output upload hints:
- To upload raw bytes, include an
output_uploadobject in the job input:- Presigned PUT:
{"output_upload":{"put_url":"...","headers":{"Content-Type":"image/png"},"public_url":"https://..."}}
- S3 creds:
{"output_upload":{"s3":{"bucket":"...","key":"...","region":"...","access_key_id":"...","secret_access_key":"..."}}}
- Presigned PUT:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gen_worker-0.1.4.tar.gz.
File metadata
- Download URL: gen_worker-0.1.4.tar.gz
- Upload date:
- Size: 198.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffb560809211d7fc065bbfd3f6ad0ceaa433249dae0024dc2102a97e82ed9f72
|
|
| MD5 |
8f2d35b81171bf260c761184c263427e
|
|
| BLAKE2b-256 |
dd2e516a5545b2d14da237694aa16486e8eece776320571fb0658a1d482c7c6b
|
File details
Details for the file gen_worker-0.1.4-py3-none-any.whl.
File metadata
- Download URL: gen_worker-0.1.4-py3-none-any.whl
- Upload date:
- Size: 81.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a07655aa3ae7b40251f63a8b972b59e1aa4195e22ce5dc4decb7847119883e02
|
|
| MD5 |
dac1f9e4d8bd77439bf9ea71a4548628
|
|
| BLAKE2b-256 |
79b639c777c44a6d12bf5bc7729f95d8a2e794187a87996ca2aceb9caba82bfb
|