LeLab / src /lib /checkpointsApi.ts
GitHub CI
Sync from leLab @ 39fcfee669f0b98e7a1fc4dde23025ea8cc7e5ce
df3ef41
Raw
History Blame Contribute Delete
1.03 kB
import { Fetcher, apiRequest } from "./apiClient";
export interface JobCheckpoint {
step: number;
source: "local" | "hub";
ref: string;
}
export interface PolicyConfigSummary {
policy_type: string | null;
image_features: Record<string, { height: number; width: number }>;
requires_task: boolean;
}
export async function listJobCheckpoints(
baseUrl: string,
fetcher: Fetcher,
jobId: string,
signal?: AbortSignal,
): Promise<JobCheckpoint[]> {
const body = await apiRequest<{ checkpoints: JobCheckpoint[] }>(
baseUrl,
fetcher,
`/jobs/${jobId}/checkpoints`,
{ signal, action: "List checkpoints" },
);
return body.checkpoints;
}
export async function getCheckpointPolicyConfig(
baseUrl: string,
fetcher: Fetcher,
jobId: string,
step: number,
signal?: AbortSignal,
): Promise<PolicyConfigSummary> {
return apiRequest<PolicyConfigSummary>(
baseUrl,
fetcher,
`/jobs/${jobId}/checkpoints/${step}/policy-config`,
{ signal, action: "Load policy config" },
);
}