v0.4.0 - NIM installer + dashboard resilience
Hotfix (was v0.3.1):
- services.py: cache 'unreachable' per (host,user) for 25s so a dead Spark doesn't hang every /api/services call behind 6s ssh timeout
- ssh_run timeout reduced 10 -> 6s for docker_state probes
- hardware probe: shorter SSH timeout (6s), longer cache TTL for failures (25s)
- JS pollStatus retries loadModels() if state.models is empty (recovers from cold-start proxy timeout)
- Unreachable hardware card now includes troubleshooting steps (Spark Control cannot SSH into an unreachable Spark to restart it)
v0.4 NIM installer:
- nim.py module: curated SUGGESTED_NIMS list (Parakeet, Magpie, Riva) + NimManager that runs docker login nvcr.io + docker pull + docker run -d --gpus all -p PORT:PORT -v VOL:/opt/nim/.cache -e NGC_API_KEY -e ... --restart=unless-stopped + chown the volume to uid 1000 + restart. Streams all output via SSE; redacts the API key from log lines.
- custom_services.py: persists installed NIMs to /data/services-overrides.yaml so they appear in the services panel after install
- services.py: merges custom services into the panel
- /api/nim/catalog GET, /api/nim/install POST + GET/SSE
- /api/services/{name} DELETE for custom services
- UI: '+ Install NIM' button next to 'Always-on services'; modal lists curated images each with a 'Pick' button + a custom-image form; installation runs in a second dialog with phase + elapsed timer + collapsible log
- NGC API key field added to Configure Sparks (masked); injected as NGC_API_KEY env var into the container
Package: bump 0.4.0:0; main.ts adds SERVICES_OVERRIDES + NGC_API_KEY env vars
This commit is contained in:
@@ -144,6 +144,15 @@ function renderHardware() {
|
||||
<span class="meta">unreachable</span>
|
||||
</div>
|
||||
<div class="muted small">${escapeHtml(s.host || '')} — ${escapeHtml(s.error || 'no response')}</div>
|
||||
<div class="muted small" style="line-height:1.5">
|
||||
Spark Control can't restart a Spark that won't answer SSH. Steps to try:
|
||||
<ol style="margin: 6px 0 0 18px; padding: 0;">
|
||||
<li>Verify it's powered on (check the front LED).</li>
|
||||
<li>Ping it from another LAN device.</li>
|
||||
<li>Power-cycle it physically.</li>
|
||||
<li>If it boots, this card will go green again automatically.</li>
|
||||
</ol>
|
||||
</div>
|
||||
`;
|
||||
grid.appendChild(card);
|
||||
continue;
|
||||
@@ -510,6 +519,10 @@ async function pollStatus() {
|
||||
renderCurrent(status);
|
||||
renderEndpoint(status);
|
||||
renderHealth(status);
|
||||
// If models hasn't loaded yet (init may have hit a transient proxy timeout), retry.
|
||||
if (!state.models || Object.keys(state.models).length === 0) {
|
||||
try { await loadModels(); } catch {}
|
||||
}
|
||||
// Refresh services state lazily — every 5s poll triggers this too.
|
||||
try {
|
||||
state.services = await fetchJSON('/api/services');
|
||||
@@ -953,6 +966,147 @@ function setupAdvancedDialog() {
|
||||
el('#adv-gmu').addEventListener('input', (e) => { el('#adv-gmu-out').value = parseFloat(e.target.value).toFixed(2); });
|
||||
}
|
||||
|
||||
// ===================== NIM installer =====================
|
||||
|
||||
const nimState = {
|
||||
catalog: null,
|
||||
job_id: null,
|
||||
eventsource: null,
|
||||
timer: null,
|
||||
started_at: null,
|
||||
};
|
||||
|
||||
async function loadNimCatalog() {
|
||||
try {
|
||||
nimState.catalog = await fetchJSON('/api/nim/catalog');
|
||||
el('#nim-catalog-link').href = nimState.catalog.catalog_url;
|
||||
const warn = el('#nim-key-warn');
|
||||
if (!nimState.catalog.ngc_key_configured) {
|
||||
warn.classList.add('nim-key-warn');
|
||||
warn.innerHTML = '⚠️ NGC API key not set. Open <strong>Configure Sparks</strong> in StartOS and paste your NGC personal API key, otherwise installs will fail. <a href="https://ngc.nvidia.com/setup/personal-key" target="_blank" rel="noopener">Get a key</a>';
|
||||
} else {
|
||||
warn.classList.remove('nim-key-warn');
|
||||
warn.textContent = '';
|
||||
}
|
||||
const grid = el('#nim-suggested');
|
||||
grid.innerHTML = '';
|
||||
for (const s of nimState.catalog.suggested || []) {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'nim-card';
|
||||
card.innerHTML = `
|
||||
<div class="info">
|
||||
<div class="name">${escapeHtml(s.name)} <span class="muted small">· ${escapeHtml(s.kind || 'nim')}</span></div>
|
||||
<div class="desc">${escapeHtml(s.description || '')}</div>
|
||||
<div class="img">${escapeHtml(s.image)}</div>
|
||||
<div class="links">${s.homepage ? `<a href="${escapeHtml(s.homepage)}" target="_blank" rel="noopener">View on NGC ↗</a>` : ''}</div>
|
||||
</div>
|
||||
<button type="button" class="btn primary nim-pick" data-image="${escapeHtml(s.image)}" data-container="${escapeHtml(s.default_container)}" data-port="${s.default_port}" data-kind="${escapeHtml(s.kind)}">Pick</button>
|
||||
`;
|
||||
grid.appendChild(card);
|
||||
}
|
||||
grid.querySelectorAll('.nim-pick').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
el('#nim-image').value = btn.dataset.image;
|
||||
el('#nim-container').value = btn.dataset.container;
|
||||
el('#nim-port').value = btn.dataset.port;
|
||||
el('#nim-kind').value = btn.dataset.kind || 'nim';
|
||||
});
|
||||
});
|
||||
} catch (e) { console.warn('nim catalog failed', e); }
|
||||
}
|
||||
|
||||
function openNimDialog() {
|
||||
loadNimCatalog();
|
||||
el('#nim-dialog').showModal();
|
||||
}
|
||||
|
||||
async function submitNim(e) {
|
||||
e.preventDefault();
|
||||
const body = {
|
||||
image: el('#nim-image').value.trim(),
|
||||
container: el('#nim-container').value.trim(),
|
||||
port: parseInt(el('#nim-port').value, 10),
|
||||
host: el('#nim-host').value,
|
||||
kind: el('#nim-kind').value,
|
||||
};
|
||||
if (!body.image || !body.container || !body.port) {
|
||||
alert('Image, container name, and port are required.');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const r = await fetchJSON('/api/nim/install', {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
el('#nim-dialog').close();
|
||||
attachNimProgress(r.job_id);
|
||||
} catch (e) {
|
||||
alert('Install failed: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
function nimTimerStart(at) {
|
||||
nimState.started_at = at;
|
||||
if (nimState.timer) clearInterval(nimState.timer);
|
||||
const tick = () => {
|
||||
if (!nimState.started_at) return;
|
||||
const sec = Math.max(0, Math.floor((Date.now() - nimState.started_at) / 1000));
|
||||
const m = Math.floor(sec / 60);
|
||||
const s = sec % 60;
|
||||
el('#nim-prog-elapsed').textContent = `${m}:${s.toString().padStart(2, '0')}`;
|
||||
};
|
||||
tick();
|
||||
nimState.timer = setInterval(tick, 500);
|
||||
}
|
||||
|
||||
async function attachNimProgress(jobId) {
|
||||
nimState.job_id = jobId;
|
||||
el('#nim-prog-log').textContent = '';
|
||||
el('#nim-prog-title').textContent = 'Installing…';
|
||||
el('#nim-progress-dialog').showModal();
|
||||
try {
|
||||
const snap = await fetchJSON(`/api/nim/install/${jobId}`);
|
||||
nimTimerStart(Date.parse(snap.started_at));
|
||||
el('#nim-prog-phase').textContent = snap.phase || 'Working…';
|
||||
el('#nim-prog-log').textContent = (snap.lines || []).join('\n');
|
||||
if (snap.returncode !== null) { onNimDone(snap); return; }
|
||||
} catch { nimTimerStart(Date.now()); }
|
||||
const es = new EventSource(`/api/nim/install/${jobId}/stream`);
|
||||
nimState.eventsource = es;
|
||||
es.onmessage = ev => {
|
||||
try {
|
||||
const d = JSON.parse(ev.data);
|
||||
if (d.line !== undefined) {
|
||||
const log = el('#nim-prog-log');
|
||||
log.textContent += d.line + '\n';
|
||||
log.scrollTop = log.scrollHeight;
|
||||
}
|
||||
} catch {}
|
||||
};
|
||||
es.addEventListener('phase', ev => {
|
||||
try { el('#nim-prog-phase').textContent = JSON.parse(ev.data).phase; } catch {}
|
||||
});
|
||||
es.addEventListener('done', ev => {
|
||||
let d = {}; try { d = JSON.parse(ev.data); } catch {}
|
||||
onNimDone(d);
|
||||
});
|
||||
es.onerror = () => { es.close(); nimState.eventsource = null; };
|
||||
}
|
||||
|
||||
function onNimDone(d) {
|
||||
if (nimState.eventsource) { nimState.eventsource.close(); nimState.eventsource = null; }
|
||||
if (nimState.timer) { clearInterval(nimState.timer); nimState.timer = null; }
|
||||
if (d.state === 'failed') {
|
||||
el('#nim-prog-title').textContent = `Failed (rc=${d.returncode})`;
|
||||
el('#nim-prog-phase').textContent = 'Failed';
|
||||
} else {
|
||||
el('#nim-prog-title').textContent = 'Installed';
|
||||
el('#nim-prog-phase').textContent = 'Done ✓ — service will appear when the container reports healthy.';
|
||||
}
|
||||
pollStatus();
|
||||
}
|
||||
|
||||
// ===================== Explain context (LLM commit summary) =====================
|
||||
|
||||
let explainEventSource = null;
|
||||
@@ -1149,6 +1303,10 @@ async function init() {
|
||||
el('#ub-apply').addEventListener('click', applyUpdate);
|
||||
el('#ub-explain').addEventListener('click', explainContext);
|
||||
el('#dl-repo').addEventListener('input', updateDlHfLink);
|
||||
el('#open-nim').addEventListener('click', openNimDialog);
|
||||
el('#nim-cancel').addEventListener('click', () => el('#nim-dialog').close());
|
||||
el('#nim-form').addEventListener('submit', submitNim);
|
||||
el('#nim-prog-close').addEventListener('click', () => el('#nim-progress-dialog').close());
|
||||
setupCatalogDialog();
|
||||
setupAdvancedDialog();
|
||||
// Open WebUI link from /api/config
|
||||
|
||||
Reference in New Issue
Block a user