feat: build Onyx SSR shell and plan hero with mock data
This commit is contained in:
1 parent
84c20992f9
commit
2db494fb10
34 files changed
+3197
-2
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { mockMeta } from './mock-data'
|
||||
|
||||
export interface MockTrainJob {
|
||||
job_id: string
|
||||
status: 'queued' | 'running' | 'succeeded' | 'failed'
|
||||
model: 'small' | 'forecast'
|
||||
started_at: string
|
||||
finished_at: string | null
|
||||
metrics: Record<string, number | string> | null
|
||||
model_version: string | null
|
||||
error: string | null
|
||||
filename: string | null
|
||||
}
|
||||
|
||||
const jobs = new Map<string, MockTrainJob>()
|
||||
|
||||
export function createMockTrainJob(model: 'small' | 'forecast', filename: string | null): MockTrainJob {
|
||||
const now = new Date().toISOString()
|
||||
const job: MockTrainJob = {
|
||||
job_id: `mock-${Date.now().toString(36)}`,
|
||||
// The mock completes immediately. Replace this with polling of GET /api/train/{job_id}
|
||||
// once the Go/FastAPI service exists.
|
||||
status: 'succeeded',
|
||||
model,
|
||||
started_at: now,
|
||||
finished_at: now,
|
||||
metrics:
|
||||
model === 'small'
|
||||
? { accuracy: 0.84, f1: 0.81, trained_rows: 12480, kind: 'busy classifier' }
|
||||
: {
|
||||
mae: mockMeta.metrics.mae,
|
||||
wape: mockMeta.metrics.wape,
|
||||
r2: mockMeta.metrics.r2,
|
||||
baseline_wape: mockMeta.metrics.baseline_wape,
|
||||
kind: 'global HistGB',
|
||||
},
|
||||
model_version: `${mockMeta.model_version}-mock-${Date.now().toString(36)}`,
|
||||
error: null,
|
||||
filename,
|
||||
}
|
||||
jobs.set(job.job_id, job)
|
||||
return job
|
||||
}
|
||||
|
||||
export function getMockTrainJob(jobId: string): MockTrainJob | undefined {
|
||||
return jobs.get(jobId)
|
||||
}
|
||||
Reference in new issue
Block a user