import { type LicensePolicy } from "@mailwoman/license/policy"; import { PathBuilder, type PathBuilderLike } from "path-ts"; import { type AlignTotalsRecord } from "#build/align/totals"; import type { AlignSettings } from "#build/checkpoint"; import type { BuildProfile } from "#build/types"; import { type CountryHoldout, type SplitName } from "#utils/split"; /** * One range's place in its source's canonical file. */ export interface AlignRangePlan { index: number; count: number; /** * The canonical file's size when the plan was made. */ canonicalBytes: number; /** * First byte of the range, at the start of a line. */ start: number; /** * One past the last byte of the range: the byte after a newline, or the end of the file. */ end: number; } /** * The files one range's task writes, by name. * * `staged-.txt` holds each labeled row as {@linkcode encodeStagedRow} writes it, so the finish * worker shuffles and writes the parquet staging lines without parsing a row or serializing it again. */ export declare const ALIGN_RANGE_OUTPUTS: readonly ["staged-train.txt", "staged-val.txt", "staged-test.txt", "quarantine.jsonl", "source-ids-train.txt", "source-ids-val.txt", "source-ids-test.txt"]; export type AlignRangeOutputName = (typeof ALIGN_RANGE_OUTPUTS)[number]; /** * What a finished range's task records beside its outputs. */ export interface AlignRangeRecord { plan: AlignRangePlan; settings: AlignSettings; /** * Each output's size in bytes after it was closed. */ outputs: Record; totals: AlignTotalsRecord; completed_at: string; } /** * The record's name in a range's directory, written by {@linkcode runAlignRange} * after every output is closed. */ export declare const ALIGN_RANGE_RECORD_FILE = "RANGE_COMPLETE.json"; /** * The directory one range's task writes into. */ export declare function alignRangeDirectory(sourceDir: PathBuilderLike, plan: Pick): PathBuilder; /** * Divide a canonical file into at most `count` ranges that each begin at a line start. * * The boundaries sit at the first line start at or after each `i / count` of the file, * The file determines those boundaries. * A file with fewer lines than `count` yields fewer ranges, and an empty file yields one empty range. */ export declare function planAlignRanges(path: PathBuilderLike, count: number): Promise; export interface AlignRangeOptions { canonicalPath: PathBuilderLike; plan: AlignRangePlan; sourceDir: PathBuilderLike; corpusVersion: string; synthesize: boolean; profile: BuildProfile; licensePolicy: LicensePolicy; excludeLicenses: readonly RegExp[]; holdouts: Record; trainShares?: Readonly>; eligibility: ReadonlyMap | null; } /** * The record of a range that a resumed build may reuse, or `null` when the range must be aligned again. * * Reuse needs the same offsets in a file of the same size, the same settings, * and every output at its recorded size. * A task killed before it wrote its record leaves no record, so its range is aligned again. */ export declare function reusableAlignRange(sourceDir: PathBuilderLike, plan: AlignRangePlan, settings: AlignSettings): Promise; /** * Align one range into its directory and write its record. */ export declare function runAlignRange(opts: AlignRangeOptions): Promise; /** * Each split's staged-row files and source-id lists across a source's ranges, in range order. */ export declare function alignRangeSplitFiles(sourceDir: PathBuilderLike, plans: readonly AlignRangePlan[]): Record; //# sourceMappingURL=range.d.ts.map