#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib.sh
source "${SCRIPT_DIR}/lib.sh"

install_one() {
  local name="$1"
  echo "[${name}] ensure verl importable"
  if ! dexec "${name}" python3 -c "import verl; print(verl.__file__)" >/dev/null 2>&1; then
    echo "[${name}] verl not importable; installing editable from /workspace/verl"
    dexec "${name}" bash -lc "pip install -e /workspace/verl"
  else
    echo "[${name}] verl import OK"
  fi
}

install_one "${HEAD_CONTAINER}"
install_one "${WORKER0_CONTAINER}"
install_one "${WORKER1_CONTAINER}"

