Spaces:
Paused
Paused
Deploy Sensorflow Studio (part 6)
Browse filesFiles changed (4)
- static/app.js+495-49
- static/index.html+69-5
- static/style.css+208
- tests/test_pipeline/test_auto_label_integrity.pyAdded+124
1 unmodified line23456722 unmodified lines303132333435363738394018 unmodified lines5960616263646566679 unmodified lines7778798081828384858639 unmodified lines12612712812913013113242 unmodified lines1751761771781791801811821831841852 unmodified lines18818919019119219319419519641 unmodified lines23823924024124224324424543 unmodified lines289290291292293294295102 unmodified lines3983994004014024034044052 unmodified lines40840941041141241341441541641741841942042142224 unmodified lines4474484494504514524534544554564574584594605 unmodified lines466467468469470471472473474475476140 unmodified lines617618619620621622623624625626627130 unmodified lines75875976076176276376474 unmodified lines83984084184284384484584684784884985096 unmodified lines94794894995095195295312 unmodified lines96696796896997097197221 unmodified lines994995996997998999100013 unmodified lines101410151016101710181019102010211022102310241025102610271028102910301031280 unmodified lines1312131313141315131613171318508 unmodified lines182718281829183018311832183318341835241 unmodified lines2077207820792080208120821 unmodified line20842085208620872088208920902091209220932094209520962097209820992100227 unmodified lines23282329233023311 unmodified line// API base URLconst API_BASE = '';// Stage Navigationconst navButtons = document.querySelectorAll('.nav-btn');const panels = document.querySelectorAll('.stage-panel');22 unmodified lineslet pipelineState = {};let currentSequenceId = 'seq_001';async function refreshPipelineStatus() {try {const res = await fetch(`${API_BASE}/api/pipeline/status?sequence_id=${currentSequenceId}`);const data = await res.json();pipelineState = data;updateGateBadges();} catch (e) { /* backend offline */ }}18 unmodified linesif (meta.completionOnly) {if (verdict === true) {badge.textContent = 'PASS';badge.style.background = '#00ffaa33';badge.style.color = '#00ffaa';} else {badge.textContent = '';}9 unmodified linesbadge.style.background = '#ff444433';badge.style.color = '#ff4444';} else if (completed === true) {// Ran stage artifact exists but no explicit pass/fail yetbadge.textContent = 'PASS';badge.style.background = '#00ffaa33';badge.style.color = '#00ffaa';} else {badge.textContent = '';}39 unmodified linesconst currentStage = document.querySelector('.nav-btn.active')?.dataset.stage;const meta = STAGE_METADATA[currentStage];if (meta && meta.gateKey && pipelineState[meta.gateKey] === false) {alert('Launch gate not passed. Complete the quality gate first.');return;}switchStage(nextBtn.dataset.next);42 unmodified linessource_path: datasetSourcePath.value})});const data = await res.json();alert('Configuration saved & verified successfully!');} catch (e) {console.error(e);alert('Failed to save dataset configuration.');}});2 unmodified linestry {const res = await fetch(`${API_BASE}/api/precheck`);const data = await res.json();alert(`Pre-Check Complete!\n\nStatus: ${data.status}\nDetails: ${data.message}`);} catch (e) {alert('Failed to complete pre-check.');}});41 unmodified lines})});const data = await res.json();// Start polling logs and statuspollTraining();trainInterval = setInterval(pollTraining, 1500);} catch (e) {43 unmodified lines}if (!status.running) {terminalLogs.textContent += '\n--- Process finished ---\n';resetTrainingUI();}} catch (e) {102 unmodified lines})});const data = await res.json();// Populate select dropdownselectInferImage.innerHTML = '';if (data.images && data.images.length > 0) {data.images.forEach(img => {2 unmodified linesopt.textContent = img;selectInferImage.appendChild(opt);});// Trigger image loadloadImage(data.images[0]);} else {selectInferImage.innerHTML = '<option value="">No images found</option>';}alert('Inference finished successfully!');} catch (e) {console.error(e);alert('Inference execution failed.');} finally {btnRunInfer.textContent = '⚡ Run Auto-Labeler';btnRunInfer.disabled = false;24 unmodified linestry {const res = await fetch(`${API_BASE}/api/grade`);const data = await res.json();graderScore.textContent = data.quality_score.toFixed(1);statTotalImgs.textContent = data.total_images;statTotalPreds.textContent = data.total_predictions;// Render issues listgraderIssuesList.innerHTML = '';if (data.issues && data.issues.length > 0) {data.issues.forEach(issue => {const el = document.createElement('div');el.className = `issue-card ${issue.severity.toLowerCase()}`;5 unmodified linesgraderIssuesList.appendChild(el);});} else {graderIssuesList.innerHTML = '<div class="empty-state">✅ Perfect score! No quality anomalies detected.</div>';}} catch (e) {console.error(e);alert('Failed to run quality diagnostics.');} finally {btnRunGrader.textContent = 'Run Quality Diagnostics';btnRunGrader.disabled = false;140 unmodified linescurrentMitlData = data.data;originalCocText = currentMitlData.coc_trace;renderMitlData();alert(`Dataset loaded successfully: ${currentMitlData.dataset}`);}} catch (e) {console.error(e);alert('Failed to load NVIDIA dataset.');}}130 unmodified lines}} catch (e) {console.error(e);alert('Catalog metadata load failed.');} finally {btnPreprocessDataset.textContent = 'Load Catalog Metadata';btnPreprocessDataset.disabled = false;74 unmodified lines});const data = await res.json();if (data.status === 'ok') {alert(`Pipeline configuration saved!\n\n- Annotation: ${annotationTool}\n- Training: ${trainingFramework}\n- Validation: ${validationMethod}`);pipelineWizardModal.classList.add('hidden');}} catch (e) {console.error(e);alert('Failed to save pipeline configuration settings.');} finally {btnWizardSubmit.textContent = 'Save Pipeline Configuration';btnWizardSubmit.disabled = false;96 unmodified lines// Add Box HandlerbtnMitlAddBox.addEventListener('click', () => {if (!currentMitlData) {alert('Please load a dataset first.');return;}const nextId = currentMitlData.annotations.length > 012 unmodified lines// Save Human EditsbtnMitlSave.addEventListener('click', async () => {if (!currentMitlData) {alert('No dataset currently loaded to save.');return;}21 unmodified lines});if (parseError) {alert('Invalid bounding box format. Please enter coordinates in format [x, y, w, h].');return;}13 unmodified lines// Update local memorycurrentMitlData.annotations = updatedAnns;currentMitlData.coc_trace = mitlCocTrace.value;alert('Triage results successfully saved to runs/mitl_annotations.json!');}} catch (e) {console.error(e);alert('Failed to save human edits.');}});// Ask Gemma 4 critiquebtnMitlAudit.addEventListener('click', async () => {if (!currentMitlData) {alert('No dataset currently loaded to audit.');return;}280 unmodified lines}} catch (e) {console.error(e);alert("Failed to toggle MCP server state.");checkbox.checked = !checkbox.checked;bullet.style.transform = checkbox.checked ? 'translateX(22px)' : 'none';updateSliderStyle();508 unmodified lines}),});ssamState.selectedRow.manual_annotation = ssamDrawerAnnotation.value;alert(`Annotation saved for ${ssamState.selectedRow.street_name}`);} catch (e) {alert('Failed to save annotation.');} finally {ssamDrawerSave.textContent = 'Save Annotation';ssamDrawerSave.disabled = false;241 unmodified linesconst statusEl = document.getElementById('perception-status');statusEl.textContent = 'Running SAM auto-label...';try {const res = await fetch(`${API_BASE}/api/perception/auto-label`, {method: 'POST',headers: { 'Content-Type': 'application/json' },1 unmodified linesequence_id: currentSequenceId,sam_checkpoint: document.getElementById('perception-sam-checkpoint')?.value || 'models/sam_vit_b.pth',device: document.getElementById('perception-device')?.value || 'cpu',no_sam: true,}),});const data = await res.json();if (data.status === 'ok') {const stubPrefix = data.demo_stub ? 'demo stub: ' : '';const expected = data.frames_expected != null ? `/${data.frames_expected}` : '';statusEl.textContent =`${stubPrefix}Processed ${data.frames_processed}${expected} frames -> ${data.proposals_dir}`;} else {statusEl.textContent = `Error: ${data.detail || JSON.stringify(data)}`;}await refreshPipelineStatus();await refreshAllOutputBrowsers();227 unmodified lines}});}});1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545522 unmodified lines7879808182838485868788899091929394959697989910010110210310418 unmodified lines1231241251261271281291301319 unmodified lines14114214314414514614714814939 unmodified lines18919019119219319419542 unmodified lines2382392402412422432442452462472482492502512522532542 unmodified lines25725825926026126226326426526626741 unmodified lines30931031131231331431531631731831932032132232332432532632743 unmodified lines371372373374375376377378379380381382383384385386387388389390391392393102 unmodified lines4964974984995005015025035045055065075085095105115122 unmodified lines51551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055124 unmodified lines5765775785795805815825835845855865875885895905915925935945955965975985995 unmodified lines605606607608609610611612613614615616617618619620621622623624625626627140 unmodified lines768769770771772773774775776777778130 unmodified lines90991091191291391491591691774 unmodified lines992993994995996997998999100010011002100310041005100696 unmodified lines110311041105110611071108110912 unmodified lines112211231124112511261127112821 unmodified lines115011511152115311541155115613 unmodified lines117011711172117311741175117611771178117911801181118211831184118511861187280 unmodified lines1468146914701471147214731474508 unmodified lines198319841985198619871988198919901991241 unmodified lines22332234223522362237223822391 unmodified line224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303227 unmodified lines25312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627771 unmodified line// API base URLconst API_BASE = '';// Non-blocking status signaling (replaces window.alert for routine feedback)const toastStack = document.getElementById('toast-stack');const TOAST_ICONS = { success: '✓', error: '✕', warning: '!', info: 'ℹ' };const TOAST_DEFAULT_MS = { success: 3800, info: 4200, warning: 5200, error: 6500 };function notify(message, type = 'info', options = {}) {if (!toastStack || message == null || message === '') return;const kind = ['success', 'error', 'warning', 'info'].includes(type) ? type : 'info';const duration = options.duration ?? TOAST_DEFAULT_MS[kind];const el = document.createElement('div');el.className = `toast toast-${kind}`;el.setAttribute('role', kind === 'error' ? 'alert' : 'status');const icon = document.createElement('span');icon.className = 'toast-icon';icon.textContent = TOAST_ICONS[kind];icon.setAttribute('aria-hidden', 'true');const body = document.createElement('div');body.className = 'toast-body';body.textContent = String(message);const close = document.createElement('button');close.type = 'button';close.className = 'toast-close';close.setAttribute('aria-label', 'Dismiss');close.textContent = '×';let hideTimer = null;const dismiss = () => {if (hideTimer) clearTimeout(hideTimer);el.classList.add('toast-out');setTimeout(() => el.remove(), 180);};close.addEventListener('click', dismiss);el.appendChild(icon);el.appendChild(body);el.appendChild(close);toastStack.appendChild(el);if (duration > 0) {hideTimer = setTimeout(dismiss, duration);}return dismiss;}// Stage Navigationconst navButtons = document.querySelectorAll('.nav-btn');const panels = document.querySelectorAll('.stage-panel');22 unmodified lineslet pipelineState = {};let currentSequenceId = 'seq_001';async function syncActiveSequence() {try {const cfg = await fetch(`${API_BASE}/api/config`).then((r) => r.json());if (cfg?.sequence_id) {currentSequenceId = cfg.sequence_id;return;}} catch (e) { /* ignore */ }try {const st = await fetch(`${API_BASE}/api/pipeline/status?sequence_id=${encodeURIComponent(currentSequenceId)}`).then((r) => r.json());if (st?.active_sequence_id) currentSequenceId = st.active_sequence_id;} catch (e) { /* ignore */ }}async function refreshPipelineStatus() {try {await syncActiveSequence();const res = await fetch(`${API_BASE}/api/pipeline/status?sequence_id=${encodeURIComponent(currentSequenceId)}`);const data = await res.json();pipelineState = data;if (data.active_sequence_id) currentSequenceId = data.active_sequence_id;updateGateBadges();} catch (e) { /* backend offline */ }}18 unmodified linesif (meta.completionOnly) {if (verdict === true) {badge.textContent = pipelineState.demo_stub ? 'STUB' : 'DONE';badge.style.background = pipelineState.demo_stub ? '#fbbf2433' : '#00ffaa33';badge.style.color = pipelineState.demo_stub ? '#fbbf24' : '#00ffaa';} else {badge.textContent = '';}9 unmodified linesbadge.style.background = '#ff444433';badge.style.color = '#ff4444';} else if (completed === true) {badge.textContent = 'RAN';badge.style.background = '#3b82f633';badge.style.color = '#93c5fd';} else {badge.textContent = '';}39 unmodified linesconst currentStage = document.querySelector('.nav-btn.active')?.dataset.stage;const meta = STAGE_METADATA[currentStage];if (meta && meta.gateKey && pipelineState[meta.gateKey] === false) {notify('Launch gate not passed. Complete the quality gate first.', 'warning');return;}switchStage(nextBtn.dataset.next);42 unmodified linessource_path: datasetSourcePath.value})});if (!res.ok) throw new Error(`HTTP ${res.status}`);const data = await res.json();notify('Configuration saved (YAML/paths not yet executed).', 'success');const cfgStatus = document.getElementById('config-exec-status');if (cfgStatus) {cfgStatus.textContent = 'CONFIGURATION SAVED / not yet used by an execution — run Load & Preprocess.';cfgStatus.dataset.modified = '1';}} catch (e) {console.error(e);notify('Failed to save dataset configuration.', 'error');}});2 unmodified linestry {const res = await fetch(`${API_BASE}/api/precheck`);const data = await res.json();const precheckType = data.verified ? 'success' : 'warning';notify(`Pre-check: ${data.status}\n${data.message || ''}`, precheckType);refreshScriptStatus(data.scripts);} catch (e) {notify('Failed to complete pre-check.', 'error');}});41 unmodified lines})});const data = await res.json();if (!res.ok) {terminalLogs.textContent += `Error: ${JSON.stringify(data)}\n`;resetTrainingUI();notify(data.detail?.message || data.detail || 'Failed to start training', 'error');return;}renderEvidenceCard('evidence-training', {status: 'RUNNING',execution_id: data.execution_id,process_id: data.process_id,command: data.command,message: 'Training process spawned',});pollTraining();trainInterval = setInterval(pollTraining, 1500);} catch (e) {43 unmodified lines}if (!status.running) {const verdict = status.status || (status.exit_code === 0 ? 'SUCCEEDED' : 'FAILED');terminalLogs.textContent += `\n--- Process finished: ${verdict} exit_code=${status.exit_code} ---\n`;renderEvidenceCard('evidence-training', {status: verdict,execution_id: status.execution_id,exit_code: status.exit_code,process_id: status.process_id,command: status.command,metrics: {epochs_observed: status.epochs_observed,epochs_requested: status.epochs_requested,checkpoint: status.checkpoint,losses_parsed: (status.losses || []).length,},message: `Training ${verdict}`,});refreshExecutionConsole();resetTrainingUI();}} catch (e) {102 unmodified lines})});const data = await res.json();if (!res.ok) {const detail = data.detail?.message || data.detail || JSON.stringify(data);notify(`Inference failed: ${detail}`, 'error');renderEvidenceCard('evidence-inference', {status: 'FAILED',execution_id: data.detail?.execution_id || data.execution_id,message: detail,});return;}selectInferImage.innerHTML = '';if (data.images && data.images.length > 0) {data.images.forEach(img => {2 unmodified linesopt.textContent = img;selectInferImage.appendChild(opt);});loadImage(data.images[0]);} else {selectInferImage.innerHTML = '<option value="">No images found</option>';}renderEvidenceCard('evidence-inference', {status: data.status,execution_id: data.execution_id,duration_ms: data.duration_ms,model: data.model,checkpoint: data.checkpoint,metrics: {discovered: data.records_discovered,processed: data.records_processed,succeeded: data.records_succeeded,failed: data.records_failed,inference_calls: data.inference_calls,predictions: data.predictions_generated,output_dir: data.output_dir,exit_code: data.exit_code,},message: data.message,});refreshExecutionConsole();if (data.status === 'SUCCEEDED' || data.status === 'PARTIAL_SUCCESS') {notify(`Inference ${data.status}: ${data.records_succeeded}/${data.records_discovered} images`, 'success');} else {notify(`Inference ${data.status}: ${data.message || 'see evidence'}`, 'warning');}} catch (e) {console.error(e);notify('Inference execution failed.', 'error');} finally {btnRunInfer.textContent = '⚡ Run Auto-Labeler';btnRunInfer.disabled = false;24 unmodified linestry {const res = await fetch(`${API_BASE}/api/grade`);const data = await res.json();if (!res.ok) {notify(data.detail?.message || data.detail || 'Grader failed', 'error');renderEvidenceCard('evidence-grader', {status: 'FAILED',execution_id: data.detail?.execution_id || data.execution_id,message: data.detail?.message || data.detail,});return;}graderScore.textContent = data.quality_score != null ? Number(data.quality_score).toFixed(1) : '—';statTotalImgs.textContent = data.total_images ?? '—';statTotalPreds.textContent = data.total_predictions ?? '—';graderIssuesList.innerHTML = '';if (data.status === 'NOT_EXECUTED') {graderIssuesList.innerHTML = '<div class="empty-state">NOT_EXECUTED — no predictions artifact. This is not a perfect score.</div>';} else if (data.issues && data.issues.length > 0) {data.issues.forEach(issue => {const el = document.createElement('div');el.className = `issue-card ${issue.severity.toLowerCase()}`;5 unmodified linesgraderIssuesList.appendChild(el);});} else {graderIssuesList.innerHTML = '<div class="empty-state">No quality anomalies reported by grader output (not a claim of ground-truth perfection).</div>';}renderEvidenceCard('evidence-grader', {status: data.status,execution_id: data.execution_id,duration_ms: data.duration_ms,metrics: data.metrics || {total_images: data.total_images,total_predictions: data.total_predictions,quality_score: data.quality_score,},message: data.message,});refreshExecutionConsole();} catch (e) {console.error(e);notify('Failed to run quality diagnostics.', 'error');} finally {btnRunGrader.textContent = 'Run Quality Diagnostics';btnRunGrader.disabled = false;140 unmodified linescurrentMitlData = data.data;originalCocText = currentMitlData.coc_trace;renderMitlData();notify(`Dataset loaded: ${currentMitlData.dataset}`, 'success');}} catch (e) {console.error(e);notify('Failed to load NVIDIA dataset.', 'error');}}130 unmodified lines}} catch (e) {console.error(e);const statusEl = document.getElementById('source-browse-status');if (statusEl) statusEl.textContent = 'Catalog metadata load failed.';notify('Catalog metadata load failed.', 'error');} finally {btnPreprocessDataset.textContent = 'Load Catalog Metadata';btnPreprocessDataset.disabled = false;74 unmodified lines});const data = await res.json();if (data.status === 'ok') {notify(`Pipeline configuration saved\nAnnotation: ${annotationTool}\nTraining: ${trainingFramework}\nValidation: ${validationMethod}`,'success');pipelineWizardModal.classList.add('hidden');}} catch (e) {console.error(e);notify('Failed to save pipeline configuration settings.', 'error');} finally {btnWizardSubmit.textContent = 'Save Pipeline Configuration';btnWizardSubmit.disabled = false;96 unmodified lines// Add Box HandlerbtnMitlAddBox.addEventListener('click', () => {if (!currentMitlData) {notify('Please load a dataset first.', 'warning');return;}const nextId = currentMitlData.annotations.length > 012 unmodified lines// Save Human EditsbtnMitlSave.addEventListener('click', async () => {if (!currentMitlData) {notify('No dataset currently loaded to save.', 'warning');return;}21 unmodified lines});if (parseError) {notify('Invalid bounding box format. Use coordinates [x, y, w, h].', 'error');return;}13 unmodified lines// Update local memorycurrentMitlData.annotations = updatedAnns;currentMitlData.coc_trace = mitlCocTrace.value;notify('Triage results saved to runs/mitl_annotations.json.', 'success');}} catch (e) {console.error(e);notify('Failed to save human edits.', 'error');}});// Ask Gemma 4 critiquebtnMitlAudit.addEventListener('click', async () => {if (!currentMitlData) {notify('No dataset currently loaded to audit.', 'warning');return;}280 unmodified lines}} catch (e) {console.error(e);notify('Failed to toggle MCP server state.', 'error');checkbox.checked = !checkbox.checked;bullet.style.transform = checkbox.checked ? 'translateX(22px)' : 'none';updateSliderStyle();508 unmodified lines}),});ssamState.selectedRow.manual_annotation = ssamDrawerAnnotation.value;notify(`Annotation saved for ${ssamState.selectedRow.street_name}`, 'success');} catch (e) {notify('Failed to save annotation.', 'error');} finally {ssamDrawerSave.textContent = 'Save Annotation';ssamDrawerSave.disabled = false;241 unmodified linesconst statusEl = document.getElementById('perception-status');statusEl.textContent = 'Running SAM auto-label...';try {await syncActiveSequence();const res = await fetch(`${API_BASE}/api/perception/auto-label`, {method: 'POST',headers: { 'Content-Type': 'application/json' },1 unmodified linesequence_id: currentSequenceId,sam_checkpoint: document.getElementById('perception-sam-checkpoint')?.value || 'models/sam_vit_b.pth',device: document.getElementById('perception-device')?.value || 'cpu',no_sam: !!document.getElementById('perception-no-sam')?.checked,}),});const data = await res.json();const payload = (data && typeof data.detail === 'object') ? data.detail : data;const status = payload.status || (res.ok ? 'SUCCEEDED' : 'FAILED');const nextSteps = payload.next_steps || [];const stubPrefix = payload.demo_stub ? 'demo stub · ' : '';if (!res.ok || status === 'FAILED') {statusEl.textContent = [`${status}: ${payload.message || 'Auto-label could not run.'}`,payload.checkpoint?.exists === false ? 'SAM checkpoint missing.' : '',payload.frames_expected === 0 ? 'No ingested frames for this sequence.' : '',nextSteps.length ? `Next: ${nextSteps[0]}` : '',].filter(Boolean).join('\n');renderEvidenceCard('evidence-perception', {status: 'FAILED',execution_id: payload.execution_id,duration_ms: payload.duration_ms,model: payload.model,checkpoint: payload.checkpoint,metrics: {frames_processed: payload.frames_processed,frames_expected: payload.frames_expected,predictions_generated: payload.predictions_generated,sam_ran: payload.sam_ran,},message: payload.message,next_steps: nextSteps,events: payload.events,});} else {statusEl.textContent = [`${status}: ${stubPrefix}${payload.frames_processed}/${payload.frames_expected} frames`,payload.message || '',nextSteps.length && status !== 'SUCCEEDED' ? `Next: ${nextSteps[0]}` : '',].filter(Boolean).join('\n');renderEvidenceCard('evidence-perception', {status,execution_id: payload.execution_id,duration_ms: payload.duration_ms,model: payload.model,checkpoint: payload.checkpoint,metrics: {frames_processed: payload.frames_processed,frames_expected: payload.frames_expected,predictions_generated: payload.predictions_generated,inference_calls: payload.inference_calls,sam_ran: payload.sam_ran,output_dir: payload.proposals_dir,},message: payload.message,next_steps: nextSteps,events: payload.events,});refreshExecutionConsole();}await refreshPipelineStatus();await refreshAllOutputBrowsers();227 unmodified lines}});}// --- Execution integrity: evidence cards, console, strict mode, load ---function esc(s) {return String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');}function renderEvidenceCard(elementId, evidence) {const el = document.getElementById(elementId);if (!el || !evidence) return;const status = evidence.status || 'NOT_EXECUTED';const metrics = evidence.metrics || {};const metricRows = Object.entries(metrics).map(([k, v]) => {const val = typeof v === 'object' ? JSON.stringify(v) : v;return `<div class="ev-row"><span>${esc(k)}</span><strong>${esc(val)}</strong></div>`;}).join('');const events = (evidence.events || []).slice(-8).map(ev =>`<li><code>${esc(ev.ts || '')}</code> ${esc(ev.kind || '')}: ${esc(ev.message || '')}</li>`).join('');const ckpt = evidence.checkpoint? `<div class="ev-row"><span>checkpoint</span><strong>${esc(evidence.checkpoint.path || evidence.checkpoint)} ${evidence.checkpoint.exists === false ? '(missing)' : ''}</strong></div>`: '';const nextSteps = (evidence.next_steps || []).map((s) => `<li>${esc(s)}</li>`).join('');el.innerHTML = `<h4>What actually happened?</h4><div class="ev-status ev-status-${esc(status)}">${esc(status)}</div><div class="ev-row"><span>execution_id</span><strong class="font-mono">${esc(evidence.execution_id || '—')}</strong></div>${evidence.duration_ms != null ? `<div class="ev-row"><span>duration_ms</span><strong>${esc(evidence.duration_ms)}</strong></div>` : ''}${evidence.model ? `<div class="ev-row"><span>model</span><strong>${esc(evidence.model)}</strong></div>` : ''}${ckpt}${evidence.process_id != null ? `<div class="ev-row"><span>process_id</span><strong>${esc(evidence.process_id)}</strong></div>` : ''}${evidence.exit_code != null ? `<div class="ev-row"><span>exit_code</span><strong>${esc(evidence.exit_code)}</strong></div>` : ''}${evidence.command ? `<div class="ev-row"><span>command</span><strong class="font-mono">${esc(Array.isArray(evidence.command) ? evidence.command.join(' ') : evidence.command)}</strong></div>` : ''}${metricRows}${evidence.message ? `<p class="ev-msg">${esc(evidence.message)}</p>` : ''}${nextSteps ? `<div class="ev-next"><strong>What to do next</strong><ul>${nextSteps}</ul></div>` : ''}${evidence.execution_id ? `<a class="ev-log-link" href="/api/executions/${encodeURIComponent(evidence.execution_id)}/log" target="_blank" rel="noopener">Open execution log</a>` : ''}${events ? `<details class="ev-timeline"><summary>Event timeline</summary><ul>${events}</ul></details>` : ''}`;}function refreshScriptStatus(scripts) {const map = {'train.py': 'script-status-train','infer.py': 'script-status-infer','autograder.py': 'script-status-grader',};Object.entries(map).forEach(([name, id]) => {const el = document.getElementById(id);const r = scripts?.[name];if (!el || !r) return;if (!r.exists) {el.textContent = `Missing (${name})`;el.className = 'val font-mono';el.style.color = '#ff8888';} else if (r.syntax_valid && r.dry_run_ok) {el.textContent = `Verified (${name})${r.last_status ? ' · last ' + r.last_status : ''}`;el.className = 'val font-mono green';el.style.color = '';} else {el.textContent = `Found but unverified (${name})`;el.className = 'val font-mono';el.style.color = '#fbbf24';}});}async function refreshHealth() {try {const res = await fetch(`${API_BASE}/api/health`);const data = await res.json();const chip = document.getElementById('health-status-chip');if (chip) {chip.textContent = [data.filesystem_writable ? 'FS writable' : 'FS FAIL',data.torch_installed ? 'torch' : 'no-torch',data.ultralytics_installed ? 'yolo' : 'no-yolo',data.gpu?.available ? `GPU:${data.gpu.name}` : 'CPU',data.last_successful_execution_id ? `last:${data.last_successful_execution_id}` : 'no-success-yet',].join(' · ');}if (data.scripts) refreshScriptStatus(data.scripts);const tog = document.getElementById('toggle-strict-mode');if (tog) tog.checked = !!data.strict_mode;} catch (e) {const chip = document.getElementById('health-status-chip');if (chip) chip.textContent = 'Backend unreachable';}}async function refreshExecutionConsole() {const list = document.getElementById('exec-console-list');if (!list) return;try {const res = await fetch(`${API_BASE}/api/executions?limit=40`);const data = await res.json();const rows = data.executions || [];if (!rows.length) {list.innerHTML = '<p class="evidence-empty">No executions recorded yet.</p>';return;}list.innerHTML = rows.map(e => `<button type="button" class="exec-row" data-id="${esc(e.execution_id)}"><span class="ev-status ev-status-${esc(e.status)}">${esc(e.status)}</span><span class="font-mono">${esc(e.execution_id)}</span><span>${esc(e.operation)}</span><span>${esc(e.duration_ms != null ? e.duration_ms + 'ms' : '—')}</span><span>${e.verified ? 'verified' : 'unverified'}</span></button>`).join('');list.querySelectorAll('.exec-row').forEach(btn => {btn.addEventListener('click', async () => {const detail = document.getElementById('exec-console-detail');const r = await fetch(`${API_BASE}/api/executions/${encodeURIComponent(btn.dataset.id)}`);const full = await r.json();detail.classList.remove('hidden');detail.innerHTML = `<pre>${esc(JSON.stringify(full, null, 2))}</pre>`;});});} catch (e) {list.innerHTML = `<p class="evidence-empty">Failed to load executions: ${esc(e.message)}</p>`;}}const btnLoadPreprocess = document.getElementById('btn-load-preprocess');if (btnLoadPreprocess) {btnLoadPreprocess.addEventListener('click', async () => {btnLoadPreprocess.disabled = true;btnLoadPreprocess.textContent = 'Loading…';const statusEl = document.getElementById('source-browse-status');try {const res = await fetch(`${API_BASE}/api/dataset/load`, {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({source_path: datasetSourcePath?.value || 'data',yaml_path: dataYamlPath?.value || 'coco8.yaml',dataset_type: selectDatasetType?.value || 'local',}),});const data = await res.json();const m = data.metrics || {};if (statusEl) {statusEl.textContent = `${data.status}: discovered=${m.images_discovered ?? 0} readable=${m.images_readable ?? 0} corrupt=${m.images_corrupt ?? 0} → ${data.manifest_path || ''}`;}renderEvidenceCard('evidence-dataset', {status: data.status,execution_id: data.execution_id,duration_ms: data.duration_ms,metrics: {...m,reconciliation: data.reconciliation?.state,manifest: data.manifest_path,},message: data.message,events: data.events,});const badge = document.getElementById('ds-meta-badge');const loadedEl = document.getElementById('ds-kpi-loaded-rows');const pctEl = document.getElementById('ds-kpi-ingest-pct');if (loadedEl) loadedEl.textContent = m.images_readable ?? 0;if (pctEl) pctEl.textContent = m.loaded_pct_of_discovered != null ? `${m.loaded_pct_of_discovered}% of discovered` : '—';if (badge) {if (data.status === 'FAILED' || (m.images_readable ?? 0) === 0) {badge.textContent = 'FAILED — 0 loaded';badge.style.background = 'rgba(255, 68, 68, 0.12)';badge.style.color = '#ff8888';} else {badge.textContent = `${m.images_readable} loaded (evidence)`;badge.style.background = 'rgba(0, 255, 170, 0.15)';badge.style.color = '#00ffaa';}}const cfgStatus = document.getElementById('config-exec-status');if (cfgStatus) {cfgStatus.textContent = `used_by_execution YES · last execution_id ${data.execution_id}`;cfgStatus.dataset.modified = '0';}refreshExecutionConsole();if (data.status === 'FAILED' || data.status === 'VALIDATION_FAILED') {notify(data.message || 'Load failed', 'error');} else if (data.status === 'PARTIAL_SUCCESS') {notify(data.message || 'Partial load', 'warning');} else {notify(data.message || 'Load complete', 'success');}} catch (e) {if (statusEl) statusEl.textContent = `Load failed: ${e.message}`;notify('Load & Preprocess failed.', 'error');} finally {btnLoadPreprocess.disabled = false;btnLoadPreprocess.textContent = 'Load & Preprocess';}});}const btnYamlValidate = document.getElementById('btn-yaml-validate');if (btnYamlValidate) {btnYamlValidate.addEventListener('click', async () => {try {const res = await fetch(`${API_BASE}/api/yaml/validate`, {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ path: dataYamlPath?.value || 'coco8.yaml' }),});const data = await res.json();notify(`${data.status}: classes=${data.class_count} images=${JSON.stringify(data.image_counts)}`, data.status === 'SUCCEEDED' ? 'success' : 'warning');const cfgStatus = document.getElementById('config-exec-status');if (cfgStatus) {cfgStatus.textContent = `YAML hash ${data.content_hash || '—'} · ${data.status} · execution ${data.execution_id || '—'}`;}refreshExecutionConsole();} catch (e) {notify(`YAML validate failed: ${e.message}`, 'error');}});}document.getElementById('btn-open-exec-console')?.addEventListener('click', () => {document.getElementById('exec-console-modal')?.classList.remove('hidden');refreshExecutionConsole();});document.getElementById('btn-close-exec-console')?.addEventListener('click', () => {document.getElementById('exec-console-modal')?.classList.add('hidden');});document.getElementById('btn-refresh-executions')?.addEventListener('click', refreshExecutionConsole);document.getElementById('btn-health-check')?.addEventListener('click', async () => {await refreshHealth();notify('Health refreshed — see Workspace Status chip.', 'info');});document.getElementById('toggle-strict-mode')?.addEventListener('change', async (e) => {try {await fetch(`${API_BASE}/api/strict-mode`, {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ enabled: e.target.checked }),});notify(e.target.checked ? 'Strict Execution Mode ON' : 'Strict Execution Mode OFF', 'info');} catch (err) {notify('Failed to toggle strict mode', 'error');}});refreshHealth();});
101 unmodified lines10210310410510610710832 unmodified lines1411421431441451461471481491501515 unmodified lines157158159160161162163164165166167168169170171174 unmodified lines3463473483493503513522 unmodified lines35535635735835936036136229 unmodified lines3923933943953963975 unmodified lines403404405406407408113 unmodified lines52252352452552652734 unmodified lines56256356456556656735 unmodified lines603604605606607608462 unmodified lines107110721073107410751076101 unmodified lines<h2 id="stage-title">Dataset Configuration</h2><p id="stage-desc">Prepare and validate your image source path and annotation files.</p></div><div class="controls-area"><button class="btn btn-secondary" id="btn-validate">Run Pre-Check</button><button class="btn btn-primary" id="btn-global-action">Proceed to Model</button></div>32 unmodified lines</div><div class="actions-row" style="display: flex; gap: 12px; flex-wrap: wrap;"><button class="btn btn-primary" id="btn-save-dataset">Save Config</button><button class="btn btn-secondary" id="btn-preprocess-dataset">Load Catalog Metadata</button><button class="btn btn-secondary" id="btn-browse-source" title="List and preview images under Images Path">Validate & Browse Images Path</button></div><div id="source-browse-status" class="status-box" style="margin-top:12px;"></div><div id="source-browse-gallery" class="output-browse-gallery" style="margin-top:12px;"></div></div><div class="card card-glass">5 unmodified lines</div><div class="info-row"><span class="lbl">Train script:</span><span class="val font-mono green">Found (train.py)</span></div><div class="info-row"><span class="lbl">Infer script:</span><span class="val font-mono green">Found (infer.py)</span></div><div class="info-row"><span class="lbl">Auto-Grader script:</span><span class="val font-mono green">Found (autograder.py)</span></div></div></div>174 unmodified lines<p class="text-muted">Generate 2D SAM masks and lift to 3D bounding box proposals.</p><div class="form-group"><label for="perception-sam-checkpoint">SAM Checkpoint</label><input type="text" id="perception-sam-checkpoint" value="models/sam_vit_b.pth" class="input-field"></div><div class="form-group"><label for="perception-device">Device</label>2 unmodified lines<option value="cuda">CUDA</option></select></div><button class="btn btn-primary" id="btn-perception-run">Run Auto-Label</button><div id="perception-status" class="status-box" style="margin-top:16px;"></div></div><div class="card card-glass pipeline-output-browser" style="margin-top:16px;" data-browser="perception"><h3>Pipeline Outputs — proposals & frames</h3>29 unmodified lines<button class="btn btn-primary" id="btn-tracking-run">Run Temporal Tracker</button><div id="tracking-status" class="status-box" style="margin-top:16px;"></div><div id="tracking-tracks-table" style="margin-top:16px;"></div></div></section>5 unmodified lines<button class="btn btn-primary" id="btn-quality-gate-run">Run Quality Gate</button><div id="quality-gate-status" class="status-box" style="margin-top:16px;"></div><div id="quality-gate-metrics" style="margin-top:16px;"></div></div></section>113 unmodified lines<div class="progress-bar-fill" id="train-progress-bar" style="width: 0%"></div></div></div></div><div class="card card-glass">34 unmodified lines<span class="range-val" id="val-infer-iou">0.45</span></div><button class="btn btn-primary btn-large" id="btn-run-infer">⚡ Run Auto-Labeler</button></div><div class="card card-glass">35 unmodified lines</div></div><button class="btn btn-primary width-full" id="btn-run-grader" style="margin-top: 15px;">Run Quality Diagnostics</button></div><div class="card card-glass">462 unmodified lines</div></div><script src="app.js"></script></body></html>101 unmodified lines10210310410510610710810911011111211332 unmodified lines1461471481491501511521531541551561571581591601611621635 unmodified lines169170171172173174175176177178179180181182183184185186187174 unmodified lines3623633643653663673683693703713722 unmodified lines37537637737837938038138238338438538638738838929 unmodified lines4194204214224234244254264274285 unmodified lines434435436437438439440441442443113 unmodified lines55755855956056156256356456556634 unmodified lines60160260360460560660760860961035 unmodified lines646647648649650651652653654655462 unmodified lines11181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140101 unmodified lines<h2 id="stage-title">Dataset Configuration</h2><p id="stage-desc">Prepare and validate your image source path and annotation files.</p></div><div class="controls-area" style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;"><label class="strict-mode-toggle" title="Refuse SUCCEEDED unless process, exit, outputs, metrics, and execution_id are verified"><input type="checkbox" id="toggle-strict-mode"> Strict Execution</label><button class="btn btn-secondary" id="btn-open-exec-console" title="Global execution history">Execution Console</button><button class="btn btn-secondary" id="btn-health-check" title="Meaningful backend health">Health</button><button class="btn btn-secondary" id="btn-validate">Run Pre-Check</button><button class="btn btn-primary" id="btn-global-action">Proceed to Model</button></div>32 unmodified lines</div><div class="actions-row" style="display: flex; gap: 12px; flex-wrap: wrap;"><button class="btn btn-primary" id="btn-save-dataset">Save Config</button><button class="btn btn-primary" id="btn-load-preprocess" title="Real discovery/decode/validation with ledger evidence">Load & Preprocess</button><button class="btn btn-secondary" id="btn-preprocess-dataset">Load Catalog Metadata</button><button class="btn btn-secondary" id="btn-browse-source" title="List and preview images under Images Path">Validate & Browse Images Path</button><button class="btn btn-secondary" id="btn-yaml-validate" title="Semantic YAML path/class validation">Validate YAML</button></div><div id="config-exec-status" class="config-exec-status" style="margin-top:10px;font-size:12px;color:var(--text-muted);"></div><div id="source-browse-status" class="status-box" style="margin-top:12px;"></div><div id="source-browse-gallery" class="output-browse-gallery" style="margin-top:12px;"></div><div class="evidence-card" id="evidence-dataset" data-stage="dataset"><h4>What actually happened?</h4><p class="evidence-empty">No execution yet — Load & Preprocess to generate verifiable evidence.</p></div></div><div class="card card-glass">5 unmodified lines</div><div class="info-row"><span class="lbl">Train script:</span><span class="val font-mono" id="script-status-train">Verifying…</span></div><div class="info-row"><span class="lbl">Infer script:</span><span class="val font-mono" id="script-status-infer">Verifying…</span></div><div class="info-row"><span class="lbl">Auto-Grader script:</span><span class="val font-mono" id="script-status-grader">Verifying…</span></div><div class="info-row"><span class="lbl">Backend health:</span><span class="val font-mono" id="health-status-chip">—</span></div></div></div>174 unmodified lines<p class="text-muted">Generate 2D SAM masks and lift to 3D bounding box proposals.</p><div class="form-group"><label for="perception-sam-checkpoint">SAM Checkpoint</label><input type="text" id="perception-sam-checkpoint" value="models/sam_vit_b.pth" class="input-field"placeholder="models/sam_vit_b.pth — download ViT-B weights locally (not bundled on HF Space CPU)"><p class="text-muted" style="font-size:12px;margin-top:4px;">Default path <code>models/sam_vit_b.pth</code>. On Hugging Face Space, upload weights or run locally with GPU.</p></div><div class="form-group"><label for="perception-device">Device</label>2 unmodified lines<option value="cuda">CUDA</option></select></div><div class="form-group"><label><input type="checkbox" id="perception-no-sam"> Skip SAM (fallback / NOT a model SUCCESS)</label></div><button class="btn btn-primary" id="btn-perception-run">Run Auto-Label</button><div id="perception-status" class="status-box" style="margin-top:16px;"></div><div class="evidence-card" id="evidence-perception" data-stage="perception"><h4>What actually happened?</h4><p class="evidence-empty">No auto-label execution yet.</p></div></div><div class="card card-glass pipeline-output-browser" style="margin-top:16px;" data-browser="perception"><h3>Pipeline Outputs — proposals & frames</h3>29 unmodified lines<button class="btn btn-primary" id="btn-tracking-run">Run Temporal Tracker</button><div id="tracking-status" class="status-box" style="margin-top:16px;"></div><div id="tracking-tracks-table" style="margin-top:16px;"></div><div class="evidence-card evidence-stub" id="evidence-tracking" data-stage="tracking"><h4>What actually happened?</h4><p class="evidence-empty">Ledger wiring pending — status will show NOT_EXECUTED until this stage records evidence.</p></div></div></section>5 unmodified lines<button class="btn btn-primary" id="btn-quality-gate-run">Run Quality Gate</button><div id="quality-gate-status" class="status-box" style="margin-top:16px;"></div><div id="quality-gate-metrics" style="margin-top:16px;"></div><div class="evidence-card evidence-stub" id="evidence-quality-gate" data-stage="quality-gate"><h4>What actually happened?</h4><p class="evidence-empty">Evidence panel stub — gate results are live, full ledger wiring deferred.</p></div></div></section>113 unmodified lines<div class="progress-bar-fill" id="train-progress-bar" style="width: 0%"></div></div></div><div class="evidence-card" id="evidence-training" data-stage="training"><h4>What actually happened?</h4><p class="evidence-empty">No training execution yet.</p></div></div><div class="card card-glass">34 unmodified lines<span class="range-val" id="val-infer-iou">0.45</span></div><button class="btn btn-primary btn-large" id="btn-run-infer">⚡ Run Auto-Labeler</button><div class="evidence-card" id="evidence-inference" data-stage="inference"><h4>What actually happened?</h4><p class="evidence-empty">No inference execution yet.</p></div></div><div class="card card-glass">35 unmodified lines</div></div><button class="btn btn-primary width-full" id="btn-run-grader" style="margin-top: 15px;">Run Quality Diagnostics</button><div class="evidence-card" id="evidence-grader" data-stage="grader"><h4>What actually happened?</h4><p class="evidence-empty">No grader execution yet.</p></div></div><div class="card card-glass">462 unmodified lines</div></div><div id="toast-stack" class="toast-stack" aria-live="polite" aria-relevant="additions"></div><div id="exec-console-modal" class="modal-overlay hidden" role="dialog" aria-label="Execution Console"><div class="modal-card exec-console-card"><div class="modal-header" style="display:flex;justify-content:space-between;align-items:center;gap:12px;"><h3 style="margin:0;">Global Execution Console</h3><div style="display:flex;gap:8px;"><button type="button" class="btn btn-secondary" id="btn-refresh-executions">Refresh</button><button type="button" class="btn btn-secondary" id="btn-close-exec-console">Close</button></div></div><p style="font-size:12px;color:var(--text-muted);margin:8px 0 12px;">Persistent ledger under <code>runs/executions/</code>. UI PASS badges are not evidence.</p><div id="exec-console-list" class="exec-console-list"></div><div id="exec-console-detail" class="exec-console-detail hidden"></div></div></div><script src="app.js"></script></body></html>
668 unmodified lines669670671672673674767 unmodified lines144214431444668 unmodified linescolor: var(--secondary);}/* Animations */@keyframes fadeIn {from { opacity: 0; transform: translateY(8px); }767 unmodified linescolor: var(--text-muted);font-size: 10px;}668 unmodified lines669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785767 unmodified lines1553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652668 unmodified linescolor: var(--secondary);}.status-msg.success-msg {background: rgba(16, 185, 129, 0.12);border-color: rgba(16, 185, 129, 0.28);color: var(--success);}.status-msg.error-msg {background: rgba(239, 68, 68, 0.12);border-color: rgba(239, 68, 68, 0.28);color: var(--danger);}/* Non-blocking toast notifications (replaces window.alert) */.toast-stack {position: fixed;bottom: 24px;left: 50%;transform: translateX(-50%);display: flex;flex-direction: column-reverse;gap: 8px;z-index: 2000;width: min(420px, calc(100vw - 32px));pointer-events: none;}.toast {pointer-events: auto;display: flex;align-items: flex-start;gap: 10px;padding: 12px 14px;border-radius: 8px;background: rgba(15, 20, 34, 0.96);border: 1px solid var(--border);box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);color: var(--text);font-size: 13px;line-height: 1.45;white-space: pre-line;animation: toastIn 0.2s ease;}.toast.toast-out {animation: toastOut 0.18s ease forwards;}.toast-icon {flex-shrink: 0;width: 18px;text-align: center;font-size: 14px;line-height: 1.3;}.toast-body {flex: 1;min-width: 0;}.toast-close {flex-shrink: 0;background: transparent;border: none;color: var(--text-muted);cursor: pointer;font-size: 16px;line-height: 1;padding: 0 2px;}.toast-close:hover {color: var(--text);}.toast-success {border-color: rgba(16, 185, 129, 0.35);box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(16, 185, 129, 0.08);}.toast-success .toast-icon { color: var(--success); }.toast-error {border-color: rgba(239, 68, 68, 0.4);box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(239, 68, 68, 0.08);}.toast-error .toast-icon { color: var(--danger); }.toast-warning {border-color: rgba(245, 158, 11, 0.4);}.toast-warning .toast-icon { color: var(--warning); }.toast-info {border-color: rgba(59, 130, 246, 0.35);}.toast-info .toast-icon { color: var(--secondary); }@keyframes toastIn {from { opacity: 0; transform: translateY(10px); }to { opacity: 1; transform: translateY(0); }}@keyframes toastOut {from { opacity: 1; transform: translateY(0); }to { opacity: 0; transform: translateY(8px); }}/* Animations */@keyframes fadeIn {from { opacity: 0; transform: translateY(8px); }767 unmodified linescolor: var(--text-muted);font-size: 10px;}/* Execution integrity */.strict-mode-toggle {display: inline-flex;align-items: center;gap: 6px;font-size: 12px;color: var(--text-muted);cursor: pointer;user-select: none;}.evidence-card {margin-top: 16px;padding: 14px;border: 1px solid var(--border);border-radius: 8px;background: rgba(4, 6, 11, 0.55);}.evidence-card h4 {margin: 0 0 10px 0;font-size: 13px;color: var(--secondary);}.evidence-empty {font-size: 12px;color: var(--text-muted);margin: 0;}.ev-status {display: inline-block;font-size: 11px;font-weight: 700;letter-spacing: 0.4px;padding: 3px 8px;border-radius: 4px;margin-bottom: 10px;font-family: var(--font-mono);}.ev-status-SUCCEEDED { background: #00ffaa22; color: #00ffaa; }.ev-status-PARTIAL_SUCCESS { background: #fbbf2422; color: #fbbf24; }.ev-status-FAILED, .ev-status-VALIDATION_FAILED { background: #ff444422; color: #ff8888; }.ev-status-RUNNING, .ev-status-QUEUED { background: #3b82f622; color: #93c5fd; }.ev-status-NOT_EXECUTED, .ev-status-UNVERIFIED, .ev-status-CANCELLED { background: #64748b33; color: #94a3b8; }.ev-row {display: flex;justify-content: space-between;gap: 12px;font-size: 12px;padding: 3px 0;border-bottom: 1px solid rgba(255,255,255,0.04);}.ev-row span { color: var(--text-muted); }.ev-row strong { color: var(--text); text-align: right; word-break: break-all; }.ev-msg { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; }.ev-next { margin-top: 12px; font-size: 12px; color: var(--text-muted); }.ev-next ul { margin: 6px 0 0 18px; padding: 0; }.ev-next li { margin-bottom: 4px; }.ev-log-link { display: inline-block; margin-top: 10px; font-size: 12px; color: #38bdf8; }.ev-timeline { margin-top: 10px; font-size: 11px; color: var(--text-muted); }.ev-timeline ul { margin: 6px 0 0 16px; padding: 0; }.exec-console-card {width: min(920px, 94vw);max-height: 85vh;overflow: auto;background: var(--bg-sidebar);border: 1px solid var(--border);border-radius: 12px;padding: 18px;}.exec-console-list { display: flex; flex-direction: column; gap: 6px; }.exec-row {display: grid;grid-template-columns: 140px 160px 1fr 80px 90px;gap: 8px;align-items: center;text-align: left;padding: 8px 10px;background: rgba(4,6,11,0.5);border: 1px solid var(--border);border-radius: 6px;color: var(--text);cursor: pointer;font-size: 12px;}.exec-row:hover { border-color: var(--border-active); }.exec-console-detail pre {margin-top: 12px;max-height: 320px;overflow: auto;background: #04060b;border: 1px solid var(--border);border-radius: 8px;padding: 12px;font-size: 11px;color: #00ffaa;}.config-exec-status { font-family: var(--font-mono); }
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124"""Auto-label pre-checks, status semantics, and UI-facing error payloads."""
from __future__ import annotations
import jsonimport sysfrom pathlib import Path
import pytestfrom fastapi.testclient import TestClient
ROOT = Path(__file__).resolve().parents[2]if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT))
def _write_tiny_jpeg(path: Path) -> None: path.write_bytes( bytes.fromhex( "ffd8ffe000104a46494600010100000100010000ffdb004300080606070605080707" "070909080a0c140d0c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720222c231c" "1c2837292c30313434341f27393d38323c2e333432ffdb0043010909090c0b0c180d" "0d1832211c2132323232323232323232323232323232323232323232323232323232" "323232323232323232323232323232323232323232ffc00011080001000103011100" "021101031101ffc40014000100000000000000000000000000000000ffc400141001" "00000000000000000000000000000000ffda000c0301000210031000003f00bf80ffd9" ) )
@pytest.fixture()def client(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) from sensorflow import execution_ledger as ledger
monkeypatch.setattr(ledger, "LEDGER_ROOT", tmp_path / "runs" / "executions") monkeypatch.setattr(ledger, "INDEX_PATH", tmp_path / "runs" / "executions" / "index.json") monkeypatch.setattr(ledger, "STRICT_MODE_PATH", tmp_path / "runs" / "studio_strict_mode.json")
import importlib import app_backend
importlib.reload(app_backend) return TestClient(app_backend.app)
def _ingest_local(client: TestClient, tmp_path: Path, seq_id: str = "seq_local", n: int = 5): frames_dir = tmp_path / "frames" frames_dir.mkdir() for i in range(n): _write_tiny_jpeg(frames_dir / f"f{i}.jpg") res = client.post( "/api/dataset/ingest", json={ "vendors": ["local"], "sequence_id": seq_id, "source_path": str(frames_dir), "max_frames": 10000, }, ) assert res.status_code == 200 assert res.json()["frames"] == n return res
def test_missing_checkpoint_returns_failed_not_partial(client, tmp_path): _ingest_local(client, tmp_path, "seq_ckpt", 3) res = client.post( "/api/perception/auto-label", json={ "sequence_id": "seq_ckpt", "sam_checkpoint": str(tmp_path / "missing_sam.pth"), "no_sam": False, }, ) assert res.status_code == 400 detail = res.json()["detail"] assert detail["status"] == "FAILED" assert detail["checkpoint"]["exists"] is False assert detail["frames_expected"] == 3 assert detail["frames_processed"] == 0 assert detail.get("next_steps") assert "FAILED" == detail["status"] assert "PARTIAL_SUCCESS" != detail["status"]
def test_empty_manifest_returns_failed(client, tmp_path): manifest_dir = tmp_path / "runs" / "pipeline" / "seq_empty" manifest_dir.mkdir(parents=True) (manifest_dir / "manifest.json").write_text( json.dumps( { "sequence_id": "seq_empty", "vendor": "local", "frames": [], "taxonomy_manifest": {"demo_stub": False}, } ) ) res = client.post( "/api/perception/auto-label", json={"sequence_id": "seq_empty", "no_sam": True}, ) assert res.status_code == 400 detail = res.json()["detail"] assert detail["status"] == "FAILED" assert detail["frames_expected"] == 0 assert "ingest" in detail["message"].lower() or "0 ingested" in detail["message"].lower()
def test_ingest_then_no_sam_auto_label_has_frames(client, tmp_path): _ingest_local(client, tmp_path, "seq_ok", 4) res = client.post( "/api/perception/auto-label", json={"sequence_id": "seq_ok", "no_sam": True}, ) assert res.status_code == 200 body = res.json() assert body["frames_expected"] == 4 assert body["frames_processed"] == 4 assert body["status"] == "NOT_EXECUTED" assert body["sam_ran"] is False assert isinstance(body.get("message"), str) assert "{" not in body["message"][:20]static/app.js+495-49
static/index.html+69-5
static/style.css+208
tests/test_pipeline/test_auto_label_integrity.pyAdded+124