Download space/src/commit-enrichment-bootstrap.ts from osolmaz/xtap-pool: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/osolmaz/xtap-pool/resolve/main/space/src/commit-enrichment-bootstrap.ts
- Command line
-
hf download hf://spaces/osolmaz/xtap-pool/space/src/commit-enrichment-bootstrap.ts
-
curl -L -o commit-enrichment-bootstrap.ts https://huggingface.co/spaces/osolmaz/xtap-pool/resolve/main/space/src/commit-enrichment-bootstrap.ts
1.81 kB
| import { activateEnrichmentRun } from "./enrich-active-run.js"; | |
| import { bootstrapEnrichmentRun } from "./bootstrap-enrichment-run.js"; | |
| import type { DurableIndexBucketReader } from "./durable-index.js"; | |
| import type { PreparedEnrichmentBootstrap } from "./prepare-enrichment-bootstrap.js"; | |
| import type { CheckpointObjectStore } from "@osolmaz/hf-job-control"; | |
| const CURRENT_MANIFEST_KEY = "index/current.json"; | |
| export async function commitEnrichmentBootstrap(options: { | |
| prepared: PreparedEnrichmentBootstrap; | |
| bucket: DurableIndexBucketReader; | |
| store: CheckpointObjectStore; | |
| attemptId: string; | |
| jobId?: string; | |
| }): Promise<{ runId: string; planSha256: string }> { | |
| const before = await options.bucket.readText(CURRENT_MANIFEST_KEY); | |
| if (before !== options.prepared.pointerBytes) { | |
| throw new Error("durable index changed after bootstrap preparation"); | |
| } | |
| const result = await bootstrapEnrichmentRun({ | |
| sourceDatabasePath: options.prepared.sourceDatabasePath, | |
| compactDatabasePath: options.prepared.compactDatabasePath, | |
| registryBaselineScanned: options.prepared.candidate.registry.baseline_scanned, | |
| ...(options.prepared.registryCursor === undefined | |
| ? {} | |
| : { registryCursor: options.prepared.registryCursor }), | |
| store: options.store, | |
| attemptId: options.attemptId, | |
| ...(options.jobId === undefined ? {} : { jobId: options.jobId }), | |
| planInput: options.prepared.planInput, | |
| }); | |
| const after = await options.bucket.readText(CURRENT_MANIFEST_KEY); | |
| if (after !== options.prepared.pointerBytes) { | |
| throw new Error("durable index changed during bootstrap commit"); | |
| } | |
| await activateEnrichmentRun({ | |
| store: options.store, | |
| runId: result.runId, | |
| planSha256: result.planSha256, | |
| activatedAt: new Date().toISOString(), | |
| }); | |
| return result; | |
| } | |