boatyard 0.9.13.dev284__tar.gz → 0.9.14.dev288__tar.gz
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.
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/PKG-INFO +1 -1
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/pyproject.toml +1 -1
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/lock.py +8 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/lock_file.py +1 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/workload.py +18 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/publish.py +5 -1
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/resolve.py +4 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_compose.py +3 -0
- boatyard-0.9.14.dev288/src/boatyard/score_patch_templates/replicas.tpl +28 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/up.py +23 -1
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_assembly.py +62 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_lock.py +20 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_publish_compose.py +17 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_score_generate.py +55 -5
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.gitattributes +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.github/workflows/cleanup-pr-releases.yml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.github/workflows/integrate.yml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.github/workflows/merge-gate.yml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.github/workflows/release.yml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.gitignore +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/.python-version +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/AGENTS.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/CLAUDE.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/LICENSE +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/NOTICE +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/README.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/design/AGENTS.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/design/CLAUDE.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/design/apt-hermeticity.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/design/mirror-digest-retention.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/design/precision-attribution.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/design/semver-image-bundle-lines.md +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/publish.yml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/ruff.base.toml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/ruff.toml +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/scripts/preflight.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/__init__.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/build.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/cli.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/compose.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/crane.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/markers.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/__init__.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/config_file.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/image.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/k8s_pins.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/pyproject.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/models/values_file.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/paths.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/py.typed +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_generate.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_k8s.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/docker-socket.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/gpu-cuda.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/gpu-pod.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/gpu-rocm.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/probe-adapter-healthchecks.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/restart.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/scale-to-zero.tpl +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/temp.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/__init__.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/build.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/bump.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/down.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/lock.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/matrix.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/mirror.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/publish.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/score.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/verbs/tree_tags.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/yaml.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/conftest.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_build_docker.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_bump.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_compose.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_config.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_daemon_gc.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_image_builds.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_markers.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_matrix.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_mirror.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_provisioners.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_tree_tags.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/tests/test_values.py +0 -0
- {boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/uv.lock +0 -0
|
@@ -34,6 +34,7 @@ from boatyard.models.workload import (
|
|
|
34
34
|
AUTOSTART_ANNOTATION,
|
|
35
35
|
LISTENERS_LABEL,
|
|
36
36
|
PUBLISH_PORT_LABEL,
|
|
37
|
+
REPLICAS_ANNOTATION,
|
|
37
38
|
ROUTE_PATH_LABEL,
|
|
38
39
|
ROUTE_PATH_PATTERN,
|
|
39
40
|
ROUTE_PORT_LABEL,
|
|
@@ -109,6 +110,7 @@ class BundleRecords(NamedTuple):
|
|
|
109
110
|
held_services: list[str]
|
|
110
111
|
declared_ports: dict[str, list[tuple[int, int, str]]]
|
|
111
112
|
listeners: dict[str, dict[str, int]]
|
|
113
|
+
replica_markers: dict[str, str]
|
|
112
114
|
|
|
113
115
|
|
|
114
116
|
def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) -> LockFile:
|
|
@@ -148,6 +150,7 @@ def relock(config: ConfigFile, *, upgrade: bool = False, check: bool = False) ->
|
|
|
148
150
|
held_services=records.held_services,
|
|
149
151
|
declared_ports=records.declared_ports,
|
|
150
152
|
listeners=records.listeners,
|
|
153
|
+
replica_markers=records.replica_markers,
|
|
151
154
|
)
|
|
152
155
|
|
|
153
156
|
# Refuse committed entries for local base_images keys
|
|
@@ -287,10 +290,14 @@ def extract_bundle_records(texts: list[str]) -> BundleRecords:
|
|
|
287
290
|
routes: list[Route] = []
|
|
288
291
|
ports: list[PublishedPort] = []
|
|
289
292
|
listeners: dict[str, dict[str, int]] = {}
|
|
293
|
+
replica_markers: dict[str, str] = {}
|
|
290
294
|
route_owners: dict[str, str] = {}
|
|
291
295
|
for service_name, _stanza, service_annotations in stanzas:
|
|
292
296
|
if service_annotations.get(AUTOSTART_ANNOTATION) == "false":
|
|
293
297
|
held_services.add(service_name)
|
|
298
|
+
marker = service_annotations.get(REPLICAS_ANNOTATION)
|
|
299
|
+
if marker is not None:
|
|
300
|
+
replica_markers[service_name] = marker
|
|
294
301
|
unknown = sorted(key for key in service_annotations if key.startswith("boatyard/") and key not in STANZA_LABELS)
|
|
295
302
|
if unknown:
|
|
296
303
|
raise ValueError(
|
|
@@ -356,6 +363,7 @@ def extract_bundle_records(texts: list[str]) -> BundleRecords:
|
|
|
356
363
|
held_services=sorted(held_services),
|
|
357
364
|
declared_ports=declared_ports,
|
|
358
365
|
listeners=listeners,
|
|
366
|
+
replica_markers=replica_markers,
|
|
359
367
|
)
|
|
360
368
|
|
|
361
369
|
|
|
@@ -160,6 +160,7 @@ class ConfigLockBundle(BaseModel):
|
|
|
160
160
|
held_services: list[str] = Field(default_factory=list)
|
|
161
161
|
declared_ports: dict[str, list[tuple[int, int, str]]] = Field(default_factory=dict)
|
|
162
162
|
listeners: dict[str, dict[str, int]] = Field(default_factory=dict)
|
|
163
|
+
replica_markers: dict[str, str] = Field(default_factory=dict)
|
|
163
164
|
|
|
164
165
|
@model_validator(mode="after")
|
|
165
166
|
def _require_digest_pin(self, info: ValidationInfo) -> Self:
|
|
@@ -13,6 +13,7 @@ PROBE_ADAPTER_ANNOTATION = "boatyard/probe-adapter"
|
|
|
13
13
|
PROBE_ADAPTERS = ("python-urllib", "bash-http")
|
|
14
14
|
RESTART_ANNOTATION = "boatyard/restart"
|
|
15
15
|
COMPOSE_RESTART_POLICIES = ("no", "always", "on-failure", "unless-stopped")
|
|
16
|
+
REPLICAS_ANNOTATION = "boatyard/replicas"
|
|
16
17
|
AUTOSTART_ANNOTATION = "boatyard/autostart"
|
|
17
18
|
|
|
18
19
|
# Interchange labels carrying a resolved claim or publish set into the bundle-record extraction
|
|
@@ -43,6 +44,7 @@ STANZA_LABELS = (
|
|
|
43
44
|
LISTENERS_LABEL,
|
|
44
45
|
PROBE_ADAPTER_ANNOTATION,
|
|
45
46
|
RESTART_ANNOTATION,
|
|
47
|
+
REPLICAS_ANNOTATION,
|
|
46
48
|
AUTOSTART_ANNOTATION,
|
|
47
49
|
GPU_ANNOTATION,
|
|
48
50
|
DOCKER_SOCKET_ANNOTATION,
|
|
@@ -52,6 +54,7 @@ STANZA_LABELS = (
|
|
|
52
54
|
SCALAR_ANNOTATIONS = (
|
|
53
55
|
PROBE_ADAPTER_ANNOTATION,
|
|
54
56
|
RESTART_ANNOTATION,
|
|
57
|
+
REPLICAS_ANNOTATION,
|
|
55
58
|
AUTOSTART_ANNOTATION,
|
|
56
59
|
GPU_ANNOTATION,
|
|
57
60
|
DOCKER_SOCKET_ANNOTATION,
|
|
@@ -61,6 +64,10 @@ ROUTE_PATH_PATTERN = re.compile(r"(?:/\*|/(?:[^/\s*]+(?:/[^/\s*]+)*)?(?:/\*)?)")
|
|
|
61
64
|
|
|
62
65
|
LISTENER_NAME_PATTERN = re.compile(r"[a-zA-Z0-9][a-zA-Z0-9_.-]*")
|
|
63
66
|
|
|
67
|
+
REPLICAS_COUNT_PATTERN = re.compile(r"[1-9][0-9]*")
|
|
68
|
+
|
|
69
|
+
REPLICAS_SLOT_PATTERN = re.compile(r"\$\{[A-Z][A-Z0-9_]*(?:(?::-|:\?)[^{}]*)?\}")
|
|
70
|
+
|
|
64
71
|
LISTENER_REFERENCE_PREFIX = "${listeners."
|
|
65
72
|
|
|
66
73
|
LISTENER_PORT_LOOKUP = "port"
|
|
@@ -138,6 +145,17 @@ class WorkloadDocument(BaseModel):
|
|
|
138
145
|
f"{list(COMPOSE_RESTART_POLICIES)}, not {restart!r}"
|
|
139
146
|
)
|
|
140
147
|
|
|
148
|
+
replicas = annotations.get(REPLICAS_ANNOTATION)
|
|
149
|
+
if (
|
|
150
|
+
replicas is not None
|
|
151
|
+
and REPLICAS_COUNT_PATTERN.fullmatch(replicas) is None
|
|
152
|
+
and REPLICAS_SLOT_PATTERN.fullmatch(replicas) is None
|
|
153
|
+
):
|
|
154
|
+
raise ValueError(
|
|
155
|
+
f"{REPLICAS_ANNOTATION} must be a positive integer or a ${{SLOT}} spelling with an optional "
|
|
156
|
+
f":-default or :?message, not {replicas!r}"
|
|
157
|
+
)
|
|
158
|
+
|
|
141
159
|
claim = self.boatyard.route if self.boatyard is not None else None
|
|
142
160
|
if claim is not None:
|
|
143
161
|
routable = self.routable_listener_ports
|
|
@@ -13,7 +13,11 @@ from boatyard.lock import resolve_remote_digest
|
|
|
13
13
|
from boatyard.yaml import Yaml
|
|
14
14
|
|
|
15
15
|
VAR_PATTERN = re.compile(r"\$\{([A-Z][A-Z0-9_]*)(:[?\-+][^}]*)?\}")
|
|
16
|
-
|
|
16
|
+
# Placeholder substituted for unresolved ${VAR} slots during publish-time interpolation.
|
|
17
|
+
# Compose casts the interpolated string against each field's schema type, and integer
|
|
18
|
+
# fields such as deploy.replicas run it through strconv.Atoi, so the placeholder must
|
|
19
|
+
# parse as every typed scalar, not merely be non-empty.
|
|
20
|
+
STUB_VALUE = "0"
|
|
17
21
|
|
|
18
22
|
|
|
19
23
|
class PublishedEntry(NamedTuple):
|
|
@@ -52,6 +52,7 @@ class BundleProject(NamedTuple):
|
|
|
52
52
|
held_services: list[str]
|
|
53
53
|
declared_ports: dict[str, list[tuple[int, int, str]]]
|
|
54
54
|
listeners: dict[str, dict[str, int]]
|
|
55
|
+
replica_markers: dict[str, str]
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
class PublicFace(NamedTuple):
|
|
@@ -185,6 +186,7 @@ def resolve(config: ConfigFile, lock: LockFile, values: ValuesFile) -> AssemblyP
|
|
|
185
186
|
adopted_held_services = list(locked.held_services)
|
|
186
187
|
adopted_declared_ports = dict(locked.declared_ports)
|
|
187
188
|
adopted_listeners = dict(locked.listeners)
|
|
189
|
+
adopted_replica_markers = dict(locked.replica_markers)
|
|
188
190
|
bundle_path = None
|
|
189
191
|
pinned_reference = locked.reference
|
|
190
192
|
else:
|
|
@@ -197,6 +199,7 @@ def resolve(config: ConfigFile, lock: LockFile, values: ValuesFile) -> AssemblyP
|
|
|
197
199
|
adopted_held_services = records.held_services
|
|
198
200
|
adopted_declared_ports = records.declared_ports
|
|
199
201
|
adopted_listeners = records.listeners
|
|
202
|
+
adopted_replica_markers = records.replica_markers
|
|
200
203
|
bundle_path = paths[name]
|
|
201
204
|
pinned_reference = None
|
|
202
205
|
|
|
@@ -219,6 +222,7 @@ def resolve(config: ConfigFile, lock: LockFile, values: ValuesFile) -> AssemblyP
|
|
|
219
222
|
held_services=adopted_held_services,
|
|
220
223
|
declared_ports=adopted_declared_ports,
|
|
221
224
|
listeners=adopted_listeners,
|
|
225
|
+
replica_markers=adopted_replica_markers,
|
|
222
226
|
)
|
|
223
227
|
)
|
|
224
228
|
|
|
@@ -42,6 +42,7 @@ TOOL = "score-compose"
|
|
|
42
42
|
|
|
43
43
|
HEALTHCHECK_TEMPLATE = "probe-adapter-healthchecks.tpl"
|
|
44
44
|
RESTART_TEMPLATE = "restart.tpl"
|
|
45
|
+
REPLICAS_TEMPLATE = "replicas.tpl"
|
|
45
46
|
DOCKER_SOCKET_TEMPLATE = "docker-socket.tpl"
|
|
46
47
|
GPU_COMPOSE_TEMPLATES = {"cuda": "gpu-cuda.tpl", "rocm": "gpu-rocm.tpl"}
|
|
47
48
|
|
|
@@ -75,6 +76,7 @@ class ComposeService(BaseModel):
|
|
|
75
76
|
configs: list[ComposeConfigReference] | None = None
|
|
76
77
|
image: str | None = None
|
|
77
78
|
annotations: dict[str, str] | None = None
|
|
79
|
+
labels: dict[str, str] | None = None
|
|
78
80
|
|
|
79
81
|
@property
|
|
80
82
|
def bind_volumes(self) -> list[BindVolume]:
|
|
@@ -188,6 +190,7 @@ def generate_compose(config: ConfigFile, lock: LockFile) -> list[Path]:
|
|
|
188
190
|
templates=[
|
|
189
191
|
HEALTHCHECK_TEMPLATE,
|
|
190
192
|
RESTART_TEMPLATE,
|
|
193
|
+
REPLICAS_TEMPLATE,
|
|
191
194
|
DOCKER_SOCKET_TEMPLATE,
|
|
192
195
|
*(
|
|
193
196
|
GPU_COMPOSE_TEMPLATES[value]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Pool-size marker for workloads declaring boatyard/replicas: the
|
|
2
|
+
# annotation value is a slot marker interpolated from the values file
|
|
3
|
+
# at up, never an authored count, and compose's own interpolation
|
|
4
|
+
# enforces the unset slot. The marker rides the service label because
|
|
5
|
+
# score-compose's typed output model refuses non-int replicas values,
|
|
6
|
+
# and up's override document resolves the label into deploy.replicas
|
|
7
|
+
# at run time. Compose-only consumption, no k8s twin: the k8s path
|
|
8
|
+
# accepts the annotation in the vocabulary and consumes nothing,
|
|
9
|
+
# activation there stays KEDA for the reconstructor and always-on
|
|
10
|
+
# for the localizer. The value is validated by the workload lens
|
|
11
|
+
# before generation (templates are data and cannot refuse). Presence
|
|
12
|
+
# is the trigger, the annotation value the marker.
|
|
13
|
+
{{- $matched := false }}
|
|
14
|
+
{{- range $workloadName, $workload := .Workloads }}
|
|
15
|
+
{{- $replicas := dig "metadata" "annotations" "boatyard/replicas" "" $workload }}
|
|
16
|
+
{{- if $replicas }}
|
|
17
|
+
{{- range $containerName, $_ := $workload.containers }}
|
|
18
|
+
{{- $matched = true }}
|
|
19
|
+
- op: set
|
|
20
|
+
path: services.{{ $workloadName }}-{{ $containerName }}.labels.boatyard/replicas
|
|
21
|
+
value: {{ $replicas }}
|
|
22
|
+
description: Replicas slot {{ $replicas }} for the {{ $workloadName }}-{{ $containerName }} service
|
|
23
|
+
{{- end }}
|
|
24
|
+
{{- end }}
|
|
25
|
+
{{- end }}
|
|
26
|
+
{{- if not $matched }}
|
|
27
|
+
[]
|
|
28
|
+
{{- end }}
|
|
@@ -25,6 +25,7 @@ from boatyard.models.config_file import (
|
|
|
25
25
|
)
|
|
26
26
|
from boatyard.models.lock_file import LockFile
|
|
27
27
|
from boatyard.models.values_file import ValuesFile
|
|
28
|
+
from boatyard.models.workload import REPLICAS_SLOT_PATTERN
|
|
28
29
|
from boatyard.paths import DEFAULT_CONFIG_PATH, LOCK_PATH, VALUES_FILE
|
|
29
30
|
from boatyard.resolve import AssemblyPlan, BundleProject, GatewayPlan, resolve
|
|
30
31
|
from boatyard.temp import quote_command_token
|
|
@@ -127,7 +128,7 @@ def _orchestrate_up(
|
|
|
127
128
|
override_file = _materialize(
|
|
128
129
|
materialized,
|
|
129
130
|
"boatyard-override-",
|
|
130
|
-
render_override_document(shared_network_name, bundle, values, bundle.declared_ports),
|
|
131
|
+
render_override_document(shared_network_name, bundle, values, bundle.declared_ports, plan.env),
|
|
131
132
|
)
|
|
132
133
|
invocations.append(BundleInvocation(bundle=bundle, bundle_files=compose_files, override_file=override_file))
|
|
133
134
|
|
|
@@ -221,6 +222,7 @@ def render_override_document(
|
|
|
221
222
|
bundle: BundleProject,
|
|
222
223
|
values: ValuesFile,
|
|
223
224
|
declared_ports: dict[str, list[tuple[int, int, str]]],
|
|
225
|
+
env: Mapping[str, str],
|
|
224
226
|
) -> str:
|
|
225
227
|
# Hand-render the !reset spelling safe_dump cannot write
|
|
226
228
|
lines = ["networks:", f" {shared_network_name}:", " external: true"]
|
|
@@ -237,6 +239,10 @@ def render_override_document(
|
|
|
237
239
|
if ports:
|
|
238
240
|
lines.append(" ports:")
|
|
239
241
|
lines.extend(f" - {_port_entry(port)}" for port in ports)
|
|
242
|
+
marker = bundle.replica_markers.get(service_name)
|
|
243
|
+
if marker is not None:
|
|
244
|
+
lines.append(" deploy:")
|
|
245
|
+
lines.append(f" replicas: {resolve_replica_marker(marker, env)}")
|
|
240
246
|
if service_name in bundle.container_names:
|
|
241
247
|
lines.append(" container_name: !reset null")
|
|
242
248
|
return "\n".join(lines) + "\n"
|
|
@@ -267,6 +273,22 @@ def _port_entry(port: PublishedPort) -> str:
|
|
|
267
273
|
return "{" + ", ".join(fields) + "}"
|
|
268
274
|
|
|
269
275
|
|
|
276
|
+
def resolve_replica_marker(marker: str, env: Mapping[str, str]) -> str:
|
|
277
|
+
# A bare count rides through; a slot marker resolves against the env table the per-run
|
|
278
|
+
# dotenv writes, raising the marker's own message when the value is absent
|
|
279
|
+
if REPLICAS_SLOT_PATTERN.fullmatch(marker) is None:
|
|
280
|
+
return marker
|
|
281
|
+
name, _separator, tail = marker[2:-1].partition(":")
|
|
282
|
+
value = env.get(name)
|
|
283
|
+
if value:
|
|
284
|
+
return value
|
|
285
|
+
if tail.startswith("-"):
|
|
286
|
+
return tail[1:]
|
|
287
|
+
if tail.startswith("?"):
|
|
288
|
+
raise ValueError(tail[1:])
|
|
289
|
+
raise ValueError(f"{name} is not set in boatyard.values.yaml")
|
|
290
|
+
|
|
291
|
+
|
|
270
292
|
def render_gateway_document(plan: AssemblyPlan, auth_entries: set[str]) -> str:
|
|
271
293
|
gateway = _require_gateway(plan)
|
|
272
294
|
project_name = plan.config.project_name
|
|
@@ -514,6 +514,68 @@ class TestOverrideDocument:
|
|
|
514
514
|
[override] = spy.override_documents
|
|
515
515
|
assert override["services"]["livekit"]["container_name"] is None
|
|
516
516
|
|
|
517
|
+
def test_replica_markers_resolve_into_the_override_document(
|
|
518
|
+
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
519
|
+
) -> None:
|
|
520
|
+
_write_edge_tree(tmp_path, monkeypatch, [])
|
|
521
|
+
lock = yaml.safe_load((tmp_path / LOCK_PATH).read_text(encoding="utf-8"))
|
|
522
|
+
lock["bundles"]["LIVEKIT_BUNDLE"]["replica_markers"] = {"livekit": "${GPU_SLOTS:?set the pool size}"}
|
|
523
|
+
lock["bundles"]["LIVEKIT_BUNDLE"]["slots"] = {"GPU_SLOTS": {"required": True}}
|
|
524
|
+
(tmp_path / LOCK_PATH).write_text(yaml.safe_dump(lock), encoding="utf-8")
|
|
525
|
+
values = yaml.safe_load((tmp_path / "boatyard.values.yaml").read_text(encoding="utf-8"))
|
|
526
|
+
values["values"] = {"GPU_SLOTS": "4"}
|
|
527
|
+
(tmp_path / "boatyard.values.yaml").write_text(yaml.safe_dump(values), encoding="utf-8")
|
|
528
|
+
spy = UpSpy()
|
|
529
|
+
monkeypatch.setattr(up, "bash", spy.run)
|
|
530
|
+
monkeypatch.setattr(up, "bash_check", _bash_check_true)
|
|
531
|
+
monkeypatch.setattr(up, "install_crane", lambda: None)
|
|
532
|
+
monkeypatch.setattr(up, "install_compose", lambda: None)
|
|
533
|
+
monkeypatch.setattr(up, "OciArtifactManifest", StubArtifacts({LIVEKIT_PINNED: [LIVEKIT_TEXT]}))
|
|
534
|
+
|
|
535
|
+
result = runner.invoke(app, ["up"])
|
|
536
|
+
|
|
537
|
+
assert result.exit_code == 0, result.output
|
|
538
|
+
[override] = spy.override_documents
|
|
539
|
+
assert override["services"]["livekit"]["deploy"] == {"replicas": 4}
|
|
540
|
+
|
|
541
|
+
def test_a_replica_marker_without_its_value_refuses(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
542
|
+
_write_edge_tree(tmp_path, monkeypatch, [])
|
|
543
|
+
lock = yaml.safe_load((tmp_path / LOCK_PATH).read_text(encoding="utf-8"))
|
|
544
|
+
lock["bundles"]["LIVEKIT_BUNDLE"]["replica_markers"] = {"livekit": "${GPU_SLOTS:?set the pool size}"}
|
|
545
|
+
lock["bundles"]["LIVEKIT_BUNDLE"]["slots"] = {"GPU_SLOTS": {"required": True}}
|
|
546
|
+
(tmp_path / LOCK_PATH).write_text(yaml.safe_dump(lock), encoding="utf-8")
|
|
547
|
+
spy = UpSpy()
|
|
548
|
+
monkeypatch.setattr(up, "bash", spy.run)
|
|
549
|
+
monkeypatch.setattr(up, "bash_check", _bash_check_true)
|
|
550
|
+
monkeypatch.setattr(up, "install_crane", lambda: None)
|
|
551
|
+
monkeypatch.setattr(up, "install_compose", lambda: None)
|
|
552
|
+
monkeypatch.setattr(up, "OciArtifactManifest", StubArtifacts({LIVEKIT_PINNED: [LIVEKIT_TEXT]}))
|
|
553
|
+
|
|
554
|
+
result = runner.invoke(app, ["up"])
|
|
555
|
+
|
|
556
|
+
assert result.exit_code != 0
|
|
557
|
+
assert isinstance(result.exception, ValueError)
|
|
558
|
+
assert "requires ['GPU_SLOTS']" in str(result.exception)
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
class TestResolveReplicaMarker:
|
|
562
|
+
def test_a_bare_count_rides_through(self) -> None:
|
|
563
|
+
assert up.resolve_replica_marker("3", {"GPU_SLOTS": "4"}) == "3"
|
|
564
|
+
|
|
565
|
+
def test_a_slot_marker_resolves_against_the_env(self) -> None:
|
|
566
|
+
assert up.resolve_replica_marker("${GPU_SLOTS}", {"GPU_SLOTS": "4"}) == "4"
|
|
567
|
+
|
|
568
|
+
def test_a_default_applies_when_the_value_is_absent(self) -> None:
|
|
569
|
+
assert up.resolve_replica_marker("${GPU_SLOTS:-1}", {}) == "1"
|
|
570
|
+
|
|
571
|
+
def test_the_marker_message_raises_when_the_value_is_absent(self) -> None:
|
|
572
|
+
with pytest.raises(ValueError, match="set the pool size"):
|
|
573
|
+
up.resolve_replica_marker("${GPU_SLOTS:?set the pool size}", {})
|
|
574
|
+
|
|
575
|
+
def test_a_bare_marker_refuses_when_the_value_is_absent(self) -> None:
|
|
576
|
+
with pytest.raises(ValueError, match=r"GPU_SLOTS is not set in boatyard\.values\.yaml"):
|
|
577
|
+
up.resolve_replica_marker("${GPU_SLOTS}", {"GPU_SLOTS": ""})
|
|
578
|
+
|
|
517
579
|
|
|
518
580
|
class TestUpProjects:
|
|
519
581
|
def test_bundles_then_gateway_in_declaration_order(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
@@ -1144,6 +1144,26 @@ def test_extract_bundle_records_parses_the_publish_label_into_port_records() ->
|
|
|
1144
1144
|
]
|
|
1145
1145
|
|
|
1146
1146
|
|
|
1147
|
+
def test_extract_bundle_records_collects_the_replicas_marker_labels() -> None:
|
|
1148
|
+
from boatyard.lock import extract_bundle_records
|
|
1149
|
+
|
|
1150
|
+
text = (
|
|
1151
|
+
"services:\n"
|
|
1152
|
+
" localizer:\n"
|
|
1153
|
+
" image: demo/localizer:1\n"
|
|
1154
|
+
" labels:\n"
|
|
1155
|
+
" boatyard/replicas: ${GPU_SLOTS:?set the pool size}\n"
|
|
1156
|
+
" worker:\n"
|
|
1157
|
+
" image: demo/worker:1\n"
|
|
1158
|
+
" labels:\n"
|
|
1159
|
+
" boatyard/replicas: 3\n"
|
|
1160
|
+
)
|
|
1161
|
+
|
|
1162
|
+
records = extract_bundle_records([text])
|
|
1163
|
+
|
|
1164
|
+
assert records.replica_markers == {"localizer": "${GPU_SLOTS:?set the pool size}", "worker": "3"}
|
|
1165
|
+
|
|
1166
|
+
|
|
1147
1167
|
def test_extract_bundle_records_parses_the_listeners_label_into_inventories() -> None:
|
|
1148
1168
|
from boatyard.lock import extract_bundle_records
|
|
1149
1169
|
|
|
@@ -309,6 +309,23 @@ class TestPublishComposeVerb:
|
|
|
309
309
|
assert os.environ.get("LIVEKIT_API_KEY") == publish_compose.STUB_VALUE
|
|
310
310
|
monkeypatch.delenv("LIVEKIT_API_KEY", raising=False)
|
|
311
311
|
|
|
312
|
+
def test_a_replicas_marker_label_survives_the_publish_stubs(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
|
313
|
+
self._write_tree(tmp_path)
|
|
314
|
+
artifact = tmp_path / "stack" / "generated" / "compose" / "compose.livekit-tier.yaml"
|
|
315
|
+
document = yaml.safe_load(artifact.read_text(encoding="utf-8"))
|
|
316
|
+
document["services"]["livekit-token"]["labels"] = {"boatyard/replicas": "${GPU_SLOTS:?err}"}
|
|
317
|
+
artifact.write_text(yaml.safe_dump(document, default_flow_style=False, sort_keys=False), encoding="utf-8")
|
|
318
|
+
recorder = self._invoke(monkeypatch, tmp_path)
|
|
319
|
+
|
|
320
|
+
result = runner.invoke(app, ["publish-compose"])
|
|
321
|
+
|
|
322
|
+
assert result.exit_code == 0, result.output
|
|
323
|
+
baked = yaml.safe_load(recorder.baked_snapshots["compose.livekit-tier.yaml"])
|
|
324
|
+
assert baked["services"]["livekit-token"]["labels"]["boatyard/replicas"] == "${GPU_SLOTS:?err}"
|
|
325
|
+
assert "deploy" not in baked["services"]["livekit-token"]
|
|
326
|
+
assert int(os.environ["GPU_SLOTS"]) >= 0
|
|
327
|
+
monkeypatch.delenv("GPU_SLOTS", raising=False)
|
|
328
|
+
|
|
312
329
|
def test_appends_the_sha_to_digest_table_to_the_job_summary(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
|
313
330
|
self._write_tree(tmp_path)
|
|
314
331
|
self._invoke(monkeypatch, tmp_path)
|
|
@@ -642,6 +642,29 @@ def test_generate_compose_strips_the_workload_prefix_from_differing_container_na
|
|
|
642
642
|
assert document["services"]["rathole-client"]["image"] == "ghcr.io/org/rathole-client:1"
|
|
643
643
|
|
|
644
644
|
|
|
645
|
+
def test_the_replicas_marker_stays_a_string_label_and_never_materializes(
|
|
646
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
647
|
+
) -> None:
|
|
648
|
+
marker = "${GPU_SLOTS:?set the pool size}"
|
|
649
|
+
output = _generate_compose(
|
|
650
|
+
monkeypatch,
|
|
651
|
+
tmp_path,
|
|
652
|
+
"services:\n"
|
|
653
|
+
" localizer-localizer:\n"
|
|
654
|
+
" image: ghcr.io/org/localizer:1\n"
|
|
655
|
+
" labels:\n"
|
|
656
|
+
f" boatyard/replicas: {marker}\n",
|
|
657
|
+
workload="localizer",
|
|
658
|
+
)
|
|
659
|
+
|
|
660
|
+
text = output.read_text(encoding="utf-8")
|
|
661
|
+
document = yaml.safe_load(text)
|
|
662
|
+
service = document["services"]["localizer"]
|
|
663
|
+
assert service["labels"]["boatyard/replicas"] == marker
|
|
664
|
+
assert service.get("deploy", {}).get("replicas") is None
|
|
665
|
+
assert text.count(f"{marker}\n") == 1
|
|
666
|
+
|
|
667
|
+
|
|
645
668
|
COMPOSE_WITH_BARRIER = (
|
|
646
669
|
"services:\n"
|
|
647
670
|
" api-api:\n"
|
|
@@ -952,6 +975,7 @@ class TestRenderedNameClaims:
|
|
|
952
975
|
SHIPPED_TEMPLATES = {
|
|
953
976
|
"probe-adapter-healthchecks.tpl",
|
|
954
977
|
"restart.tpl",
|
|
978
|
+
"replicas.tpl",
|
|
955
979
|
"docker-socket.tpl",
|
|
956
980
|
"gpu-cuda.tpl",
|
|
957
981
|
"gpu-rocm.tpl",
|
|
@@ -1017,6 +1041,13 @@ def test_the_healthcheck_template_derives_its_timing_from_the_probe_annotation()
|
|
|
1017
1041
|
assert "retries: {{ $retries }}" in text
|
|
1018
1042
|
|
|
1019
1043
|
|
|
1044
|
+
def test_the_replicas_template_digs_the_annotation_into_the_label() -> None:
|
|
1045
|
+
text = (files("boatyard") / "score_patch_templates" / "replicas.tpl").read_text(encoding="utf-8")
|
|
1046
|
+
|
|
1047
|
+
assert 'dig "metadata" "annotations" "boatyard/replicas" "" $workload' in text
|
|
1048
|
+
assert "services.{{ $workloadName }}-{{ $containerName }}.labels.boatyard/replicas" in text
|
|
1049
|
+
|
|
1050
|
+
|
|
1020
1051
|
PROBE_TIMING_WORKLOAD = (
|
|
1021
1052
|
"metadata:\n"
|
|
1022
1053
|
" name: api\n"
|
|
@@ -1185,7 +1216,7 @@ def test_barrier_pin_stays_unregistered_without_provisioner_services(
|
|
|
1185
1216
|
},
|
|
1186
1217
|
)
|
|
1187
1218
|
|
|
1188
|
-
assert templates == [["probe-adapter-healthchecks.tpl", "restart.tpl", "docker-socket.tpl"]]
|
|
1219
|
+
assert templates == [["probe-adapter-healthchecks.tpl", "restart.tpl", "replicas.tpl", "docker-socket.tpl"]]
|
|
1189
1220
|
|
|
1190
1221
|
|
|
1191
1222
|
def test_provisioners_register_by_resource_type_closure(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
@@ -2606,7 +2637,7 @@ def test_adapted_probe_bearing_workloads_register_the_healthcheck_template(
|
|
|
2606
2637
|
generated=API_SERVICE_RENDERING,
|
|
2607
2638
|
)
|
|
2608
2639
|
|
|
2609
|
-
assert templates == [["probe-adapter-healthchecks.tpl", "restart.tpl", "docker-socket.tpl"]]
|
|
2640
|
+
assert templates == [["probe-adapter-healthchecks.tpl", "restart.tpl", "replicas.tpl", "docker-socket.tpl"]]
|
|
2610
2641
|
|
|
2611
2642
|
|
|
2612
2643
|
def test_restart_values_outside_the_compose_enum_refuse(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
@@ -2633,7 +2664,26 @@ def test_restart_annotation_with_an_enum_value_passes(tmp_path: Path, monkeypatc
|
|
|
2633
2664
|
},
|
|
2634
2665
|
)
|
|
2635
2666
|
|
|
2636
|
-
assert templates == [["probe-adapter-healthchecks.tpl", "restart.tpl", "docker-socket.tpl"]]
|
|
2667
|
+
assert templates == [["probe-adapter-healthchecks.tpl", "restart.tpl", "replicas.tpl", "docker-socket.tpl"]]
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
def test_replicas_values_outside_the_two_shapes_refuse() -> None:
|
|
2671
|
+
for value in ("0", "-1", "1.5", "three", "${lowercase}", "${}", "$unclosed"):
|
|
2672
|
+
with pytest.raises(ValidationError, match=r"must be a positive integer or a \$\{SLOT\}"):
|
|
2673
|
+
parse_workload(
|
|
2674
|
+
{"metadata": {"name": "api", "annotations": {"boatyard/replicas": value}}, "containers": {}},
|
|
2675
|
+
"api.yaml",
|
|
2676
|
+
)
|
|
2677
|
+
|
|
2678
|
+
|
|
2679
|
+
def test_replicas_annotation_with_a_count_or_slot_spelling_passes() -> None:
|
|
2680
|
+
for value in ("3", "${GPU_SLOTS:-1}", "${REPLICAS}", "${GPU_SLOTS:?set the pool size}"):
|
|
2681
|
+
document = parse_workload(
|
|
2682
|
+
{"metadata": {"name": "api", "annotations": {"boatyard/replicas": value}}, "containers": {}},
|
|
2683
|
+
"api.yaml",
|
|
2684
|
+
)
|
|
2685
|
+
|
|
2686
|
+
assert document.metadata.annotations == {"boatyard/replicas": value}
|
|
2637
2687
|
|
|
2638
2688
|
|
|
2639
2689
|
def test_bare_literal_workload_image_refuses(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
@@ -2786,8 +2836,8 @@ def test_gpu_compose_templates_register_per_the_renderings_variant(
|
|
|
2786
2836
|
templates = _compose_init_templates(monkeypatch, tmp_path, config, {}, {})
|
|
2787
2837
|
|
|
2788
2838
|
assert templates == [
|
|
2789
|
-
["probe-adapter-healthchecks.tpl", "restart.tpl", "docker-socket.tpl", "gpu-cuda.tpl"],
|
|
2790
|
-
["probe-adapter-healthchecks.tpl", "restart.tpl", "docker-socket.tpl", "gpu-rocm.tpl"],
|
|
2839
|
+
["probe-adapter-healthchecks.tpl", "restart.tpl", "replicas.tpl", "docker-socket.tpl", "gpu-cuda.tpl"],
|
|
2840
|
+
["probe-adapter-healthchecks.tpl", "restart.tpl", "replicas.tpl", "docker-socket.tpl", "gpu-rocm.tpl"],
|
|
2791
2841
|
]
|
|
2792
2842
|
|
|
2793
2843
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/gpu-cuda.tpl
RENAMED
|
File without changes
|
{boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/gpu-pod.tpl
RENAMED
|
File without changes
|
{boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/gpu-rocm.tpl
RENAMED
|
File without changes
|
|
File without changes
|
{boatyard-0.9.13.dev284 → boatyard-0.9.14.dev288}/src/boatyard/score_patch_templates/restart.tpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|