aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--CLAUDE.md10
-rw-r--r--README.md12
-rwxr-xr-xrunpod-session.sh44
4 files changed, 62 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ad1d5c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.bak
+state.json
+config
diff --git a/CLAUDE.md b/CLAUDE.md
index 4b1b242..734c6bb 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## What this is
-Single bash script (`runpod-session.sh`) that manages RunPod GPU pod lifecycle for running Ollama models, then patches `~/.config/opencode/opencode.jsonc` so opencode points at the live pod.
+Single bash script (`runpod-session.sh`) that manages RunPod GPU pod lifecycle for running Ollama models, then patches `~/.config/opencode/opencode.jsonc`, `transart.py`, and `my-publisher/config.toml` so all tools point at the live pod.
## Running / testing
@@ -31,14 +31,16 @@ All logic is in `main()` which runs these steps in order:
2. **Pod creation** — if none found: picks cheapest secure-cloud GPU under `MAX_PRICE_PER_HR`, creates pod with `ollama/ollama:latest` image, network volume mounted at `/workspace`
3. **Wait for Ollama** — polls `https://<pod-id>-11434.proxy.runpod.net/api/tags` until `.models` appears
4. **Patch opencode.json** — updates `baseURL`, active `model`, and merges `WARMUP_MODELS` into provider models block using jq `*` merge (existing config wins on conflicts)
-5. **Warmup** — POST to `/api/generate` with a dummy prompt to load model into VRAM at `WARMUP_NUM_CTX` context length
-6. **Save state** — writes `~/.config/runpod-session/state.json` with pod_id, url, model, timestamp
+5. **Patch external configs** — `patch_external_configs()` rewrites `OLLAMA_HOST` in `transart.py` and `ollama_host` in `my-publisher/config.toml` using `sed`; paths set via `TRANSART_SCRIPT` / `PUBLISHER_CONFIG` in config; skipped if empty or file missing
+6. **Warmup** — POST to `/api/generate` with a dummy prompt to load model into VRAM at `WARMUP_NUM_CTX` context length
+7. **Save state** — writes `~/.config/runpod-session/state.json` with pod_id, url, model, timestamp
## Key design constraints
- All RunPod calls go through `gql()` — single curl wrapper that exits on API errors
- Pod is identified by name matching `test("ollama"; "i")` — not by ID — so the name `ollama-session` set at creation must not change
- `patch_opencode_config()` writes a `.bak` before touching opencode.jsonc; jq `*` merge means existing per-model settings survive
+- `patch_external_configs()` uses `sed -i` on the bare pod URL (no `/v1`); writes `.bak` before each file; skips silently when var is empty, warns when path set but missing
- `OLLAMA_MODELS_PATH` env var on the pod is not set by the script — must be set in config if models live outside default location on the network volume
- GPU selection only queries `secureCloud == true` pods; community cloud is excluded
@@ -49,3 +51,5 @@ All logic is in `main()` which runs these steps in order:
| `~/.config/runpod-session/config` | Sourced as bash; holds API key, defaults |
| `~/.config/runpod-session/state.json` | Last session record (pod_id, url, model, timestamp) |
| `~/.config/opencode/opencode.jsonc` | Patched in-place; `.bak` written before changes |
+| `$TRANSART_SCRIPT` | `OLLAMA_HOST` rewritten on each session start; `.bak` written first |
+| `$PUBLISHER_CONFIG` | `ollama_host` rewritten on each session start; `.bak` written first |
diff --git a/README.md b/README.md
index d12d1ec..194ea00 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,10 @@ CONTAINER_DISK_GB=15
GPU_COUNT=1
STARTUP_TIMEOUT=240 # seconds to wait for Ollama to become reachable
WARMUP_NUM_CTX=32768 # context size used when pre-loading models into VRAM
+
+# External tool configs to patch with the live pod URL (leave empty to skip)
+TRANSART_SCRIPT="" # e.g. /home/user/bin/transart.py
+PUBLISHER_CONFIG="" # e.g. /home/user/.config/my-publisher/config.toml
```
## Usage
@@ -109,12 +113,14 @@ runpod-session.sh --new --gpu-type "RTX 4090" --max-price 1.80
4. **Startup wait** — polls `https://<pod-id>-11434.proxy.runpod.net/api/tags` every 5 seconds until Ollama responds (up to `STARTUP_TIMEOUT` seconds).
-5. **opencode.jsonc patch** — updates three fields in your opencode config:
+5. **Config patching** — updates your opencode config and any external tools configured via `TRANSART_SCRIPT` / `PUBLISHER_CONFIG`:
- `provider.runpod.options.baseURL` → the live pod URL
- `model` → `runpod/<DEFAULT_MODEL>`
- `provider.runpod.models` → merges all `WARMUP_MODELS` in (existing per-model settings are preserved via jq recursive merge)
+ - `OLLAMA_HOST` in `transart.py` → bare pod URL (no `/v1`)
+ - `ollama_host` in `my-publisher/config.toml` → bare pod URL (no `/v1`)
- A `.bak` copy is written before any changes.
+ A `.bak` copy is written before each file is modified. Entries left empty in config are skipped.
6. **Model warmup** — sends a short generation request to load the model into VRAM at `WARMUP_NUM_CTX` context length, so the first real request isn't slow.
@@ -146,6 +152,8 @@ Your `~/.config/opencode/opencode.jsonc` needs a `runpod` provider block before
| `~/.config/runpod-session/state.json` | Last session record |
| `~/.config/opencode/opencode.jsonc` | Patched on each session start |
| `~/.config/opencode/opencode.jsonc.bak` | Backup written before each patch |
+| `$TRANSART_SCRIPT` | `OLLAMA_HOST` updated if set in config |
+| `$PUBLISHER_CONFIG` | `ollama_host` updated if set in config |
## Cost notes
diff --git a/runpod-session.sh b/runpod-session.sh
index c81e8dd..faf0098 100755
--- a/runpod-session.sh
+++ b/runpod-session.sh
@@ -29,7 +29,7 @@ RUNPOD_API="https://api.runpod.io/graphql"
# ─── Defaults (overridden by config file) ─────────────────────────────────────
OLLAMA_IMAGE="ollama/ollama:latest"
-NETWORK_VOLUME_NAME="danixland-storage"
+NETWORK_VOLUME_NAME="my-storage"
OPENCODE_PROVIDER="runpod"
DEFAULT_MODEL="qwen3-coder:latest"
WARMUP_MODELS="qwen3-coder:latest translategemma:27b"
@@ -40,6 +40,8 @@ GPU_COUNT=1
POLL_INTERVAL=5
STARTUP_TIMEOUT=240
WARMUP_NUM_CTX=32768
+TRANSART_SCRIPT=""
+PUBLISHER_CONFIG=""
# ─── Colors ───────────────────────────────────────────────────────────────────
RED='\033[0;31m'; YELLOW='\033[1;33m'; GREEN='\033[0;32m'
@@ -66,7 +68,7 @@ if [[ ! -f "$SESSION_CONFIG" ]]; then
RUNPOD_API_KEY=""
# Network volume name as shown in RunPod dashboard
-NETWORK_VOLUME_NAME="danixland-storage"
+NETWORK_VOLUME_NAME="my-storage"
# Must match the key in your opencode.json "provider" block
OPENCODE_PROVIDER="runpod"
@@ -87,6 +89,10 @@ CONTAINER_DISK_GB=15
GPU_COUNT=1
STARTUP_TIMEOUT=240 # seconds before giving up waiting for Ollama
WARMUP_NUM_CTX=32768 # num_ctx used when warming up models into VRAM
+
+# External tool configs to patch with the live pod URL (leave empty to skip)
+TRANSART_SCRIPT="" # e.g. /home/user/bin/transart.py
+PUBLISHER_CONFIG="" # e.g. /home/user/.config/my-publisher/config.toml
CONF
echo ""
echo -e "${YELLOW}Edit ${BOLD}$SESSION_CONFIG${RESET}${YELLOW}, set RUNPOD_API_KEY, then re-run.${RESET}"
@@ -445,6 +451,36 @@ patch_opencode_config() {
log " model = ${OPENCODE_PROVIDER}/${DEFAULT_MODEL}"
}
+# ─── Patch external tool configs ─────────────────────────────────────────────
+#
+# Updates the Ollama host URL in:
+# transart.py — replaces OLLAMA_HOST = "..." (bare URL, no /v1)
+# config.toml — replaces ollama_host = "..." (bare URL, no /v1)
+#
+patch_external_configs() {
+ local bare_url="$1" # https://<pod-id>-11434.proxy.runpod.net (no /v1)
+
+ if [[ -n "${TRANSART_SCRIPT:-}" ]]; then
+ if [[ ! -f "$TRANSART_SCRIPT" ]]; then
+ warn "TRANSART_SCRIPT not found: $TRANSART_SCRIPT — skipping"
+ else
+ cp "$TRANSART_SCRIPT" "${TRANSART_SCRIPT}.bak"
+ sed -i "s|^OLLAMA_HOST = \".*\"|OLLAMA_HOST = \"${bare_url}\"|" "$TRANSART_SCRIPT"
+ ok "transart.py patched: OLLAMA_HOST = $bare_url"
+ fi
+ fi
+
+ if [[ -n "${PUBLISHER_CONFIG:-}" ]]; then
+ if [[ ! -f "$PUBLISHER_CONFIG" ]]; then
+ warn "PUBLISHER_CONFIG not found: $PUBLISHER_CONFIG — skipping"
+ else
+ cp "$PUBLISHER_CONFIG" "${PUBLISHER_CONFIG}.bak"
+ sed -i "s|^ollama_host = \".*\"|ollama_host = \"${bare_url}\"|" "$PUBLISHER_CONFIG"
+ ok "my-publisher config patched: ollama_host = $bare_url"
+ fi
+ fi
+}
+
# ─── Warm up one model ────────────────────────────────────────────────────────
warmup_model() {
local pod_id="$1" model="$2"
@@ -582,6 +618,10 @@ main() {
# ── 5. Patch opencode.json ────────────────────────────────────────────────
patch_opencode_config "$ollama_url"
+ # ── 5b. Patch external tool configs (transart, my-publisher) ─────────────
+ local bare_url="https://${pod_id}-11434.proxy.runpod.net"
+ patch_external_configs "$bare_url"
+
# ── 6. Warmup ─────────────────────────────────────────────────────────────
if [[ $OPT_ALL_MODELS -eq 1 ]]; then
for m in $WARMUP_MODELS; do