Files
computer-playbook/cli/administration/deploy/development/env.py
T
kevinveenbirkenbachandClaude Opus 5 c782208f99 feat(tools): rename the i18n lane to tools and give the cache paths one spot
The lane is no longer LibreTranslate-only, so `i18n` is the wrong name for
the runner, its compose override, its inventory and its env keys. Renames
to `tools` throughout and points the lane at
`svc-ai-libretranslate-engine`, which is the role that actually owns the
`libretranslate-engine` service key.

The six cache host paths were each written out in full. They now derive
from `DIR_CACHE`, one plain string in `group_vars/all/05_paths.yml`, via a
`cache_paths` handler; the generated values are byte-identical. The handler
is registered directly after `cache_stack` rather than late, because
`registry_cache_max_size` reads `INFINITO_CACHE_REGISTRY_HOST_PATH` and
returns early when it is empty, which silently dropped
`INFINITO_CACHE_REGISTRY_MAX_SIZE` from the generated `.env` and broke
every `docker compose` invocation that layers `cache.override.yml`.

`INFINITO_TOOLS_MODELS_HOST_PATH` derives from the same base, so the model
bind the lane mounts follows the cache layout instead of repeating it.

The inventory pins `DOCKER_BIND_HOST=0.0.0.0`: the group_vars default keys
off `DOCKER_IN_CONTAINER`, which evaluates false for the inner deploy and
would leave the lane's services on the runner's loopback.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-28 23:50:26 +02:00

58 lines
2.0 KiB
Python

from __future__ import annotations
import os
from utils.distros import distro_names
VALID_DISTROS: tuple[str, ...] = distro_names()
def compose_file_args() -> list[str]:
"""Compose `-f` flags shared by up and down flows.
Each override is gated on the resource it needs being present, not on the
instance slot: an override whose `:?` guard is unsatisfied would abort the
stack outright, so a checkout that was never handed a shared git dir or
cache network simply does not layer that file in.
"""
from .profile import Profile
profile = Profile()
out = ["-f", "compose.yml"]
if profile.shared_git_dir():
out += ["-f", "compose/worktree.override.yml"]
if profile.cache_stack_enabled():
out += ["-f", "compose/cache.override.yml"]
if profile.shared_cache_network():
out += ["-f", "compose/cache.shared.override.yml"]
if profile.gpu_reservable():
out += ["-f", "compose/gpu.override.yml"]
if (os.environ.get("INFINITO_PUBLISH_PORTS") or "").strip().lower() == "false":
out += ["-f", "compose/noports.override.yml"]
if all(
(os.environ.get(key) or "").strip()
for key in (
"INFINITO_TOOLS_LIBRETRANSLATE_PORT",
"INFINITO_TOOLS_MODELS_HOST_PATH",
)
):
out += ["-f", "compose/tools.override.yml"]
return out
def resolve_distro() -> str:
"""Return INFINITO_DISTRO; raise SystemExit if missing or invalid."""
distro = os.environ["INFINITO_DISTRO"].strip()
if not distro:
raise SystemExit(
"INFINITO_DISTRO is not set. Run 'make dotenv' (or source scripts/meta/env/load.sh) "
f"or export INFINITO_DISTRO=<{'|'.join(VALID_DISTROS)}> "
"before invoking cli.administration.deploy.development."
)
if distro not in VALID_DISTROS:
raise SystemExit(
f"INFINITO_DISTRO={distro!r} is not a valid distro. "
f"Valid: {', '.join(VALID_DISTROS)}."
)
return distro