#!/usr/bin/env bash # Helpers to delegate server lifecycle and argument rendering to # `python -m sskj.deploy`. The deployment profile is the single source of # engine launch args; experiment scripts should call these helpers instead of # maintaining their own copies. DEPLOY_PYTHON="${PYTHON:-python3}" deploy_profile_abs() { local profile="$1" printf '%s' "${ROOT_DIR}/deploy/profiles/${profile}.env" } deploy_start() { local profile="$1" local tp="$2" local dp="$3" local log_dir="$4" local port="$5" local model_path="$6" local container="$7" local node_rank="${8:-}" local -a extra=() if [[ -n "$node_rank" ]]; then extra+=(--node-rank "$node_rank") fi PYTHONPATH="${ROOT_DIR}/src" "${DEPLOY_PYTHON}" -m sskj.deploy start \ --profile "$(deploy_profile_abs "$profile")" \ --tp "$tp" \ --dp "$dp" \ --log-dir "$log_dir" \ --port "$port" \ --model-path "$model_path" \ --container-name "$container" \ "${extra[@]}" } deploy_render_args() { local profile="$1" local tp="$2" local dp="$3" local port="$4" local model_path="$5" PYTHONPATH="${ROOT_DIR}/src" "${DEPLOY_PYTHON}" -m sskj.deploy render-args \ --profile "$(deploy_profile_abs "$profile")" \ --tp "$tp" \ --dp "$dp" \ --port "$port" \ --model-path "$model_path" } # Multi-node convenience helpers: orchestrate all NODE_HOSTS from one host. deploy_start_multinode() { local profile="$1" local tp="$2" local dp="$3" local log_dir="$4" local port="$5" local model_path="$6" local container="$7" PYTHONPATH="${ROOT_DIR}/src" "${DEPLOY_PYTHON}" -m sskj.deploy start \ --profile "$(deploy_profile_abs "$profile")" \ --tp "$tp" \ --dp "$dp" \ --log-dir "$log_dir" \ --port "$port" \ --model-path "$model_path" \ --container-name "$container" } deploy_stop() { local profile="$1" local tp="$2" local dp="$3" local port="$4" local model_path="$5" local container="$6" local node_rank="${7:-}" local -a extra=() if [[ -n "$node_rank" ]]; then extra+=(--node-rank "$node_rank") fi PYTHONPATH="${ROOT_DIR}/src" "${DEPLOY_PYTHON}" -m sskj.deploy stop \ --profile "$(deploy_profile_abs "$profile")" \ --tp "$tp" \ --dp "$dp" \ --port "$port" \ --model-path "$model_path" \ --container-name "$container" \ "${extra[@]}" } deploy_status() { local profile="$1" local tp="${2:-}" local dp="${3:-}" local port="${4:-}" local model_path="${5:-}" local container="${6:-}" local -a cmd=( --profile "$(deploy_profile_abs "$profile")" ) [[ -n "$tp" ]] && cmd+=(--tp "$tp") [[ -n "$dp" ]] && cmd+=(--dp "$dp") [[ -n "$port" ]] && cmd+=(--port "$port") [[ -n "$model_path" ]] && cmd+=(--model-path "$model_path") [[ -n "$container" ]] && cmd+=(--container-name "$container") PYTHONPATH="${ROOT_DIR}/src" "${DEPLOY_PYTHON}" -m sskj.deploy status "${cmd[@]}" }