Coverage for gco / inference_proxy_config.py: 100.00%
14 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-09-14 22:07 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-09-14 22:07 +0000
1"""Dependency-light inference proxy autoscaling defaults and rendering."""
3from __future__ import annotations
5from collections.abc import Mapping
7INFERENCE_PROXY_TLS_CPU_REQUEST_MILLICORES_DEFAULT = 100
8INFERENCE_PROXY_TLS_CPU_TARGET_UTILIZATION_DEFAULT = 70
9#: HPA floor and ceiling for the shared proxy Deployment. The floor is also the
10#: Deployment's create-time ``replicas`` (the HPA owns the count afterwards).
11INFERENCE_PROXY_MIN_REPLICAS_DEFAULT = 3
12INFERENCE_PROXY_MAX_REPLICAS_DEFAULT = 10
15def compute_inference_proxy_tls_replacements(
16 config: Mapping[str, object],
17) -> dict[str, str]:
18 """Render the typed inference-proxy placeholders without importing AWS CDK.
20 Two shapes matter to the applier and to kubeconform: the TLS CPU request
21 is a quoted Kubernetes quantity (``"100m"``), while the HPA target and the
22 replica bounds are bare integers in the manifest.
23 """
24 request = config["tls_proxy_cpu_request_millicores"]
25 target = config["tls_proxy_cpu_target_utilization_percentage"]
26 min_replicas = config.get("min_replicas", INFERENCE_PROXY_MIN_REPLICAS_DEFAULT)
27 max_replicas = config.get("max_replicas", INFERENCE_PROXY_MAX_REPLICAS_DEFAULT)
28 if (
29 type(request) is not int
30 or type(target) is not int
31 or type(min_replicas) is not int
32 or type(max_replicas) is not int
33 ):
34 raise ValueError("validated inference proxy TLS settings must be integers")
35 return {
36 "{{INFERENCE_PROXY_TLS_CPU_REQUEST}}": f"{request}m",
37 "{{INFERENCE_PROXY_TLS_CPU_TARGET_UTILIZATION}}": str(target),
38 "{{INFERENCE_PROXY_MIN_REPLICAS}}": str(min_replicas),
39 "{{INFERENCE_PROXY_MAX_REPLICAS}}": str(max_replicas),
40 }