- Lead with purpose and exact local/CI commands. - Remove local absolute paths, stale auth notes and unverified claims. - Keep comments to the reason or invariant they protect.
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
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; the real path polls GET /api/train/{job_id}.
|
|
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)
|
|
}
|