Provision Netron and Lab 1 local assets

This commit is contained in:
c4ch3c4d3
2026-04-16 11:15:39 -06:00
parent 56305680e0
commit 59f3032f91
16 changed files with 248 additions and 216 deletions
+19 -11
View File
@@ -15,15 +15,22 @@ load_runtime_env() {
: "${COURSEWARE_STATE_DIR:=$STATE_DIR}"
: "${COURSEWARE_BIND_HOST:=127.0.0.1}"
: "${COURSEWARE_URL_HOST:=127.0.0.1}"
: "${COURSEWARE_NETRON_PORT:=8338}"
: "${COURSEWARE_PROMPTFOO_PORT:=15500}"
: "${COURSEWARE_WIKI_PORT:=80}"
: "${COURSEWARE_WETTY_PORT:=7681}"
: "${COURSEWARE_OLLAMA_MIN_VERSION:=0.12.11}"
: "${COURSEWARE_WETTY_BASE_PATH:=/wetty}"
: "${NODE_RUNTIME_BIN_DIR:=$COURSEWARE_STATE_DIR/tools/node-runtime/node_modules/node/bin}"
: "${NETRON_VENV:=$COURSEWARE_STATE_DIR/venvs/netron}"
: "${WETTY_BIN:=$COURSEWARE_STATE_DIR/tools/wetty/node_modules/.bin/wetty}"
: "${PROMPTFOO_DIR:=$COURSEWARE_STATE_DIR/lab6}"
: "${WIKI_DIR:=$COURSEWARE_STATE_DIR/repos/LLM-Labs}"
: "${WIKI_RUNTIME_CONFIG_PATH:=$WIKI_DIR/public/courseware-runtime.json}"
: "${COURSEWARE_OLLAMA_BASE_URL:=http://$COURSEWARE_URL_HOST:$COURSEWARE_OLLAMA_PORT}"
: "${COURSEWARE_LAB1_QWEN_MODEL_PATH:=$COURSEWARE_STATE_DIR/models/lab1/Qwen3-0.6B-Q8_0.gguf}"
: "${COURSEWARE_LAB1_LLAMA_MODEL_PATH:=$COURSEWARE_STATE_DIR/models/lab1/Llama-3.2-1B.Q4_K_M.gguf}"
: "${COURSEWARE_LAB1_OLLAMA_MODEL_ALIAS:=lab1-qwen3-0.6b-q8_0}"
: "${LLAMA_CPP_BIN_DIR:=$COURSEWARE_STATE_DIR/repos/llama.cpp/build/bin}"
if [ -n "${OLLAMA_BIN:-}" ] && [[ "$OLLAMA_BIN" != */* ]] && command -v "$OLLAMA_BIN" >/dev/null 2>&1; then
@@ -42,7 +49,7 @@ service_list() {
printf '%s\n' \
"ollama" \
"open-webui" \
"transformerlab" \
"netron" \
"chunkviz" \
"embedding-atlas" \
"unsloth" \
@@ -63,7 +70,7 @@ service_port() {
case "$1" in
ollama) printf '%s\n' "${COURSEWARE_OLLAMA_PORT}" ;;
open-webui) printf '%s\n' "${COURSEWARE_OPEN_WEBUI_PORT}" ;;
transformerlab) printf '%s\n' "${COURSEWARE_TRANSFORMERLAB_PORT}" ;;
netron) printf '%s\n' "${COURSEWARE_NETRON_PORT}" ;;
chunkviz) printf '%s\n' "${COURSEWARE_CHUNKVIZ_PORT}" ;;
embedding-atlas) printf '%s\n' "${COURSEWARE_EMBEDDING_ATLAS_PORT}" ;;
unsloth) printf '%s\n' "${COURSEWARE_UNSLOTH_PORT}" ;;
@@ -78,7 +85,7 @@ service_url() {
case "$1" in
ollama) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_OLLAMA_PORT" ;;
open-webui) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_OPEN_WEBUI_PORT" ;;
transformerlab) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_TRANSFORMERLAB_PORT" ;;
netron) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_NETRON_PORT" ;;
chunkviz) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_CHUNKVIZ_PORT" ;;
embedding-atlas) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_EMBEDDING_ATLAS_PORT" ;;
unsloth) printf 'http://%s:%s\n' "$COURSEWARE_URL_HOST" "$COURSEWARE_UNSLOTH_PORT" ;;
@@ -107,14 +114,11 @@ service_command() {
"$COURSEWARE_BIND_HOST" \
"$COURSEWARE_OPEN_WEBUI_PORT"
;;
transformerlab)
printf 'export PATH="%s/envs/transformerlab/bin:$PATH"; export VIRTUAL_ENV="%s/envs/transformerlab"; export CONDA_PREFIX="%s/envs/transformerlab"; cd "%s/src" && exec ./run.sh -c -h %s -p %s' \
"$TRANSFORMERLAB_DIR" \
"$TRANSFORMERLAB_DIR" \
"$TRANSFORMERLAB_DIR" \
"$TRANSFORMERLAB_DIR" \
netron)
printf 'exec "%s/bin/netron" --host %s --port %s --verbosity quiet' \
"$NETRON_VENV" \
"$COURSEWARE_BIND_HOST" \
"$COURSEWARE_TRANSFORMERLAB_PORT"
"$COURSEWARE_NETRON_PORT"
;;
chunkviz)
printf 'cd "%s" && PATH="%s:$PATH" exec "./node_modules/.bin/serve" build -s -n -L -l tcp://%s:%s' \
@@ -145,9 +149,13 @@ service_command() {
"$COURSEWARE_PROMPTFOO_PORT"
;;
wiki)
printf 'cd "%s" && PATH="%s:$PATH" exec "./node_modules/.bin/next" start --hostname %s --port %s' \
printf 'cd "%s" && PATH="%s:$PATH" exec env COURSEWARE_OLLAMA_BASE_URL="%s" COURSEWARE_LAB1_QWEN_MODEL_PATH="%s" COURSEWARE_LAB1_LLAMA_MODEL_PATH="%s" COURSEWARE_LAB1_OLLAMA_MODEL_ALIAS="%s" "./node_modules/.bin/next" start --hostname %s --port %s' \
"$WIKI_DIR" \
"$NODE_RUNTIME_BIN_DIR" \
"$COURSEWARE_OLLAMA_BASE_URL" \
"$COURSEWARE_LAB1_QWEN_MODEL_PATH" \
"$COURSEWARE_LAB1_LLAMA_MODEL_PATH" \
"$COURSEWARE_LAB1_OLLAMA_MODEL_ALIAS" \
"$COURSEWARE_BIND_HOST" \
"$COURSEWARE_WIKI_PORT"
;;
Executable → Regular
+40 -51
View File
@@ -9,25 +9,6 @@ load_runtime_env
mkdir -p "$STATE_DIR/run" "$STATE_DIR/logs"
ensure_transformerlab_default_user() {
local helper_python="${TRANSFORMERLAB_DIR}/envs/transformerlab/bin/python"
if [ ! -x "$helper_python" ]; then
return 0
fi
if [ -z "${TRANSFORMERLAB_DEFAULT_USER_EMAIL:-}" ] || [ -z "${TRANSFORMERLAB_DEFAULT_USER_PASSWORD:-}" ]; then
return 0
fi
"$helper_python" "$SCRIPT_DIR/ensure_transformerlab_user.py" \
--transformerlab-dir "$TRANSFORMERLAB_DIR" \
--email "$TRANSFORMERLAB_DEFAULT_USER_EMAIL" \
--password "$TRANSFORMERLAB_DEFAULT_USER_PASSWORD" \
--first-name "${TRANSFORMERLAB_DEFAULT_USER_FIRST_NAME:-Student}" \
--last-name "${TRANSFORMERLAB_DEFAULT_USER_LAST_NAME:-}" >>"$STATE_DIR/logs/transformerlab_default_user.log" 2>&1 || true
}
check_wetty_prereqs() {
if [ ! -x "$WETTY_BIN" ]; then
echo "Missing WeTTY binary at $WETTY_BIN. Re-run ./labctl up." >&2
@@ -56,6 +37,40 @@ PY
fi
}
ollama_version_gte_minimum() {
local version_output
local installed_version
if ! command -v "$OLLAMA_BIN" >/dev/null 2>&1; then
return 1
fi
version_output=$("$OLLAMA_BIN" --version 2>/dev/null || true)
installed_version=$(printf '%s' "$version_output" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
if [ -z "$installed_version" ]; then
return 1
fi
[ "$(printf '%s\n' "$COURSEWARE_OLLAMA_MIN_VERSION" "$installed_version" | sort -V | head -n 1)" = "$COURSEWARE_OLLAMA_MIN_VERSION" ]
}
assert_ollama_logprobs_support() {
if ollama_version_gte_minimum; then
return 0
fi
local version_output
version_output=$("$OLLAMA_BIN" --version 2>/dev/null || printf 'unknown')
cat <<EOF >&2
Lab 1 requires Ollama ${COURSEWARE_OLLAMA_MIN_VERSION} or newer because the confidence visualizer depends on logprobs.
Installed version: ${version_output}
Re-run ./labctl up after upgrading Ollama.
EOF
exit 1
}
resolve_targets() {
if [ $# -eq 0 ]; then
echo "No target specified." >&2
@@ -104,13 +119,10 @@ service_ready() {
ollama)
curl -fsS "$(service_url "$service")/api/tags" >/dev/null 2>&1
;;
transformerlab)
curl -fsS "$(service_url "$service")/healthz" >/dev/null 2>&1
;;
promptfoo)
curl -fsS "$(service_url "$service")/health" >/dev/null 2>&1
;;
open-webui|chunkviz|embedding-atlas|unsloth|wiki|wetty)
open-webui|netron|chunkviz|embedding-atlas|unsloth|wiki|wetty)
curl -fsS "$(service_url "$service")" >/dev/null 2>&1
;;
*)
@@ -166,18 +178,16 @@ start_one() {
local attempt
local pid_grace_attempts=5
if [ "$service" = "ollama" ] || [ "$service" = "wiki" ]; then
assert_ollama_logprobs_support
fi
if has_live_pid "$service"; then
if [ "$service" = "transformerlab" ]; then
ensure_transformerlab_default_user
fi
echo "$service already running"
return 0
fi
if service_ready "$service"; then
if [ "$service" = "transformerlab" ]; then
ensure_transformerlab_default_user
fi
echo "$service already available"
return 0
fi
@@ -186,24 +196,6 @@ start_one() {
open-webui)
start_one ollama
;;
transformerlab)
if command -v python3 >/dev/null 2>&1; then
python3 "$SCRIPT_DIR/repair_transformerlab_plugin_supports.py" \
--transformerlab-dir "$TRANSFORMERLAB_DIR" \
--plugin "fastchat_server" \
--required-support "chat" \
--required-support "completion" \
--required-support "visualize_model" \
--required-support "model_layers" \
--required-support "rag" \
--required-support "tools" \
--required-support "template" \
--required-support "embeddings" \
--required-support "tokenize" \
--required-support "logprobs" \
--required-support "batched" >>"$STATE_DIR/logs/transformerlab_plugin_supports.log" 2>&1 || true
fi
;;
wetty)
check_wetty_prereqs
;;
@@ -229,9 +221,6 @@ start_one() {
for attempt in $(seq 1 60); do
if service_ready "$service"; then
if [ "$service" = "transformerlab" ]; then
ensure_transformerlab_default_user
fi
echo "started $service"
return 0
fi
@@ -313,7 +302,7 @@ urls() {
cat <<EOF
Ollama API: $(service_url ollama)
Open WebUI: $(service_url open-webui)
TransformerLab: $(service_url transformerlab)
Netron: $(service_url netron)
ChunkViz: $(service_url chunkviz)
Embedding Atlas: $(service_url embedding-atlas)
Unsloth Studio: $(service_url unsloth)