gen-worker 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gen_worker/__init__.py +19 -0
- gen_worker/decorators.py +66 -0
- gen_worker/default_model_manager/__init__.py +5 -0
- gen_worker/downloader.py +84 -0
- gen_worker/entrypoint.py +135 -0
- gen_worker/errors.py +10 -0
- gen_worker/model_interface.py +48 -0
- gen_worker/pb/__init__.py +27 -0
- gen_worker/pb/frontend_pb2.py +53 -0
- gen_worker/pb/frontend_pb2_grpc.py +189 -0
- gen_worker/pb/worker_scheduler_pb2.py +69 -0
- gen_worker/pb/worker_scheduler_pb2_grpc.py +100 -0
- gen_worker/py.typed +0 -0
- gen_worker/testing/__init__.py +1 -0
- gen_worker/testing/stub_manager.py +69 -0
- gen_worker/torch_manager/__init__.py +4 -0
- gen_worker/torch_manager/manager.py +2059 -0
- gen_worker/torch_manager/utils/base_types/architecture.py +145 -0
- gen_worker/torch_manager/utils/base_types/common.py +52 -0
- gen_worker/torch_manager/utils/base_types/config.py +46 -0
- gen_worker/torch_manager/utils/config.py +321 -0
- gen_worker/torch_manager/utils/db/database.py +46 -0
- gen_worker/torch_manager/utils/device.py +26 -0
- gen_worker/torch_manager/utils/diffusers_fix.py +10 -0
- gen_worker/torch_manager/utils/flashpack_loader.py +262 -0
- gen_worker/torch_manager/utils/globals.py +59 -0
- gen_worker/torch_manager/utils/load_models.py +238 -0
- gen_worker/torch_manager/utils/local_cache.py +340 -0
- gen_worker/torch_manager/utils/model_downloader.py +763 -0
- gen_worker/torch_manager/utils/parse_cli.py +98 -0
- gen_worker/torch_manager/utils/paths.py +22 -0
- gen_worker/torch_manager/utils/repository.py +141 -0
- gen_worker/torch_manager/utils/utils.py +43 -0
- gen_worker/types.py +47 -0
- gen_worker/worker.py +1720 -0
- gen_worker-0.1.4.dist-info/METADATA +113 -0
- gen_worker-0.1.4.dist-info/RECORD +38 -0
- gen_worker-0.1.4.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gen-worker
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author-email: Paul Fidika <paul@fidika.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: aiohttp>=3.11.14
|
|
8
|
+
Requires-Dist: backoff>=2.2.1
|
|
9
|
+
Requires-Dist: grpcio>=1.71.0
|
|
10
|
+
Requires-Dist: msgspec>=0.18.6
|
|
11
|
+
Requires-Dist: protobuf>=5.26.1
|
|
12
|
+
Requires-Dist: psutil>=7.0.0
|
|
13
|
+
Requires-Dist: pyjwt[crypto]>=2.8.0
|
|
14
|
+
Requires-Dist: tqdm>=4.66.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: devpi-client>=7.2.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: grpcio-tools>=1.71.0; extra == 'dev'
|
|
18
|
+
Provides-Extra: torch
|
|
19
|
+
Requires-Dist: flashpack>=0.1.2; extra == 'torch'
|
|
20
|
+
Requires-Dist: numpy>=1.26.0; extra == 'torch'
|
|
21
|
+
Requires-Dist: safetensors>=0.4.3; extra == 'torch'
|
|
22
|
+
Requires-Dist: torch>=2.6.0; extra == 'torch'
|
|
23
|
+
Requires-Dist: torchaudio>=2.6.0; extra == 'torch'
|
|
24
|
+
Requires-Dist: torchvision>=0.21.0; extra == 'torch'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
This is a python package, called gen_worker, which provides the worker runtime SDK:
|
|
28
|
+
|
|
29
|
+
- Orchestrator gRPC client + job loop
|
|
30
|
+
- Function discovery via @worker_function
|
|
31
|
+
- ActionContext + errors + progress events
|
|
32
|
+
- Model downloading from the Cozy hub (async + retries + progress)
|
|
33
|
+
- Output uploads (presigned PUT or S3 creds)
|
|
34
|
+
|
|
35
|
+
Torch-based model memory management is optional and installed via extras.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
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`
|
|
40
|
+
|
|
41
|
+
Install modes:
|
|
42
|
+
|
|
43
|
+
- Core only: `gen-worker`
|
|
44
|
+
- Torch runtime add-on: `gen-worker[torch]` (torch + torchvision + torchaudio + safetensors + flashpack + numpy)
|
|
45
|
+
|
|
46
|
+
Example tenant projects live in `../worker-example-functions`. They use:
|
|
47
|
+
|
|
48
|
+
- `pyproject.toml` + `uv.lock` for dependencies (no requirements.txt)
|
|
49
|
+
- `cozy.toml` TOML manifest for deployment config (functions.modules, runtime.base_image, etc.)
|
|
50
|
+
|
|
51
|
+
Dependency policy:
|
|
52
|
+
|
|
53
|
+
- Require `pyproject.toml` and/or `uv.lock`
|
|
54
|
+
- Do not use `requirements.txt`
|
|
55
|
+
- Put Cozy deployment config in `cozy.toml`
|
|
56
|
+
|
|
57
|
+
Example:
|
|
58
|
+
|
|
59
|
+
```toml
|
|
60
|
+
[functions]
|
|
61
|
+
modules = ["functions"]
|
|
62
|
+
|
|
63
|
+
[runtime]
|
|
64
|
+
base_image = "ghcr.io/cozy/python-worker:cuda12.1-torch2.6"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Function signature:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from gen_worker import worker_function, ResourceRequirements, ActionContext
|
|
71
|
+
|
|
72
|
+
@worker_function(ResourceRequirements(model_family="sdxl", requires_gpu=True))
|
|
73
|
+
def generate(ctx: ActionContext, payload: dict) -> dict:
|
|
74
|
+
return {"ok": True}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Dynamic checkpoints:
|
|
78
|
+
|
|
79
|
+
- Use `ResourceRequirements(model_family=...)` to declare a family (e.g., "sdxl")
|
|
80
|
+
- Pass the exact checkpoint at runtime via request payload (e.g., `model_ref`)
|
|
81
|
+
|
|
82
|
+
Build contract (gen-builder):
|
|
83
|
+
|
|
84
|
+
- Tenant code + `pyproject.toml`/`uv.lock` + `cozy.toml` are packaged together
|
|
85
|
+
- gen-builder layers tenant code + deps on top of a python-worker base image
|
|
86
|
+
- gen-orchestrator deploys the resulting worker image
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
Env hints:
|
|
91
|
+
|
|
92
|
+
- `SCHEDULER_ADDR` sets the primary scheduler address.
|
|
93
|
+
- `SCHEDULER_ADDRS` (comma-separated) provides seed addresses for leader discovery.
|
|
94
|
+
- `WORKER_JWT` is accepted as the auth token if `AUTH_TOKEN` is not set.
|
|
95
|
+
- `SCHEDULER_JWKS_URL` enables verification of `WORKER_JWT` before connecting.
|
|
96
|
+
- JWT verification uses RSA and requires PyJWT crypto support (installed by default via `PyJWT[crypto]`).
|
|
97
|
+
- `WORKER_MAX_INPUT_BYTES`, `WORKER_MAX_OUTPUT_BYTES`, `WORKER_MAX_UPLOAD_BYTES` cap payload sizes.
|
|
98
|
+
- `WORKER_MAX_CONCURRENCY` limits concurrent runs; `ResourceRequirements(max_concurrency=...)` limits per-function.
|
|
99
|
+
- `COZY_HUB_URL` base URL for Cozy hub downloads (used by core downloader).
|
|
100
|
+
- `COZY_HUB_TOKEN` optional bearer token for Cozy hub downloads.
|
|
101
|
+
- `MODEL_MANAGER_CLASS` optional ModelManager plugin (module:Class) loaded at startup.
|
|
102
|
+
|
|
103
|
+
Error hints:
|
|
104
|
+
|
|
105
|
+
- Use `gen_worker.errors.RetryableError` in worker functions to flag retryable failures.
|
|
106
|
+
|
|
107
|
+
Output upload hints:
|
|
108
|
+
|
|
109
|
+
- To upload raw bytes, include an `output_upload` object in the job input:
|
|
110
|
+
- Presigned PUT:
|
|
111
|
+
- `{"output_upload":{"put_url":"...","headers":{"Content-Type":"image/png"},"public_url":"https://..."}}`
|
|
112
|
+
- S3 creds:
|
|
113
|
+
- `{"output_upload":{"s3":{"bucket":"...","key":"...","region":"...","access_key_id":"...","secret_access_key":"..."}}}`
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
gen_worker/__init__.py,sha256=oo5BosBdO7iy-_5cv4TnHVRzGa0ygMyAeD0K-mJV2t4,516
|
|
2
|
+
gen_worker/decorators.py,sha256=7RfsVsH5YlR5lcTeL6CV3jpqzojTGIxlqTV7N4mPjYs,2476
|
|
3
|
+
gen_worker/downloader.py,sha256=XjmbAgsY6HicA5xBOe0f7FSqfewoyoZIp9EF__1XiCM,2980
|
|
4
|
+
gen_worker/entrypoint.py,sha256=C3Nz6JcAroTYgNwGSS2jAlyLuSxX-t7IupG9TaJPUII,6186
|
|
5
|
+
gen_worker/errors.py,sha256=1947MCZSx5ehykpk43smEj47ClJ0OnQa1EErsvx7TqI,252
|
|
6
|
+
gen_worker/model_interface.py,sha256=WFyW9kwhrW0ri7Bzs-m5DuTKQWETb8-UBPfwvIBKwiE,1180
|
|
7
|
+
gen_worker/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
gen_worker/types.py,sha256=Yn84xc4wJ9vAofjkfRwCH1wxjYo7CJacLAgJ7qIA8jE,1624
|
|
9
|
+
gen_worker/worker.py,sha256=6v1xl9kvJ-VvL2QAp4pstA3yGfIGsgAj483JdsT2tr8,78996
|
|
10
|
+
gen_worker/default_model_manager/__init__.py,sha256=8_CMt6sqvHyDppNpCyF7km1988hWDLruzsBCrW2el2I,172
|
|
11
|
+
gen_worker/pb/__init__.py,sha256=IT0vsuJUAbWRkwr9zvywA3O3A1C10hla67uMUfw24JY,965
|
|
12
|
+
gen_worker/pb/frontend_pb2.py,sha256=bWFV2ElpGvdwPsgzyzn4lWWzqBUp51lbyNHD2KvfJCk,3735
|
|
13
|
+
gen_worker/pb/frontend_pb2_grpc.py,sha256=9yIkEWbK_q_qsRiGg3wmora2cbIOS7RdUjGrT1f1Itw,6852
|
|
14
|
+
gen_worker/pb/worker_scheduler_pb2.py,sha256=ym_h5hLG37FrN03w_uqMbztQNkD1LU1WVB5GRRtU9jc,7286
|
|
15
|
+
gen_worker/pb/worker_scheduler_pb2_grpc.py,sha256=PteKjn5HQfzj-xbgJ0YfQ8GO4KJBSCYgSu0C4Uzk37E,3727
|
|
16
|
+
gen_worker/testing/__init__.py,sha256=nubuQCmjof2zS_KSPKgIgm9Iw50TfSuPeARwrkUDF2Q,38
|
|
17
|
+
gen_worker/testing/stub_manager.py,sha256=89oxi--h6ht6SYz-OfDrgeDQvW00aOwsrG-uL3acZTM,2386
|
|
18
|
+
gen_worker/torch_manager/__init__.py,sha256=mweyjnNIzNIescB8RyyOGFgOyW0u7Rn9FBUAgZjjjdY,155
|
|
19
|
+
gen_worker/torch_manager/manager.py,sha256=yoLYNLWWV1E6KJmkLareHvKwtmxo1ZSiJzSLK_vmghQ,80113
|
|
20
|
+
gen_worker/torch_manager/utils/config.py,sha256=IQHhP4mL1kr7GO_hBse_4LcFjOATpuSocIsjE9YMaEM,11643
|
|
21
|
+
gen_worker/torch_manager/utils/device.py,sha256=eLFteGOFA5HFVxhoqVr42jiB3Z_5sQ-E_Nr09hCkMSU,755
|
|
22
|
+
gen_worker/torch_manager/utils/diffusers_fix.py,sha256=GU5plsN0-kvUKsECxmtmEKpFSElHbYaGmXa2yhRKOo8,367
|
|
23
|
+
gen_worker/torch_manager/utils/flashpack_loader.py,sha256=Pt68WwM1xFzQaF8mdMHV_QwH6j4vnEbgg9wq3FF8gxw,9913
|
|
24
|
+
gen_worker/torch_manager/utils/globals.py,sha256=Rdc4Ny81Hym_tOKqpDFErnagGcMbCR-8PgvnppfPqhE,1452
|
|
25
|
+
gen_worker/torch_manager/utils/load_models.py,sha256=o5IpwM6UT5tE0Uwq1WT_kz2pHU2DL-skk91a5-zDOd4,8239
|
|
26
|
+
gen_worker/torch_manager/utils/local_cache.py,sha256=6uIkieqgXWZ5heqb15h8Cr5n5M1LdSN4DzXsd5Cr818,11716
|
|
27
|
+
gen_worker/torch_manager/utils/model_downloader.py,sha256=9VLhgHzdB31md8fdjJdFZ9rRj85Ox6u7drXZa-xY1Hg,30907
|
|
28
|
+
gen_worker/torch_manager/utils/parse_cli.py,sha256=FlbyOAkHc_5he7dBq5ET2OXZYFnnnKalbH5hZHYCcS0,2735
|
|
29
|
+
gen_worker/torch_manager/utils/paths.py,sha256=PwJ2NjtlxiTXqyK9pq3NGf07Qh4RX5csmGbQTEq9B6k,480
|
|
30
|
+
gen_worker/torch_manager/utils/repository.py,sha256=eov5LQRpTeWEJDiI1vSROpthGIZosNSq6sYccGDIZ5g,5736
|
|
31
|
+
gen_worker/torch_manager/utils/utils.py,sha256=0XXQDyOsPNfjBRgJS5FGPVmKWOLhNE6UYgpeAE9PkAg,1327
|
|
32
|
+
gen_worker/torch_manager/utils/base_types/architecture.py,sha256=47MGbJZeIF8rI305_Abov02m7KRAuyV88SAwTjq0gWs,4278
|
|
33
|
+
gen_worker/torch_manager/utils/base_types/common.py,sha256=bIDa0tnjTwRDQH1vr9IRwpCdEQlwD2CYQH7GTuhg33Q,1251
|
|
34
|
+
gen_worker/torch_manager/utils/base_types/config.py,sha256=Wej9jVeGFWWmI0rPU-TCMWOvoEYYQjc1FJgEyTVCd_c,1133
|
|
35
|
+
gen_worker/torch_manager/utils/db/database.py,sha256=U1U114wti7ah5Pk-hr0-khYwji5jT4ALLwGFUuksyNg,1286
|
|
36
|
+
gen_worker-0.1.4.dist-info/METADATA,sha256=xY_JgHgliPRXSa0FsFCt_oxTa71L-z5bIjK5508Geqg,4123
|
|
37
|
+
gen_worker-0.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
38
|
+
gen_worker-0.1.4.dist-info/RECORD,,
|