Skip to main content
sidecar/ai_train/ The training code lives in sidecar/ai_train/ and runs on Modal, the one provider implemented so far. It is ported from gloflow_phoenix/gf_phoenix/ai_train and restructured so the cloud-specific parts sit behind a provider interface. It is the backend behind the Python sidecar: the sidecar’s modal backend proxies the Go server’s requests to the web API of this app, and nothing else calls it. It runs on Modal and is not imported by main_sidecar.py; Dockerfile.sidecar copies the directory only so that the sidecar can deploy it. Deploying, stopping and inspecting the app can be done from the sidecar and the admin UI, without the modal CLI: see Modal app lifecycle.

Layout

Prerequisites

The modal CLI, logged in (pip install modal && modal setup), for the commands below (to deploy, stop and look at the app you can use the sidecar and the admin UI instead, see Modal app lifecycle), and a provider secret holding HF_TOKEN for the Gemma weights (named by SIDECAR_HF_SECRET).

Commands

train syncs the (local) dataset first; --dataset is required for sync, validate and train (there is no default dataset; see Training datasets). modal deploy app.py (or the Deploy button of the admin UI’s training view, which runs the same deploy through the sidecar: Modal app lifecycle) publishes the web API as the Modal app gligabao-train, which the sidecar looks up by name (SIDECAR_APP_NAME) and forwards to; the Go server starts jobs through the sidecar (see Training jobs). modal serve app.py is the dev mode: it prints a temporary URL that you give the sidecar as SIDECAR_MODAL_WEB_URL. The modal CLI uses your own Modal login; the sidecar, which looks the app up through the Modal SDK, needs MODAL_TOKEN_ID and MODAL_TOKEN_SECRET instead (see the sidecar’s configuration). Local tests: cd sidecar/ai_train && python -m unittest test_ai_train_core -v.

Configuration

These are the settings of the Modal app, in config.py; they can be overridden by environment variable when the app is deployed. The sidecar’s own settings (SIDECAR_BACKEND, SIDECAR_MODAL_WEB_URL, the tokens) are on the sidecar page. SIDECAR_APP_NAME is read by both and must have the same value. Volumes are created if missing. The Go server’s only setting is sidecar_url, the address of the sidecar, not of Modal; see the overview.