fix(translate): fix batch sizing — use real available input budget, respect job.batch_size, lazy playwright in docker

- _batch_sizer.py: compute per_batch_budget from actual available_input_budget
  (context_window - max_output_tokens) instead of sum of first N rows
- _batch_sizer.py: cap max_rows_hard_cap with job.batch_size (user config)
- _token_budget.py: add available_input_budget and max_output_tokens to return
- preview.py: validate required config fields before preview
- requirements-docker.txt: add playwright pip package (~5 MB)
- backend.entrypoint.sh: lazy playwright install chromium on first start
- build.sh: switch tar to tar.xz (-T0 -9), 5.5x smaller bundles
- README.md: add offline bundle deployment instructions
- playwright.config.js: add testMatch for *.e2e.js files
- frontend: preview tab config validation, i18n keys, translationRun store
This commit is contained in:
2026-05-17 23:32:00 +03:00
parent 6988e63967
commit 9228d071ef
15 changed files with 195 additions and 46 deletions

View File

@@ -51,6 +51,27 @@ bootstrap_admin() {
}
# [/DEF:docker.backend.entrypoint.bootstrap_admin:Function]
# [DEF:docker.backend.entrypoint.install_playwright:Function]
# @PURPOSE: Lazily install Playwright Chromium browser on first container start.
# Browser binaries (~377 MB) are downloaded only once and cached in
# PLAYWRIGHT_BROWSERS_PATH (default: ~/.cache/ms-playwright).
# Use a Docker volume or bind mount to persist across restarts:
# -v playwright_cache:/root/.cache/ms-playwright
install_playwright() {
local pw_dir="${PLAYWRIGHT_BROWSERS_PATH:-$HOME/.cache/ms-playwright}"
if [ -f "${pw_dir}/chromium-*/chrome-linux64/chrome" ]; then
echo "[entrypoint] Playwright Chromium already installed at ${pw_dir}"
return 0
fi
echo "[entrypoint] Installing Playwright Chromium browser (first start only)..."
echo "[entrypoint] This downloads ~377 MB. Use a volume to cache:"
echo " -v playwright_cache:/root/.cache/ms-playwright"
python3 -m playwright install chromium --with-deps 2>&1
echo "[entrypoint] Playwright Chromium installed successfully"
}
# [/DEF:docker.backend.entrypoint.install_playwright:Function]
install_playwright
bootstrap_admin
echo "[entrypoint] starting backend: $*"