Skip to content

Result export (altar.export)

altar.export renders stored model scores and annotations into wide TSV/Parquet tables, striped wide Parquet datasets (altar-wide/1), unified long datasets (altar-long/1), prioritized NDJSON streams, and augmented VCF buckets—locally or through single-scan BigQuery WarehouseExportSession.

Maturity: 38 Stable, 75 Provisional (113 exports total). Related guides: Read and export results · Warehouse scale on BigQuery · Assemble results and publish datasets.

from altar.export import WarehouseExportSession, ExportsLongScores, export_long_dataset

Summary

Warehouse session & dataset writers

Symbol Description Maturity
WarehouseExportSession Reusable staged BigQuery export session (async with store.warehouse_export(...) as exp:, provisional). Provisional
ExportsLongScores Capability of a ScoreStore that exports selected scores as the altar-long/1 partitioned dataset. Provisional
export_long_dataset Export models across one or more ScoreStores into an altar-long/1 partitioned dataset. Provisional
export_wide_parquet Export a column-striped altar-wide/1 dataset from ResultBuckets or a ScoreStore. Provisional
open_wide_dataset Open an altar-wide/1 column-striped dataset and return a horizontally aligned pyarrow.Table. Provisional
render_wide_dataset Render ResultBuckets into a column-striped altar-wide/1 Parquet dataset. Provisional
render_wide_parquet Write the buckets as the wide table in Parquet, <destination_uri>/part-000000000000.parquet. Stable
render_wide_tsv Write the buckets as the gzipped, tab-delimited wide table <destination_uri>/<part>, and return the prefix. Stable
render_prioritized_ndjson Write the prioritized variants as gzipped NDJSON, <destination_uri>/part-000000000000.json.gz. Stable
render_augmentation_buckets Join buckets onto a VCF ingest's occurrences and write v2 occurrence buckets; return their URIs. Stable

Cross-model reducers

Symbol Description Maturity
CrossModelReducer Base class for typed cross-model summary reducers. Provisional
TopModel Pick the top-ranked model row per variant and emit its ID, display name, and signed effect. Provisional
MaxAbs Compute MAX(ABS(effect)) across a variant's non-null, non-NaN scored (or prioritized) models. Provisional
CountWhere Count a variant's scored models (prioritized_only=False) or prioritized models (prioritized_only=True). Provisional
PrioritizedCounts How much of an export is prioritized (ResultBuckets.prioritized_counts). Stable

Wide & striped dataset layouts (altar-wide/1)

Symbol Description Maturity
WideExportLayout The column layout of the wide exports, built by wide_layout. Stable
ModelExportBlock The wide-export columns of one model. Stable
WideStripeSpec Planned vertical stripe of whole ModelExportBlocks. Provisional
WideDatasetManifest The manifest of a column-striped wide Parquet dataset (altar-wide/1). Provisional
WideDatasetModelEntry Per-model identity and lineage provenance in altar-wide/1 _manifest.json (provisional). Provisional
WideDatasetStripeEntry One vertical model-column stripe under stripes/<name>. Provisional
WideDatasetFileEntry One Parquet part of variants/ or stripes/<name>/. Provisional
WideDatasetExport What export_wide_parquet / render_wide_dataset wrote. Provisional
wide_layout Build the wide-export layout for models and annotation_sources (see the module docstring). Stable
plan_wide_stripes Partition layout.model_blocks into <max_columns_per_stripe-column and <750 KB-SQL stripes. Provisional
wide_column_manifest Describe every column of layout, one entry per column in layout.columns order. Stable
column_manifest_tsv Render manifest entries as the text of _columns.tsv. Stable
write_column_manifest Write the column manifest of layout as <destination_uri>/_columns.tsv and return its URI. Stable
write_models_manifest Write per-model lineage provenance (<destination_uri>/_models.json, provisional) and return its URI. Provisional
read_wide_dataset_manifest Read the altar-wide/1 manifest at destination_uri through storage. Provisional
write_wide_tsv_header Write the wide TSV's header row, layout.columns, to sink as one gzip member. Stable
write_wide_tsv_member Write one bucket's wide TSV rows to sink as one gzip member, in genomic order. Stable
write_prioritized_ndjson_member Write one bucket's prioritized variants to sink as NDJSON in one gzip member, in genomic order. Stable
ColumnManifestEntry One column of a wide export, as wide_column_manifest describes it. Stable
ColumnKind What a wide column holds (ColumnManifestEntry.kind). Stable
export_col_alias Build the wide-export column name of one model field: the model's prefix plus the field's name. Stable
export_column_prefix Build a model's stable, collision-resistant column prefix for the wide exports (see model_column_prefix). Stable
model_column_prefix Build a model's stable, collision-resistant column prefix for wide exports and VCF manifests. Provisional
WIDE_DATASET_FORMAT The format identifier recorded in a column-striped wide Parquet _manifest.json. Provisional
WIDE_DATASET_MANIFEST The manifest file name under the destination, written last as the atomic completion marker. Provisional
COLUMN_MANIFEST_FILE The file the column manifest of a wide export is written to, beside its part. Stable
MODELS_MANIFEST_FILE The file a wide TSV export's per-model lineage provenance is written to, beside its part. Provisional
DOWNLOAD_PART Public export. Stable
PRIORITIZED_PART Public export. Stable
DEFAULT_MAX_COLUMNS_PER_STRIPE Default maximum columns per wide Parquet stripe (keeps stripe SQL well below BigQuery's 1 MB query limit). Provisional
DEFAULT_WIDE_SORT_CELL_BUDGET Default cell budget (rows_per_range * len(layout.columns)) per CSV export slice in export_wide_tsv. Provisional

Unified long datasets (altar-long/1)

Symbol Description Maturity
LongDatasetManifest The manifest of a unified long dataset, altar-long/1, at <destination>/_manifest.json. Provisional
LongDatasetScope Which variants the dataset covers: every stored one, a listed set, or a relation in the store. Provisional
LongDatasetModelEntry One model of the dataset, including its column_prefix, identity, and accepted lineages. Provisional
LongDatasetAnnotationSourceEntry One annotation source included in variants/ when has_variants=True. Provisional
LongDatasetTableEntry One score table: its directory, the plugin and result schema version its models share, and its columns. Provisional
LongDatasetColumnEntry One column of a Parquet table in the dataset: its name and its Arrow type. Provisional
LongDatasetFieldEntry One score column a model declares: its name, its type, and what it means. Provisional
LongDatasetFileEntry One Parquet file of the dataset: its relative path, table, partition, size, rows, and checksums. Provisional
LongDatasetExport What export_long_dataset / export_long_scores wrote: its destination and its manifest. Provisional
LongScoresManifest Public export. Provisional
LongScoresScope Public export. Provisional
LongScoresModelEntry Public export. Provisional
LongScoresTableEntry Public export. Provisional
LongScoresColumnEntry Public export. Provisional
LongScoresFieldEntry Public export. Provisional
LongScoresFileEntry Public export. Provisional
LongScoresExport Public export. Provisional
LongScoreTable One score table of the long export: the models whose plugin and result schema version it holds (provisional). Provisional
StoreMapping Public export. Provisional
long_score_tables Group the layout's models into score tables by plugin ID and result schema version (provisional). Provisional
long_dataset_schema Return the Arrow schema of one score table's files (scores/<schema_family>/chromosome=<chr>/part-*.parquet). Provisional
long_variants_schema Return the Arrow schema of variants/chromosome=<chr>/part-*.parquet when include_variants=True. Provisional
long_scores_schema Return the Arrow schema of one score-only table's files (include_prioritized=False). Provisional
long_dataset_manifest_json_schema Return the published JSON Schema of a long dataset manifest, altar-long/1. Provisional
long_scores_manifest_json_schema Public export. Provisional
read_long_dataset_manifest Read the altar-long/1 manifest at destination_uri; refuses manifests of any other format. Provisional
read_long_scores_manifest Public export. Provisional
LONG_DATASET_FORMAT The canonical format identifier recorded in _manifest.json. Provisional
LONG_DATASET_MANIFEST The manifest file name under the dataset destination, written last as the atomic completion marker. Provisional
LONG_DATASET_METADATA_KEY The Parquet key-value metadata key describing a local writer's score or variant file. Provisional
LONG_SCORES_FORMAT Public export. Provisional
LONG_SCORES_MANIFEST Public export. Provisional
LONG_SCORES_METADATA_KEY Public export. Provisional

Result & augmentation buckets

Symbol Description Maturity
ResultBuckets The buckets of one export, as a store produces them. Stable
ResultBucket One bucket's rows: a table with result_bucket_schema, its rows in no particular order. Stable
ResultBucketDescriptor One bucket of an export: its number, the ordinals it covers, and its row count. Stable
ResultBucketSql The SQL BigQueryScoreStore.result_buckets runs for one export, rendered without a client (provisional). Provisional
BucketLoader Reads one bucket's rows; a producer passes it to ResultBuckets. Stable
BucketReader Opens a loader for one iteration of ResultBuckets, with state of its own, and closes it when the iteration ends. Stable
ExportStaging Where BigQueryScoreStore stages an export's Parquet shards, and how it reads them back. Stable
VariantBridge Mapping relation that re-keys an annotation source from a target coordinate space to the job's variant_ids. Provisional
ChromosomeBounds Per-chromosome inclusive variant_id (and optional pos) range for pruning 1M-70M variant tables. Provisional
bucket_export_layout Build the wide layout of a result-bucket export: wide_layout with typed cross-model reducer columns. Stable
plan_buckets Cut row_count ordinals into consecutive buckets of bucket_rows, the last one possibly shorter. Stable
bucket_rows_for Return the variants per bucket: bucket_rows, or bucket_bytes (default 128 MiB) over the estimate. Stable
build_result_bucket_sql Render the SQL BigQueryScoreStore(…, table_id).result_buckets runs for these arguments (provisional). Provisional
predicate_groups Return each distinct model predicate's SQL, in first-seen order, and each model's index into that list. Provisional
result_bucket_schema Return the Arrow schema of a result bucket for layout (see the module docstring). Stable
augmentation_bucket_schema Return the Arrow schema of a v2 occurrence-bucket part for layout and include_model_scores. Stable
estimated_variant_bytes Estimate one variant's size in a bucket, from the layout alone, as if every model scored it. Provisional
genomic_sort_key Return the key that orders canonical variant ids in genomic order. Stable
ProvenanceCallback Returns the provenance of the rows a wide writer wrote; the writer calls it once, after the last row. Stable
RESULT_BUCKET_SCHEMA_VERSION The version of the result-bucket schema this module defines; bumped by any change to its columns. Stable
AUGMENTATION_BUCKET_SCHEMA_VERSION The version of the occurrence-bucket format this module defines; the augmented-VCF manifest records it. Stable

Parity comparison & exceptions

Symbol Description Maturity
compare_wide_tsvs Compare two gzipped wide TSVs as sets of rows keyed by variant_id, cell by cell (provisional). Provisional
compare_prioritized_ndjson Compare two prioritized NDJSON exports record by record, by value (provisional). Provisional
WideTsvComparison The result of compare_wide_tsvs. Provisional
NdjsonComparison The result of compare_prioritized_ndjson (provisional). Provisional
CellDifference One cell that differs between two wide TSVs: its row's variant_id, its column, and both values. Provisional
FieldDifference One field that differs between two prioritized NDJSON records (provisional). Provisional
cells_equal Return whether two TSV cells hold the same value, across Altar's and BigQuery's encodings (provisional). Provisional
values_equal Return whether two decoded values are equal by value, across Altar's and BigQuery's encodings (provisional). Provisional
WideExportColumnLimitExceeded A warehouse wide TSV export exceeds BigQuery's physical table column limit (10,000 columns). Provisional
ExportDuplicateRowsError An export holds more than one row for some variant, where its contract is one row per variant. Stable
ExportScanLimitExceeded A store refused an export whose estimated scan exceeds the configured maximum_bytes_billed. Stable
LongDatasetExportUnsupported A store cannot export this long dataset request, for the reason in the message. Provisional
LongScoresExportUnsupported Public export. Provisional

Warehouse session & dataset writers API

Result export: unified long datasets, striped wide datasets, result buckets, and writers.

Hosts and scripts that export stored results import these names from :mod:altar.export, the supported import path. The modules under altar.plugins that define them are not public API. The stores an export reads from, and their lineage and reuse rules, are in :mod:altar.results.

The wide layout is stable: wide_layout computes it as a WideExportLayout of ModelExportBlock values, and export_column_prefix (provisional alias model_column_prefix) computes each model's <name>__<hash12> column prefix. Per-cell score_lineage_id columns are omitted from wide layouts by default (opt-in via include_lineage_ids=True); lineage IDs and observed counts are recorded per model in export manifests (MODELS_MANIFEST_FILE, write_models_manifest, WideDatasetModelEntry) and models/ tables.

Typed cross-model summary reducers (CrossModelReducer, TopModel, MaxAbs, CountWhere, provisional) declare variant-level summary columns compiled into single-pass warehouse SQL and evaluated in pure Python on portable stores.

The result-bucket export is stable too. A store hands its export over as result buckets (ResultBuckets, ResultBucket, ResultBucketDescriptor, PrioritizedCounts, RESULT_BUCKET_SCHEMA_VERSION, result_bucket_schema, genomic_sort_key, and bucket_export_layout, bucket_rows_for and plan_buckets, with which a store that produces its own buckets cuts them). BucketReader and BucketLoader are how ResultBuckets reads its buckets. The writers render them into any storage (render_wide_tsv, render_wide_parquet, render_prioritized_ndjson), recording provenance through a ProvenanceCallback; the per-bucket member writers they loop over feed several outputs from one pass (write_wide_tsv_header, write_wide_tsv_member, write_prioritized_ndjson_member). DOWNLOAD_PART and PRIORITIZED_PART are the file names of the first wide and prioritized export parts. An export refuses to repeat a variant (ExportDuplicateRowsError), and BigQuery's cost guard refuses a scan over its limit (ExportScanLimitExceeded). The wide export's column manifest (wide_column_manifest, ColumnManifestEntry, ColumnKind, column_manifest_tsv, write_column_manifest, COLUMN_MANIFEST_FILE) and its <name>__<hash12>_<field> column rule (export_col_alias) are stable, and so are the augmented VCF's occurrence buckets v2 (render_augmentation_buckets, augmentation_bucket_schema, AUGMENTATION_BUCKET_SCHEMA_VERSION) and ExportStaging.

The unified partitioned long dataset (altar-long/1: export_long_dataset, LONG_DATASET_FORMAT, LongDatasetManifest and its entries, read_long_dataset_manifest, long_dataset_schema, long_variants_schema, long_dataset_manifest_json_schema, plus ExportsLongScores and the LONG_SCORES_* aliases), the column-striped partitioned wide Parquet dataset (altar-wide/1: export_wide_parquet, render_wide_dataset, open_wide_dataset, plan_wide_stripes, WideDatasetManifest and its entries, read_wide_dataset_manifest), warehouse cluster-pruning helpers (ChromosomeBounds, VariantBridge), and low-level bucket SQL helpers (estimated_variant_bytes, ResultBucketSql, build_result_bucket_sql, predicate_groups), and value-level export comparators (compare_wide_tsvs, WideTsvComparison, CellDifference, compare_prioritized_ndjson, NdjsonComparison, FieldDifference, cells_equal, values_equal) are provisional and listed in __provisional__.

WarehouseExportSession

WarehouseExportSession(
    *,
    store: BigQueryScoreStore,
    models: tuple[ScoredModel, ...],
    annotation_sources: tuple[AnnotationSource, ...],
    layout: WideExportLayout,
    reducers: tuple[CrossModelReducer, ...],
    annotations_table: str,
    model_rows_table: str | None,
    resolutions: dict[str, Resolution],
    store_by_model: dict[str, ScoreStore],
    source_flags: dict[str, str],
    score_fields: tuple[tuple[str, str], ...],
    anno_field_types: dict[str, tuple[str, str]],
    anno_schema_by_name: dict[str, Any],
    variant_ids: tuple[str, ...],
    variants_relation: str | None,
    limit: int | None,
    store_label: str,
    scratch: list[tuple[BigQueryScoreStore, str]],
    resumed: bool = False,
)

Reusable staged BigQuery export session (async with store.warehouse_export(...) as exp:, provisional).

Entering the session collapses all applicable annotation_sources once into annotations_table and scans each distinct physical BigQueryScoreStore table at most once into model_rows_table (clustered by _altar_chr, _altar_pos, model_id, variant_id). All export methods on the session (export_prioritized_ndjson, export_wide_tsv, export_wide_parquet, export_long_dataset, and export_augmentation_buckets) read those staged tables without rescanning any base score or annotation table, and drop all session scratch tables (including a caller-named annotations_table) when the async with block exits (with resume_key=, completed staged tables are retained for 24h when the session exits on an exception so a retry skips re-reading the sources).

store property

The primary BigQueryScoreStore that opened this session.

models property

models: tuple[ScoredModel, ...]

The session's scored models in declaration order.

annotation_sources property

annotation_sources: tuple[AnnotationSource, ...]

The staged/applicable annotation sources joined into annotations_table.

reducers property

reducers: tuple[CrossModelReducer, ...]

The normalized cross-model summary reducers configured on this session.

layout property

The session's wide export layout.

annotations_table property

annotations_table: str

The BigQuery table ID holding one collapsed annotation row per job variant while the session is open.

model_rows_table property

model_rows_table: str | None

Deduplicated (variant, model) score table clustered by (_altar_chr, _altar_pos, model_id, variant_id).

resolutions property

resolutions: dict[str, Resolution]

Each model's resolved accepted lineages, keyed by model_id.

resumed property

resumed: bool

Whether this session adopted staged tables completed by an earlier failed attempt with resume_key=.

export_prioritized_ndjson async

export_prioritized_ndjson(
    *,
    destination_uri: str,
    storage: Storage,
    include_lineage_ids: bool = False,
    provenance: ProvenanceCallback | None = None,
    overwrite: bool = False,
) -> list[str]

Export prioritized variants as gzipped NDJSON shards from the staged session tables.

export_wide_parquet async

export_wide_parquet(
    *,
    destination_uri: str,
    storage: Storage,
    prioritized_only: bool = False,
    include_lineage_ids: bool = False,
    max_columns_per_stripe: int = DEFAULT_MAX_COLUMNS_PER_STRIPE,
    rows_per_export_range: int = DEFAULT_STRIPE_RANGE_ROWS,
    overwrite: bool = False,
    provenance: ProvenanceCallback | None = None,
    max_concurrent_jobs: int = 8,
) -> WideDatasetExport

Export altar-wide/1 column-striped Parquet from the staged session tables.

export_wide_tsv async

export_wide_tsv(
    *,
    destination_uri: str,
    storage: Storage,
    prioritized_only: bool = False,
    include_lineage_ids: bool = False,
    single_file: bool = False,
    part: str = TSV_PART,
    wide_sort_cell_budget: int = DEFAULT_WIDE_SORT_CELL_BUDGET,
    overwrite: bool = False,
    provenance: ProvenanceCallback | None = None,
    max_concurrent_jobs: int = 8,
    workers: int = 1,
    allow_bucket_fallback: bool = False,
) -> list[str]

Export wide .tsv.gz from the staged session tables with cell-budgeted range slicing.

Up to BigQuery's 10,000-column table ceiling (_BIGQUERY_MAX_COLUMNS), runs 100% server-side in BigQuery: inline in one EXPORT DATA query when SQL fits under 950 KB, or pre-pivoted across <=2,000-column scratch slice tables joined via p{k}.* EXCEPT (...) when inline SQL exceeds 950 KB (e.g. 1,100-1,990 models). Above 10,000 columns, raises WideExportColumnLimitExceeded unless allow_bucket_fallback=True is passed.

export_long_dataset async

export_long_dataset(
    destination_uri: str,
    *,
    storage: Storage,
    chromosomes: Sequence[str] | None = None,
    include_variants: bool = False,
    overwrite: bool = False,
    provenance: ProvenanceCallback | None = None,
    max_concurrent_jobs: int = DEFAULT_LONG_SCORES_JOBS,
) -> LongDatasetExport

Export altar-long/1 directly from staged model_rows_table and annotations_table without rescans.

export_augmentation_buckets async

export_augmentation_buckets(
    *,
    occurrence_relation: str,
    destination_uri: str,
    max_record_ordinal: int,
    bucket_size: int,
    include_model_scores: bool | Sequence[str] = False,
) -> list[str]

Write v2 occurrence buckets directly from staged session tables without building ResultBuckets.

ExportsLongScores

Bases: Protocol

Capability of a ScoreStore that exports selected scores as the altar-long/1 partitioned dataset.

export_long_dataset async

export_long_dataset(
    stores: StoreMapping,
    models: Sequence[ScoredModel],
    destination_uri: str,
    *,
    storage: Storage,
    variants: Sequence[str] | StoreRelation | None = None,
    chromosomes: Sequence[str] | None = None,
    include_variants: bool = False,
    annotation_sources: Sequence[AnnotationSource] = (),
    reducers: CrossModelReducer
    | Sequence[CrossModelReducer]
    | None = None,
    rider: DisplayRider | None = None,
    annotations_table: str | None = None,
    keep_all_sources: bool = False,
    overwrite: bool = False,
    provenance: ProvenanceCallback | None = None,
    rows_per_file: int = DEFAULT_ROWS_PER_FILE,
    maximum_bytes_billed: int | None = None,
    max_concurrent_jobs: int = 4,
    stage_portable_sources: bool = True,
) -> LongDatasetExport

Export models across one or more ScoreStores into an altar-long/1 partitioned dataset.

export_wide_parquet async

export_wide_parquet(
    source: ResultBuckets | StoreMapping,
    destination_uri: str,
    *,
    storage: Storage,
    variant_ids: Sequence[str] = (),
    models: Sequence[ScoredModel] = (),
    annotation_sources: Sequence[AnnotationSource] = (),
    reducers: CrossModelReducer
    | Sequence[CrossModelReducer]
    | None = None,
    rider: DisplayRider | None = None,
    variants_relation: str | None = None,
    annotations_table: str | None = None,
    prioritized_only: bool = False,
    include_lineage_ids: bool = False,
    max_columns_per_stripe: int = DEFAULT_MAX_COLUMNS_PER_STRIPE,
    rows_per_export_range: int = DEFAULT_STRIPE_RANGE_ROWS,
    overwrite: bool = False,
    provenance: ProvenanceCallback | None = None,
    maximum_bytes_billed: int | None = None,
    max_concurrent_jobs: int = 8,
    stage_portable_sources: bool = True,
) -> WideDatasetExport

Export a column-striped altar-wide/1 dataset from ResultBuckets or a ScoreStore.

open_wide_dataset

open_wide_dataset(
    uri: str | Path,
    *,
    columns: Sequence[str] | None = None,
    chromosomes: Sequence[str] | None = None,
    storage_options: Mapping[str, Any] | None = None,
) -> Table

Open an altar-wide/1 column-striped dataset and return a horizontally aligned pyarrow.Table.

Reads _manifest.json first and opens only variants/ and the stripe directories containing requested columns (pushing column selection down into Parquet footers). Works on local paths, file://, and remote object-store URIs (gs://, s3://, memory://).

render_wide_dataset async

render_wide_dataset(
    buckets: ResultBuckets,
    destination_uri: str,
    *,
    storage: Storage,
    prioritized_only: bool = False,
    include_lineage_ids: bool = False,
    max_columns_per_stripe: int = DEFAULT_MAX_COLUMNS_PER_STRIPE,
    overwrite: bool = False,
    provenance: ProvenanceCallback | None = None,
    store_name: str = "portable",
) -> WideDatasetExport

Render ResultBuckets into a column-striped altar-wide/1 Parquet dataset.

render_wide_parquet async

render_wide_parquet(
    buckets: ResultBuckets,
    destination_uri: str,
    *,
    storage: Storage,
    prioritized_only: bool = False,
    include_lineage_ids: bool = False,
    provenance: ProvenanceCallback | None = None,
) -> str

Write the buckets as the wide table in Parquet, <destination_uri>/part-000000000000.parquet.

The schema is arrow_schema(buckets.layout) (with <prefix>_score_lineage_id appended per model block when include_lineage_ids=True), rider columns included. Each bucket is one row group, so the bucket size sets the row-group size. With provenance, its mapping is stored as JSON text in the file's key-value metadata under altar.provenance.

render_wide_tsv async

render_wide_tsv(
    buckets: ResultBuckets,
    destination_uri: str,
    *,
    storage: Storage,
    prioritized_only: bool = False,
    include_lineage_ids: bool = False,
    part: str = DOWNLOAD_PART,
    provenance: ProvenanceCallback | None = None,
    workers: int = 1,
) -> str

Write the buckets as the gzipped, tab-delimited wide table <destination_uri>/<part>, and return the prefix.

The columns are buckets.layout.columns (with <prefix>_score_lineage_id appended per model block when include_lineage_ids=True), with a header row. NULL is empty, a boolean true/false, a NaN or infinite float NaN, Infinity or -Infinity, and a repeated, struct or json value its compact JSON text (see altar.plugins.data_lake.export). Rows are in genomic order. prioritized_only keeps only the prioritized variants. part defaults to the name a warehouse export's first shard has; altar run passes TSV_PART. Per-model lineage provenance (accepted_lineage_ids and observed_lineage_counts) is written beside the part as <destination_uri>/_models.json, and with provenance, its mapping is written to <destination_uri>/_provenance.json after the last row. workers above 1 renders the buckets in that many processes (_write_members_in_pool), with the same bytes.

render_prioritized_ndjson async

render_prioritized_ndjson(
    buckets: ResultBuckets,
    destination_uri: str,
    *,
    storage: Storage,
    int64_as_string: bool = True,
    include_lineage_ids: bool = False,
    provenance: ProvenanceCallback | None = None,
    workers: int = 1,
) -> str

Write the prioritized variants as gzipped NDJSON, <destination_uri>/part-000000000000.json.gz.

Each line is one prioritized variant's record, with these fields in this order: variant_id, any cross-model reducer columns, model_scores (each entry model_id, model_name, every score field of the export, prioritized, plus score_lineage_id only when include_lineage_ids=True), prioritized_model_ids, prioritized_source_names, each annotation column in its native shape, then prioritized. Records are in genomic order, and each record's model_scores in the order of the export's models.

Altar's NDJSON format: a missing repeated value is [], a NaN or infinite float is the string "NaN", "Infinity" or "-Infinity" (JSON has no such numbers, and a database's JSON type refuses the bare tokens), with int64_as_string (the default) an integer is a JSON string, a null field is written as null, and a float is its shortest round-trip text. BigQuery's JSON export omits null fields and writes floats to 15 or 17 significant digits.

With provenance, its mapping is written to <destination_uri>/_provenance.json after the last row. workers above 1 renders the buckets in that many processes (_write_members_in_pool), with the same bytes.

render_augmentation_buckets async

render_augmentation_buckets(
    buckets: ResultBuckets,
    occurrence_parts: Sequence[str],
    destination_uri: str,
    *,
    storage: Storage,
    bucket_size: int,
    include_model_scores: bool | Sequence[str] = False,
) -> list[str]

Join buckets onto a VCF ingest's occurrences and write v2 occurrence buckets; return their URIs.


Cross-model reducers API

Result export: unified long datasets, striped wide datasets, result buckets, and writers.

Hosts and scripts that export stored results import these names from :mod:altar.export, the supported import path. The modules under altar.plugins that define them are not public API. The stores an export reads from, and their lineage and reuse rules, are in :mod:altar.results.

The wide layout is stable: wide_layout computes it as a WideExportLayout of ModelExportBlock values, and export_column_prefix (provisional alias model_column_prefix) computes each model's <name>__<hash12> column prefix. Per-cell score_lineage_id columns are omitted from wide layouts by default (opt-in via include_lineage_ids=True); lineage IDs and observed counts are recorded per model in export manifests (MODELS_MANIFEST_FILE, write_models_manifest, WideDatasetModelEntry) and models/ tables.

Typed cross-model summary reducers (CrossModelReducer, TopModel, MaxAbs, CountWhere, provisional) declare variant-level summary columns compiled into single-pass warehouse SQL and evaluated in pure Python on portable stores.

The result-bucket export is stable too. A store hands its export over as result buckets (ResultBuckets, ResultBucket, ResultBucketDescriptor, PrioritizedCounts, RESULT_BUCKET_SCHEMA_VERSION, result_bucket_schema, genomic_sort_key, and bucket_export_layout, bucket_rows_for and plan_buckets, with which a store that produces its own buckets cuts them). BucketReader and BucketLoader are how ResultBuckets reads its buckets. The writers render them into any storage (render_wide_tsv, render_wide_parquet, render_prioritized_ndjson), recording provenance through a ProvenanceCallback; the per-bucket member writers they loop over feed several outputs from one pass (write_wide_tsv_header, write_wide_tsv_member, write_prioritized_ndjson_member). DOWNLOAD_PART and PRIORITIZED_PART are the file names of the first wide and prioritized export parts. An export refuses to repeat a variant (ExportDuplicateRowsError), and BigQuery's cost guard refuses a scan over its limit (ExportScanLimitExceeded). The wide export's column manifest (wide_column_manifest, ColumnManifestEntry, ColumnKind, column_manifest_tsv, write_column_manifest, COLUMN_MANIFEST_FILE) and its <name>__<hash12>_<field> column rule (export_col_alias) are stable, and so are the augmented VCF's occurrence buckets v2 (render_augmentation_buckets, augmentation_bucket_schema, AUGMENTATION_BUCKET_SCHEMA_VERSION) and ExportStaging.

The unified partitioned long dataset (altar-long/1: export_long_dataset, LONG_DATASET_FORMAT, LongDatasetManifest and its entries, read_long_dataset_manifest, long_dataset_schema, long_variants_schema, long_dataset_manifest_json_schema, plus ExportsLongScores and the LONG_SCORES_* aliases), the column-striped partitioned wide Parquet dataset (altar-wide/1: export_wide_parquet, render_wide_dataset, open_wide_dataset, plan_wide_stripes, WideDatasetManifest and its entries, read_wide_dataset_manifest), warehouse cluster-pruning helpers (ChromosomeBounds, VariantBridge), and low-level bucket SQL helpers (estimated_variant_bytes, ResultBucketSql, build_result_bucket_sql, predicate_groups), and value-level export comparators (compare_wide_tsvs, WideTsvComparison, CellDifference, compare_prioritized_ndjson, NdjsonComparison, FieldDifference, cells_equal, values_equal) are provisional and listed in __provisional__.

CrossModelReducer

Bases: ABC

Base class for typed cross-model summary reducers.

output_columns abstractmethod

output_columns() -> tuple[tuple[str, ScalarDtype], ...]

Return the ordered (column_name, dtype) pairs this reducer emits.

effect_spec abstractmethod

effect_spec() -> str | None

Return the score field name or 'primary_effect' this reducer reads, or None if none.

to_dict abstractmethod

to_dict() -> dict[str, Any]

Return a JSON-serializable description of this reducer for export manifests and digests.

TopModel dataclass

TopModel(
    effect: str = PRIMARY_EFFECT_TOKEN,
    prioritize_first: bool = True,
    id_alias: str | None = "top_model_id",
    name_alias: str | None = "top_model_name",
    effect_alias: str | None = "top_effect",
)

Bases: CrossModelReducer

Pick the top-ranked model row per variant and emit its ID, display name, and signed effect.

Non-null, non-NaN effect rows are ranked by (is_prioritized DESC, ABS(effect) DESC, model_id ASC) when prioritize_first=True, or (ABS(effect) DESC, model_id ASC) when prioritize_first=False. The winning row's signed effect (never ABS(effect)), model_id, and caller-supplied ScoredModel.model_name are projected under id_alias, name_alias, and effect_alias; pass None for any alias to omit that column.

MaxAbs dataclass

MaxAbs(
    effect: str = PRIMARY_EFFECT_TOKEN,
    prioritized_only: bool = False,
    alias: str = "max_abs_effect",
)

Bases: CrossModelReducer

Compute MAX(ABS(effect)) across a variant's non-null, non-NaN scored (or prioritized) models.

CountWhere dataclass

CountWhere(
    prioritized_only: bool = True,
    alias: str = "prioritized_model_count",
)

Bases: CrossModelReducer

Count a variant's scored models (prioritized_only=False) or prioritized models (prioritized_only=True).

PrioritizedCounts dataclass

PrioritizedCounts(variants: int, variant_models: int)

How much of an export is prioritized (ResultBuckets.prioritized_counts).

variants is the number of prioritized variants, the rows of the prioritized view and of every prioritized output. variant_models is the number of model_scores entries those variants hold, every model's entry whether or not that model prioritized the variant: the per-model cells a prioritized download fills.


Wide & striped dataset layouts (altar-wide/1) API

Result export: unified long datasets, striped wide datasets, result buckets, and writers.

Hosts and scripts that export stored results import these names from :mod:altar.export, the supported import path. The modules under altar.plugins that define them are not public API. The stores an export reads from, and their lineage and reuse rules, are in :mod:altar.results.

The wide layout is stable: wide_layout computes it as a WideExportLayout of ModelExportBlock values, and export_column_prefix (provisional alias model_column_prefix) computes each model's <name>__<hash12> column prefix. Per-cell score_lineage_id columns are omitted from wide layouts by default (opt-in via include_lineage_ids=True); lineage IDs and observed counts are recorded per model in export manifests (MODELS_MANIFEST_FILE, write_models_manifest, WideDatasetModelEntry) and models/ tables.

Typed cross-model summary reducers (CrossModelReducer, TopModel, MaxAbs, CountWhere, provisional) declare variant-level summary columns compiled into single-pass warehouse SQL and evaluated in pure Python on portable stores.

The result-bucket export is stable too. A store hands its export over as result buckets (ResultBuckets, ResultBucket, ResultBucketDescriptor, PrioritizedCounts, RESULT_BUCKET_SCHEMA_VERSION, result_bucket_schema, genomic_sort_key, and bucket_export_layout, bucket_rows_for and plan_buckets, with which a store that produces its own buckets cuts them). BucketReader and BucketLoader are how ResultBuckets reads its buckets. The writers render them into any storage (render_wide_tsv, render_wide_parquet, render_prioritized_ndjson), recording provenance through a ProvenanceCallback; the per-bucket member writers they loop over feed several outputs from one pass (write_wide_tsv_header, write_wide_tsv_member, write_prioritized_ndjson_member). DOWNLOAD_PART and PRIORITIZED_PART are the file names of the first wide and prioritized export parts. An export refuses to repeat a variant (ExportDuplicateRowsError), and BigQuery's cost guard refuses a scan over its limit (ExportScanLimitExceeded). The wide export's column manifest (wide_column_manifest, ColumnManifestEntry, ColumnKind, column_manifest_tsv, write_column_manifest, COLUMN_MANIFEST_FILE) and its <name>__<hash12>_<field> column rule (export_col_alias) are stable, and so are the augmented VCF's occurrence buckets v2 (render_augmentation_buckets, augmentation_bucket_schema, AUGMENTATION_BUCKET_SCHEMA_VERSION) and ExportStaging.

The unified partitioned long dataset (altar-long/1: export_long_dataset, LONG_DATASET_FORMAT, LongDatasetManifest and its entries, read_long_dataset_manifest, long_dataset_schema, long_variants_schema, long_dataset_manifest_json_schema, plus ExportsLongScores and the LONG_SCORES_* aliases), the column-striped partitioned wide Parquet dataset (altar-wide/1: export_wide_parquet, render_wide_dataset, open_wide_dataset, plan_wide_stripes, WideDatasetManifest and its entries, read_wide_dataset_manifest), warehouse cluster-pruning helpers (ChromosomeBounds, VariantBridge), and low-level bucket SQL helpers (estimated_variant_bytes, ResultBucketSql, build_result_bucket_sql, predicate_groups), and value-level export comparators (compare_wide_tsvs, WideTsvComparison, CellDifference, compare_prioritized_ndjson, NdjsonComparison, FieldDifference, cells_equal, values_equal) are provisional and listed in __provisional__.

WIDE_DATASET_FORMAT module-attribute

WIDE_DATASET_FORMAT: Final = 'altar-wide/1'

The format identifier recorded in a column-striped wide Parquet _manifest.json.

WIDE_DATASET_MANIFEST module-attribute

WIDE_DATASET_MANIFEST = '_manifest.json'

The manifest file name under the destination, written last as the atomic completion marker.

COLUMN_MANIFEST_FILE module-attribute

COLUMN_MANIFEST_FILE = '_columns.tsv'

The file the column manifest of a wide export is written to, beside its part.

MODELS_MANIFEST_FILE module-attribute

MODELS_MANIFEST_FILE = '_models.json'

The file a wide TSV export's per-model lineage provenance is written to, beside its part.

DOWNLOAD_PART module-attribute

DOWNLOAD_PART = 'part-000000000000.csv.gz'

PRIORITIZED_PART module-attribute

PRIORITIZED_PART = 'part-000000000000.json.gz'

DEFAULT_MAX_COLUMNS_PER_STRIPE module-attribute

DEFAULT_MAX_COLUMNS_PER_STRIPE = 4000

Default maximum columns per wide Parquet stripe (keeps stripe SQL well below BigQuery's 1 MB query limit).

DEFAULT_WIDE_SORT_CELL_BUDGET module-attribute

DEFAULT_WIDE_SORT_CELL_BUDGET = 100000000

Default cell budget (rows_per_range * len(layout.columns)) per CSV export slice in export_wide_tsv.

ColumnKind

ColumnKind = Literal[
    "variant_key",
    "prioritization",
    "display",
    "annotation",
    "score",
    "lineage",
]

What a wide column holds (ColumnManifestEntry.kind).

WideExportLayout dataclass

WideExportLayout(
    columns: tuple[str, ...],
    rider_columns: tuple[str, ...],
    annotation_columns: tuple[AnnotationColumn, ...],
    model_blocks: tuple[ModelExportBlock, ...],
    annotation_source_names: tuple[str, ...] = (),
    rider_dtypes: tuple[ScalarDtype, ...] = (),
)

The column layout of the wide exports, built by wide_layout.

columns is every column in order. row renders one MaterializedVariant into that layout with logical values: an absent annotation and every field of a model that did not score the variant are None. The writers encode those values per format. annotation_source_names names the source of each of annotation_columns, in the same order. rider_dtypes is the scalar type of each of rider_columns when it is known (a layout built for result buckets knows them), and empty otherwise.

json_text_columns

json_text_columns() -> frozenset[str]

Return the annotation columns a CSV cell holds as JSON text: repeated, struct, and json columns.

ModelExportBlock dataclass

ModelExportBlock(
    model_id: str,
    column_prefix: str,
    fields: tuple[ExportField, ...],
    model_name: str = "",
    plugin_id: str = "",
    plugin_version: str = "",
    result_schema_version: str = "",
    result_schema_hash: str = "",
    primary_effect: str | None = None,
)

The wide-export columns of one model.

fields are its columns in order: its score columns, followed by prioritized. Score lineage IDs are recorded at model level in dataset manifests and models/ tables rather than repeated in every wide cell. The other fields say whose columns they are: the model's display model_name, and the plugin_id, plugin_version, result_schema_version, result_schema_hash, and primary_effect of its plugin and result schema.

score_fields property

score_fields: tuple[ExportField, ...]

The block's score columns, without its prioritized.

WideStripeSpec dataclass

WideStripeSpec(
    name: str,
    path: str,
    blocks: tuple[ModelExportBlock, ...],
    start_position: int = 0,
)

Planned vertical stripe of whole ModelExportBlocks.

WideDatasetManifest

Bases: _WideEntry

The manifest of a column-striped wide Parquet dataset (altar-wide/1).

WideDatasetModelEntry

Bases: _WideEntry

Per-model identity and lineage provenance in altar-wide/1 _manifest.json (provisional).

WideDatasetStripeEntry

Bases: _WideEntry

One vertical model-column stripe under stripes/<name>.

WideDatasetFileEntry

Bases: _WideEntry

One Parquet part of variants/ or stripes/<name>/.

WideDatasetExport dataclass

WideDatasetExport(
    destination_uri: str, manifest: WideDatasetManifest
)

What export_wide_parquet / render_wide_dataset wrote.

ColumnManifestEntry dataclass

ColumnManifestEntry(
    column: str,
    kind: ColumnKind,
    field: str,
    dtype: str | None,
    repeated: bool = False,
    label: str | None = None,
    source: str | None = None,
    model_id: str | None = None,
    model_name: str | None = None,
    plugin_id: str | None = None,
    plugin_version: str | None = None,
    result_schema_version: str | None = None,
    result_schema_hash: str | None = None,
)

One column of a wide export, as wide_column_manifest describes it.

  • column is the column's name in the file, and kind what it holds: variant_key (variant_id), prioritization (the variant's prioritized and its two reason lists, or one model's prioritized), display (a cross-model summary reducer column), annotation (a source's column), or score (a model's score field).
  • field is the name the value has outside the wide file: a score field's own name, such as log2fc, which models that share a result schema share; an annotation's column name; or the column's name otherwise.
  • dtype is the logical type, float, int, bool, str, json or struct, and repeated says the column is a list of it. A reducer column has its type when the layout knows it and None otherwise. A TSV holds a repeated, struct or json value as JSON text.
  • label is a score or annotation column's display label.
  • source names an annotation column's source.
  • The model fields are set on a model's columns: model_id (the model key), model_name, plugin_id, plugin_version, and the result_schema_version and result_schema_hash of the plugin's result schema.

to_dict

to_dict() -> dict[str, Any]

Return the entry as JSON-compatible values, keyed in COLUMN_MANIFEST_FIELDS order.

wide_layout

wide_layout(
    models: Sequence[ScoredModel],
    annotation_sources: Sequence[AnnotationSource],
    *,
    rider_columns: Sequence[str] = (),
    rider_dtypes: Sequence[ScalarDtype] = (),
    include_lineage_ids: bool = False,
) -> WideExportLayout

Build the wide-export layout for models and annotation_sources (see the module docstring).

rider_columns are cross-model reducer output columns, placed after prioritized, and rider_dtypes, when given, their scalar types in the same order. include_lineage_ids=True appends <column_prefix>_score_lineage_id at the end of each ModelExportBlock for row-level lineage attribution; default False omits per-cell lineage columns. Raises SchemaCollisionError when two sources declare one column, a score column collides with an annotation column, or any two export columns share a name.

plan_wide_stripes

plan_wide_stripes(
    layout: WideExportLayout,
    *,
    max_columns_per_stripe: int = DEFAULT_MAX_COLUMNS_PER_STRIPE,
) -> tuple[WideStripeSpec, ...]

Partition layout.model_blocks into <max_columns_per_stripe-column and <750 KB-SQL stripes.

wide_column_manifest

wide_column_manifest(
    layout: WideExportLayout,
) -> list[ColumnManifestEntry]

Describe every column of layout, one entry per column in layout.columns order.

It reads only the layout, so it describes any file with these columns: the portable writers' TSV and Parquet files and an altar run export, whose display rider columns are entries of kind display.

column_manifest_tsv

column_manifest_tsv(
    entries: Iterable[ColumnManifestEntry],
) -> str

Render manifest entries as the text of _columns.tsv.

A header row of COLUMN_MANIFEST_FIELDS, then one tab-separated row per entry, quoted as the wide TSV quotes its cells. An unset field is empty, and repeated is true or false.

write_column_manifest async

write_column_manifest(
    layout: WideExportLayout,
    destination_uri: str,
    *,
    storage: Storage,
) -> str

Write the column manifest of layout as <destination_uri>/_columns.tsv and return its URI.

Its leading underscore keeps a part-* glob, and a dataset reader that opens the whole directory, from taking it for a data file.

write_models_manifest async

write_models_manifest(
    layout: WideExportLayout,
    destination_uri: str,
    *,
    storage: Storage,
    accepted_lineage_ids: Mapping[str, Sequence[str]]
    | None = None,
    observed_lineage_counts: Mapping[str, Mapping[str, int]]
    | None = None,
) -> str

Write per-model lineage provenance (<destination_uri>/_models.json, provisional) and return its URI.

read_wide_dataset_manifest async

read_wide_dataset_manifest(
    destination_uri: str, *, storage: Storage
) -> WideDatasetExport

Read the altar-wide/1 manifest at destination_uri through storage.

write_wide_tsv_header

write_wide_tsv_header(
    layout: WideExportLayout, sink: BinaryIO
) -> None

Write the wide TSV's header row, layout.columns, to sink as one gzip member.

It is the first member of render_wide_tsv's output; write_wide_tsv_member writes each bucket's after it.

write_wide_tsv_member

write_wide_tsv_member(
    bucket: ResultBucket,
    layout: WideExportLayout,
    sink: BinaryIO,
    *,
    prioritized_only: bool = False,
) -> None

Write one bucket's wide TSV rows to sink as one gzip member, in genomic order.

The rows and cells are those render_wide_tsv writes, which is this function called for each bucket in order after write_wide_tsv_header. prioritized_only keeps only the prioritized variants; a bucket with none still writes an (empty) member. It runs synchronously, so call it off the event loop when sink can block.

write_prioritized_ndjson_member

write_prioritized_ndjson_member(
    bucket: ResultBucket,
    layout: WideExportLayout,
    sink: BinaryIO,
    *,
    int64_as_string: bool = True,
    include_lineage_ids: bool = False,
) -> None

Write one bucket's prioritized variants to sink as NDJSON in one gzip member, in genomic order.

The records are those render_prioritized_ndjson writes, which is this function called for each bucket in order. A bucket with no prioritized variant still writes an (empty) member. It runs synchronously, so call it off the event loop when sink can block.

export_col_alias

export_col_alias(
    model_id: str, model_name: str, col: str
) -> str

Build the wide-export column name of one model field: the model's prefix plus the field's name.

The score-column suffix is preserved for consumers that group columns by score type.

export_column_prefix

export_column_prefix(model_id: str, model_name: str) -> str

Build a model's stable, collision-resistant column prefix for the wide exports (see model_column_prefix).

model_column_prefix

model_column_prefix(model_id: str, model_name: str) -> str

Build a model's stable, collision-resistant column prefix for wide exports and VCF manifests.

The readable token comes from model_name; a 12-hex SHA-256 digest of the stable model_id distinguishes duplicate display names and names that sanitize to the same token.


Unified long datasets (altar-long/1) API

Result export: unified long datasets, striped wide datasets, result buckets, and writers.

Hosts and scripts that export stored results import these names from :mod:altar.export, the supported import path. The modules under altar.plugins that define them are not public API. The stores an export reads from, and their lineage and reuse rules, are in :mod:altar.results.

The wide layout is stable: wide_layout computes it as a WideExportLayout of ModelExportBlock values, and export_column_prefix (provisional alias model_column_prefix) computes each model's <name>__<hash12> column prefix. Per-cell score_lineage_id columns are omitted from wide layouts by default (opt-in via include_lineage_ids=True); lineage IDs and observed counts are recorded per model in export manifests (MODELS_MANIFEST_FILE, write_models_manifest, WideDatasetModelEntry) and models/ tables.

Typed cross-model summary reducers (CrossModelReducer, TopModel, MaxAbs, CountWhere, provisional) declare variant-level summary columns compiled into single-pass warehouse SQL and evaluated in pure Python on portable stores.

The result-bucket export is stable too. A store hands its export over as result buckets (ResultBuckets, ResultBucket, ResultBucketDescriptor, PrioritizedCounts, RESULT_BUCKET_SCHEMA_VERSION, result_bucket_schema, genomic_sort_key, and bucket_export_layout, bucket_rows_for and plan_buckets, with which a store that produces its own buckets cuts them). BucketReader and BucketLoader are how ResultBuckets reads its buckets. The writers render them into any storage (render_wide_tsv, render_wide_parquet, render_prioritized_ndjson), recording provenance through a ProvenanceCallback; the per-bucket member writers they loop over feed several outputs from one pass (write_wide_tsv_header, write_wide_tsv_member, write_prioritized_ndjson_member). DOWNLOAD_PART and PRIORITIZED_PART are the file names of the first wide and prioritized export parts. An export refuses to repeat a variant (ExportDuplicateRowsError), and BigQuery's cost guard refuses a scan over its limit (ExportScanLimitExceeded). The wide export's column manifest (wide_column_manifest, ColumnManifestEntry, ColumnKind, column_manifest_tsv, write_column_manifest, COLUMN_MANIFEST_FILE) and its <name>__<hash12>_<field> column rule (export_col_alias) are stable, and so are the augmented VCF's occurrence buckets v2 (render_augmentation_buckets, augmentation_bucket_schema, AUGMENTATION_BUCKET_SCHEMA_VERSION) and ExportStaging.

The unified partitioned long dataset (altar-long/1: export_long_dataset, LONG_DATASET_FORMAT, LongDatasetManifest and its entries, read_long_dataset_manifest, long_dataset_schema, long_variants_schema, long_dataset_manifest_json_schema, plus ExportsLongScores and the LONG_SCORES_* aliases), the column-striped partitioned wide Parquet dataset (altar-wide/1: export_wide_parquet, render_wide_dataset, open_wide_dataset, plan_wide_stripes, WideDatasetManifest and its entries, read_wide_dataset_manifest), warehouse cluster-pruning helpers (ChromosomeBounds, VariantBridge), and low-level bucket SQL helpers (estimated_variant_bytes, ResultBucketSql, build_result_bucket_sql, predicate_groups), and value-level export comparators (compare_wide_tsvs, WideTsvComparison, CellDifference, compare_prioritized_ndjson, NdjsonComparison, FieldDifference, cells_equal, values_equal) are provisional and listed in __provisional__.

LongScoresManifest module-attribute

LongScoresManifest = LongDatasetManifest

LongScoresScope module-attribute

LongScoresScope = LongDatasetScope

LongScoresModelEntry module-attribute

LongScoresModelEntry = LongDatasetModelEntry

LongScoresTableEntry module-attribute

LongScoresTableEntry = LongDatasetTableEntry

LongScoresColumnEntry module-attribute

LongScoresColumnEntry = LongDatasetColumnEntry

LongScoresFieldEntry module-attribute

LongScoresFieldEntry = LongDatasetFieldEntry

LongScoresFileEntry module-attribute

LongScoresFileEntry = LongDatasetFileEntry

LongScoresExport module-attribute

LongScoresExport = LongDatasetExport

long_scores_manifest_json_schema module-attribute

long_scores_manifest_json_schema = (
    long_dataset_manifest_json_schema
)

read_long_scores_manifest module-attribute

read_long_scores_manifest = read_long_dataset_manifest

LONG_DATASET_FORMAT module-attribute

LONG_DATASET_FORMAT: Final = 'altar-long/1'

The canonical format identifier recorded in _manifest.json.

LONG_DATASET_MANIFEST module-attribute

LONG_DATASET_MANIFEST = '_manifest.json'

The manifest file name under the dataset destination, written last as the atomic completion marker.

LONG_DATASET_METADATA_KEY module-attribute

LONG_DATASET_METADATA_KEY = 'altar.long'

The Parquet key-value metadata key describing a local writer's score or variant file.

LONG_SCORES_FORMAT module-attribute

LONG_SCORES_FORMAT: Final = LONG_DATASET_FORMAT

LONG_SCORES_MANIFEST module-attribute

LONG_SCORES_MANIFEST = LONG_DATASET_MANIFEST

LONG_SCORES_METADATA_KEY module-attribute

LONG_SCORES_METADATA_KEY = LONG_DATASET_METADATA_KEY

StoreMapping

StoreMapping = (
    ScoreStore
    | Sequence[ScoreStore]
    | Mapping[str, ScoreStore]
)

LongDatasetManifest

Bases: _Entry

The manifest of a unified long dataset, altar-long/1, at <destination>/_manifest.json.

to_json

to_json() -> str

Return the manifest as indented JSON, as the export writes it.

LongDatasetScope

Bases: _Entry

Which variants the dataset covers: every stored one, a listed set, or a relation in the store.

LongDatasetModelEntry

Bases: _Entry

One model of the dataset, including its column_prefix, identity, and accepted lineages.

LongDatasetAnnotationSourceEntry

Bases: _Entry

One annotation source included in variants/ when has_variants=True.

LongDatasetTableEntry

Bases: _Entry

One score table: its directory, the plugin and result schema version its models share, and its columns.

LongDatasetColumnEntry

Bases: _Entry

One column of a Parquet table in the dataset: its name and its Arrow type.

LongDatasetFieldEntry

Bases: _Entry

One score column a model declares: its name, its type, and what it means.

LongDatasetFileEntry

Bases: _Entry

One Parquet file of the dataset: its relative path, table, partition, size, rows, and checksums.

LongDatasetExport dataclass

LongDatasetExport(
    destination_uri: str, manifest: LongDatasetManifest
)

What export_long_dataset / export_long_scores wrote: its destination and its manifest.

manifest_uri property

manifest_uri: str

The manifest's URI, <destination_uri>/_manifest.json.

uri

uri(path: str) -> str

Return the URI of one of the manifest's relative paths.

LongScoreTable dataclass

LongScoreTable(
    name: str,
    plugin_id: str,
    result_schema_version: str,
    model_ids: tuple[str, ...],
    fields: tuple[ExportField, ...],
)

One score table of the long export: the models whose plugin and result schema version it holds (provisional).

name is the table's directory under scores/. fields are its score columns, each named by its own field name, in the order the models declare them; a field one model of the table lacks is NULL in that model's rows.

path property

path: str

The table's directory, relative to the export: scores/<name>.

long_score_tables

long_score_tables(
    layout: WideExportLayout,
) -> tuple[LongScoreTable, ...]

Group the layout's models into score tables by plugin ID and result schema version (provisional).

Tables come in the order of their first model, and each lists its models in layout order. Raises SchemaCollisionError when a score field is named variant_id, model_id, score_lineage_id or prioritized, the key columns of every score table.

long_dataset_schema

long_dataset_schema(
    table: LongScoreTable,
    *,
    include_prioritized: bool = False,
) -> Schema

Return the Arrow schema of one score table's files (scores/<schema_family>/chromosome=<chr>/part-*.parquet).

When include_prioritized=False (pure score-atlas mode), omits prioritized. When include_prioritized=True (include_variants=True), includes prioritized: bool evaluated per (variant, model).

long_variants_schema

long_variants_schema(layout: WideExportLayout) -> Schema

Return the Arrow schema of variants/chromosome=<chr>/part-*.parquet when include_variants=True.

long_scores_schema

long_scores_schema(table: LongScoreTable) -> Schema

Return the Arrow schema of one score-only table's files (include_prioritized=False).

long_dataset_manifest_json_schema

long_dataset_manifest_json_schema() -> dict[str, Any]

Return the published JSON Schema of a long dataset manifest, altar-long/1.

read_long_dataset_manifest async

read_long_dataset_manifest(
    destination_uri: str, *, storage: Storage
) -> LongDatasetExport

Read the altar-long/1 manifest at destination_uri; refuses manifests of any other format.


Result & augmentation buckets API

Result export: unified long datasets, striped wide datasets, result buckets, and writers.

Hosts and scripts that export stored results import these names from :mod:altar.export, the supported import path. The modules under altar.plugins that define them are not public API. The stores an export reads from, and their lineage and reuse rules, are in :mod:altar.results.

The wide layout is stable: wide_layout computes it as a WideExportLayout of ModelExportBlock values, and export_column_prefix (provisional alias model_column_prefix) computes each model's <name>__<hash12> column prefix. Per-cell score_lineage_id columns are omitted from wide layouts by default (opt-in via include_lineage_ids=True); lineage IDs and observed counts are recorded per model in export manifests (MODELS_MANIFEST_FILE, write_models_manifest, WideDatasetModelEntry) and models/ tables.

Typed cross-model summary reducers (CrossModelReducer, TopModel, MaxAbs, CountWhere, provisional) declare variant-level summary columns compiled into single-pass warehouse SQL and evaluated in pure Python on portable stores.

The result-bucket export is stable too. A store hands its export over as result buckets (ResultBuckets, ResultBucket, ResultBucketDescriptor, PrioritizedCounts, RESULT_BUCKET_SCHEMA_VERSION, result_bucket_schema, genomic_sort_key, and bucket_export_layout, bucket_rows_for and plan_buckets, with which a store that produces its own buckets cuts them). BucketReader and BucketLoader are how ResultBuckets reads its buckets. The writers render them into any storage (render_wide_tsv, render_wide_parquet, render_prioritized_ndjson), recording provenance through a ProvenanceCallback; the per-bucket member writers they loop over feed several outputs from one pass (write_wide_tsv_header, write_wide_tsv_member, write_prioritized_ndjson_member). DOWNLOAD_PART and PRIORITIZED_PART are the file names of the first wide and prioritized export parts. An export refuses to repeat a variant (ExportDuplicateRowsError), and BigQuery's cost guard refuses a scan over its limit (ExportScanLimitExceeded). The wide export's column manifest (wide_column_manifest, ColumnManifestEntry, ColumnKind, column_manifest_tsv, write_column_manifest, COLUMN_MANIFEST_FILE) and its <name>__<hash12>_<field> column rule (export_col_alias) are stable, and so are the augmented VCF's occurrence buckets v2 (render_augmentation_buckets, augmentation_bucket_schema, AUGMENTATION_BUCKET_SCHEMA_VERSION) and ExportStaging.

The unified partitioned long dataset (altar-long/1: export_long_dataset, LONG_DATASET_FORMAT, LongDatasetManifest and its entries, read_long_dataset_manifest, long_dataset_schema, long_variants_schema, long_dataset_manifest_json_schema, plus ExportsLongScores and the LONG_SCORES_* aliases), the column-striped partitioned wide Parquet dataset (altar-wide/1: export_wide_parquet, render_wide_dataset, open_wide_dataset, plan_wide_stripes, WideDatasetManifest and its entries, read_wide_dataset_manifest), warehouse cluster-pruning helpers (ChromosomeBounds, VariantBridge), and low-level bucket SQL helpers (estimated_variant_bytes, ResultBucketSql, build_result_bucket_sql, predicate_groups), and value-level export comparators (compare_wide_tsvs, WideTsvComparison, CellDifference, compare_prioritized_ndjson, NdjsonComparison, FieldDifference, cells_equal, values_equal) are provisional and listed in __provisional__.

RESULT_BUCKET_SCHEMA_VERSION module-attribute

RESULT_BUCKET_SCHEMA_VERSION = 1

The version of the result-bucket schema this module defines; bumped by any change to its columns.

AUGMENTATION_BUCKET_SCHEMA_VERSION module-attribute

AUGMENTATION_BUCKET_SCHEMA_VERSION = (
    "altar-augmentation-buckets-v2"
)

The version of the occurrence-bucket format this module defines; the augmented-VCF manifest records it.

BucketLoader

BucketLoader = Callable[
    [ResultBucketDescriptor], Awaitable["pa.Table"]
]

Reads one bucket's rows; a producer passes it to ResultBuckets.

BucketReader

BucketReader = Callable[
    [], AbstractAsyncContextManager[BucketLoader]
]

Opens a loader for one iteration of ResultBuckets, with state of its own, and closes it when the iteration ends.

ProvenanceCallback

ProvenanceCallback = Callable[
    [], Awaitable[Mapping[str, Any]]
]

Returns the provenance of the rows a wide writer wrote; the writer calls it once, after the last row.

ResultBuckets

ResultBuckets(
    layout: WideExportLayout,
    descriptors: Sequence[ResultBucketDescriptor],
    load: BucketLoader | None = None,
    *,
    models: Sequence[ScoredModel] = (),
    reader: BucketReader | None = None,
    accepted_lineage_ids: Mapping[str, Sequence[str]]
    | None = None,
)

The buckets of one export, as a store produces them.

layout is the export's wide layout (with the rider's columns and types), schema the bucket schema, and descriptors the buckets in genomic order. Iterating yields each ResultBucket in that order, reading one at a time through the producer's loader, which a later iteration calls again; a writer that drops each bucket before asking for the next holds one bucket. Each table is cast to schema, an empty repeated annotation is turned into null, a table that repeats a variant_ordinal raises ExportDuplicateRowsError, and one whose row count or ordinals do not match its descriptor raises ValueError. models are the export's models, in order.

A producer passes load, a loader every iteration shares, or reader, which opens a loader of its own for each iteration and closes it when the iteration ends: a producer whose reading keeps state, such as the local copies of staged files, uses it so that several writers can iterate the same buckets at once.

prioritized() opens a view that holds only the prioritized variants, and prioritized_counts() counts them. Here they read each bucket through the loader and filter it; a store that can filter and count in its own query returns a subclass that does (BigQueryScoreStore). resumed says whether the store adopted an export that an earlier, failed attempt had built, instead of reading the export's inputs again.

resumed class-attribute instance-attribute

resumed: bool = False

Whether the store adopted what an earlier, failed attempt built (BigQueryScoreStore.result_buckets' resume_key) rather than reading the annotation sources again. A store that does not resume always says False.

row_count property

row_count: int

The number of variants in the export, across every bucket; in a prioritized view, its prioritized ones.

prioritized

prioritized() -> AbstractAsyncContextManager[ResultBuckets]

Open a view of the export's prioritized variants: async with buckets.prioritized() as view.

The view has this export's layout, models and buckets, by the same index and ordinal bounds, and each of its buckets holds only this bucket's rows whose prioritized is true, whole: every model's model_scores entry, prioritizing or not, every annotation and reason column, and the rider, which the store computed over all of the variant's models. A bucket with no prioritized variant is empty. A descriptor's row_count is its bucket's prioritized variants, so view.row_count is the export's. Every writer therefore writes over the view the bytes it writes over this export with prioritized_only=True (the NDJSON is prioritized only anyway), while reading only the prioritized rows. A view checks its buckets as the export does: a repeated variant raises ExportDuplicateRowsError.

This implementation reads every bucket once to count its prioritized variants, then reads each through this export's loader and filters it; a store that can filter in its own query reads only those rows (BigQueryScoreStore). Open it inside the export's own block; the view releases what it created when its block exits.

prioritized_counts async

prioritized_counts() -> PrioritizedCounts

Count the export's prioritized variants and their model entries, without rendering.

A host decides with it whether a prioritized output is worth rendering before it renders anything. The counts are the prioritized view's (prioritized): its rows, and the model_scores entries they hold. This implementation reads each bucket once and keeps the counts, so a later view needs no count of its own; a store that can count in its own query does so (BigQueryScoreStore reads two narrow columns of its canonical table).

ResultBucket dataclass

ResultBucket(
    descriptor: ResultBucketDescriptor, table: Table
)

One bucket's rows: a table with result_bucket_schema, its rows in no particular order.

sorted_table

sorted_table() -> Table

Return the bucket's rows sorted by variant_ordinal, the order every writer renders them in.

The sort runs once per bucket and is kept with it, so several writers fed the same bucket share it.

ResultBucketDescriptor dataclass

ResultBucketDescriptor(
    index: int,
    first_ordinal: int,
    last_ordinal: int,
    row_count: int,
    sort_key: tuple[str, ...] = (VARIANT_ORDINAL,),
    schema_version: int = RESULT_BUCKET_SCHEMA_VERSION,
)

One bucket of an export: its number, the ordinals it covers, and its row count.

first_ordinal and last_ordinal are inclusive, and row_count is last_ordinal - first_ordinal + 1: every variant of the export has exactly one row. In a prioritized view (ResultBuckets.prioritized) the bounds and index are the whole export's bucket's, and row_count is how many of its variants are prioritized. sort_key names the column a writer sorts the bucket's rows by.

ResultBucketSql dataclass

ResultBucketSql(
    annotations: str,
    canonical: str,
    selection_rows: tuple[dict[str, object], ...] | None,
    parameters: dict[str, list[str]],
    annotation_statements: tuple[
        tuple[str, dict[str, list[str]]], ...
    ],
)

The SQL BigQueryScoreStore.result_buckets runs for one export, rendered without a client (provisional).

annotations is the SELECT whose rows the store inserts into its annotations table: one row per variant of the job, each source collapsed to one row per variant, plus each prioritizing source's src_prioritized__<name> flag. canonical is the SELECT the store builds its canonical table from (CREATE TABLE … AS); it reads the score table, the selection table and the annotations table, and holds each distinct model predicate once, in a CASE on the model's predicate group when the models have more than one. selection_rows are the rows the store loads into the selection table: one per model and accepted lineage, with the model's position and its index into predicate_groups(models). They are None when the call names no lineages: the canonical query joins scores on their lineage, so rows without one would select no scores. parameters are the query parameters both queries read, model_ids and genomes; with no variants_relation, both also read @variant_ids, the job's variant ids.

annotation_statements are the SELECTs the store inserts into its annotations table, in order, each with the ARRAY<STRING> parameters it binds besides parameters. It is ((annotations, {}),) unless the job's variant ids were given and a source declares a chromosome column: then each source that does reads only the storage blocks of the job's chromosomes and variants (chromosome_variant_filter), its ids bound by chromosome in sorted lists of at most 2,000, @chromosome_ids_0, @chromosome_ids_1, …. A job whose lists would bind more than about 4 MB in one statement is split by chromosome into several statements, each restricted to its own variants; annotations is the first.

ExportStaging dataclass

ExportStaging(uri: str, storage: Storage)

Where BigQueryScoreStore stages an export's Parquet shards, and how it reads them back.

uri is a gs:// prefix (BigQuery's EXPORT DATA writes only to GCS) and storage a Storage that reads and deletes objects under it, such as an FsspecStorage. It is a store setting, separate from the Storage the export's files are written to, which can be anything.

VariantBridge dataclass

VariantBridge(
    relation: str,
    target_id_column: str = "target_variant_id",
    source_id_column: str = "variant_id",
    where: str | None = None,
)

Mapping relation that re-keys an annotation source from a target coordinate space to the job's variant_ids.

Used when a study's variants are keyed on one assembly (for example hg19) and a reference annotation table is keyed on another (for example hg38) via a liftover mapping table in the warehouse. When attached to a BigQueryAnnotationSource (bridge=), warehouse exports compute per-chromosome ChromosomeBounds over target_id_column for the job's variants so the target reference table is cluster-pruned too.

ChromosomeBounds dataclass

ChromosomeBounds(
    chromosome: str,
    min_variant_id: str,
    max_variant_id: str,
    min_pos: int | None = None,
    max_pos: int | None = None,
)

Per-chromosome inclusive variant_id (and optional pos) range for pruning 1M-70M variant tables.

Above BigQuery's inline parameter limit (_PRUNED_VARIANTS_LIMIT), binding millions of IDs in UNNEST(@param) is impossible and a bare variant_id IN (SELECT variant_id FROM <relation>) semi-join skips no storage blocks. Instead, a single metadata query computes per-chromosome (min_variant_id, max_variant_id, min_pos, max_pos) bounds from <relation> (or from a VariantBridge's target_id_column), and the source injects constant <chr_col> IN (...) AND variant_id BETWEEN '<min>' AND '<max>' conjuncts ahead of the semi-join so BigQuery skips unreferenced chromosome and range blocks on multi-terabyte reference tables.

bucket_export_layout

bucket_export_layout(
    models: Sequence[ScoredModel],
    annotation_sources: Sequence[AnnotationSource],
    *,
    reducers: Sequence[CrossModelReducer] = (),
    rider: DisplayRider | None = None,
    include_lineage_ids: bool = False,
) -> WideExportLayout

Build the wide layout of a result-bucket export: wide_layout with typed cross-model reducer columns.

Pass only the sources that apply to the models (applicable_annotation_sources).

plan_buckets

plan_buckets(
    row_count: int, bucket_rows: int
) -> tuple[ResultBucketDescriptor, ...]

Cut row_count ordinals into consecutive buckets of bucket_rows, the last one possibly shorter.

bucket_rows_for

bucket_rows_for(
    layout: WideExportLayout,
    *,
    bucket_rows: int | None = None,
    bucket_bytes: int | None = None,
) -> int

Return the variants per bucket: bucket_rows, or bucket_bytes (default 128 MiB) over the estimate.

build_result_bucket_sql

build_result_bucket_sql(
    table_id: str,
    models: Sequence[ScoredModel],
    annotation_sources: Sequence[AnnotationSource],
    *,
    reducers: CrossModelReducer
    | Sequence[CrossModelReducer]
    | None = None,
    rider: DisplayRider | None = None,
    variants_relation: str | None = None,
    lineages: Sequence[Sequence[str | None]] | None = None,
    selection_relation: str | None = None,
    annotations_relation: str | None = None,
    variant_ids: Sequence[str] | None = None,
    keep_all_sources: bool = False,
) -> ResultBucketSql

Render the SQL BigQueryScoreStore(…, table_id).result_buckets runs for these arguments (provisional).

predicate_groups

predicate_groups(
    models: Sequence[ScoredModel],
    unavailable_columns: Collection[str] = (),
) -> tuple[list[str], list[int]]

Return each distinct model predicate's SQL, in first-seen order, and each model's index into that list.

result_bucket_schema

result_bucket_schema(layout: WideExportLayout) -> Schema

Return the Arrow schema of a result bucket for layout (see the module docstring).

augmentation_bucket_schema

augmentation_bucket_schema(
    occurrence_schema: Schema,
    layout: WideExportLayout,
    *,
    include_model_scores: bool | Sequence[str] = False,
) -> Schema

Return the Arrow schema of a v2 occurrence-bucket part for layout and include_model_scores.

When include_model_scores is False (default), model_scores is omitted and scalar max_abs_effect and top_model_id carry the headline summary. When True or a sequence of model_ids, model_scores is kept alongside max_abs_effect and top_model_id.

estimated_variant_bytes

estimated_variant_bytes(layout: WideExportLayout) -> int

Estimate one variant's size in a bucket, from the layout alone, as if every model scored it.

The estimate sizes buckets the same way on every store, so their boundaries, and so a gzipped export's bytes, agree by default. It counts about 9 bytes per score field and 80 for each entry's ids, 64 more for a lineage id, 32 per scalar annotation and 512 per nested one, and 64 per variant.

genomic_sort_key

genomic_sort_key(
    variant_id: str,
) -> tuple[int, bytes, int, bytes, bytes]

Return the key that orders canonical variant ids in genomic order.

The key is the chromosome's rank (chromosome_rank), its name, the position, then the reference and alternate alleles, names and alleles compared as bytes. Distinct canonical ids get distinct keys. Raises VariantIdentityError for a non-canonical id.


Parity comparison & exceptions API

Result export: unified long datasets, striped wide datasets, result buckets, and writers.

Hosts and scripts that export stored results import these names from :mod:altar.export, the supported import path. The modules under altar.plugins that define them are not public API. The stores an export reads from, and their lineage and reuse rules, are in :mod:altar.results.

The wide layout is stable: wide_layout computes it as a WideExportLayout of ModelExportBlock values, and export_column_prefix (provisional alias model_column_prefix) computes each model's <name>__<hash12> column prefix. Per-cell score_lineage_id columns are omitted from wide layouts by default (opt-in via include_lineage_ids=True); lineage IDs and observed counts are recorded per model in export manifests (MODELS_MANIFEST_FILE, write_models_manifest, WideDatasetModelEntry) and models/ tables.

Typed cross-model summary reducers (CrossModelReducer, TopModel, MaxAbs, CountWhere, provisional) declare variant-level summary columns compiled into single-pass warehouse SQL and evaluated in pure Python on portable stores.

The result-bucket export is stable too. A store hands its export over as result buckets (ResultBuckets, ResultBucket, ResultBucketDescriptor, PrioritizedCounts, RESULT_BUCKET_SCHEMA_VERSION, result_bucket_schema, genomic_sort_key, and bucket_export_layout, bucket_rows_for and plan_buckets, with which a store that produces its own buckets cuts them). BucketReader and BucketLoader are how ResultBuckets reads its buckets. The writers render them into any storage (render_wide_tsv, render_wide_parquet, render_prioritized_ndjson), recording provenance through a ProvenanceCallback; the per-bucket member writers they loop over feed several outputs from one pass (write_wide_tsv_header, write_wide_tsv_member, write_prioritized_ndjson_member). DOWNLOAD_PART and PRIORITIZED_PART are the file names of the first wide and prioritized export parts. An export refuses to repeat a variant (ExportDuplicateRowsError), and BigQuery's cost guard refuses a scan over its limit (ExportScanLimitExceeded). The wide export's column manifest (wide_column_manifest, ColumnManifestEntry, ColumnKind, column_manifest_tsv, write_column_manifest, COLUMN_MANIFEST_FILE) and its <name>__<hash12>_<field> column rule (export_col_alias) are stable, and so are the augmented VCF's occurrence buckets v2 (render_augmentation_buckets, augmentation_bucket_schema, AUGMENTATION_BUCKET_SCHEMA_VERSION) and ExportStaging.

The unified partitioned long dataset (altar-long/1: export_long_dataset, LONG_DATASET_FORMAT, LongDatasetManifest and its entries, read_long_dataset_manifest, long_dataset_schema, long_variants_schema, long_dataset_manifest_json_schema, plus ExportsLongScores and the LONG_SCORES_* aliases), the column-striped partitioned wide Parquet dataset (altar-wide/1: export_wide_parquet, render_wide_dataset, open_wide_dataset, plan_wide_stripes, WideDatasetManifest and its entries, read_wide_dataset_manifest), warehouse cluster-pruning helpers (ChromosomeBounds, VariantBridge), and low-level bucket SQL helpers (estimated_variant_bytes, ResultBucketSql, build_result_bucket_sql, predicate_groups), and value-level export comparators (compare_wide_tsvs, WideTsvComparison, CellDifference, compare_prioritized_ndjson, NdjsonComparison, FieldDifference, cells_equal, values_equal) are provisional and listed in __provisional__.

LongScoresExportUnsupported module-attribute

LongScoresExportUnsupported = LongDatasetExportUnsupported

WideTsvComparison dataclass

WideTsvComparison(
    same_header: bool,
    only_left: tuple[str, ...] = (),
    only_right: tuple[str, ...] = (),
    differences: tuple[CellDifference, ...] = (),
    allowed: tuple[CellDifference, ...] = (),
)

The result of compare_wide_tsvs.

same_header says the headers are identical (modulo <prefix>_score_lineage_id columns when ignore_lineage_ids=True). only_left and only_right are the variant_ids one file has and the other lacks. differences are the differing cells outside allowed_columns, and allowed the differing cells inside them. matches holds when the headers match, both files hold the same variants, and no cell outside the allowed columns differs.

NdjsonComparison dataclass

NdjsonComparison(
    only_left: tuple[str, ...] = (),
    only_right: tuple[str, ...] = (),
    differences: tuple[FieldDifference, ...] = (),
)

The result of compare_prioritized_ndjson (provisional).

only_left and only_right are the variants one side has and the other lacks, and differences every field whose values differ. matches holds when both sides hold the same variants with equal values.

CellDifference dataclass

CellDifference(
    variant_id: str, column: str, left: str, right: str
)

One cell that differs between two wide TSVs: its row's variant_id, its column, and both values.

FieldDifference dataclass

FieldDifference(
    variant_id: str, path: str, left: object, right: object
)

One field that differs between two prioritized NDJSON records (provisional).

path names it from the record's top: am_class, or model_scores[m1].logfc for a model's entry.

WideExportColumnLimitExceeded

WideExportColumnLimitExceeded(
    column_count: int, max_columns: int
)

Bases: AltarError, RuntimeError

A warehouse wide TSV export exceeds BigQuery's physical table column limit (10,000 columns).

Provisional (0.10.0). Raised by WarehouseExportSession.export_wide_tsv and BigQueryScoreStore.export_wide_tsv when len(layout.columns) > max_columns unless allow_bucket_fallback=True is explicitly passed, preventing a warehouse export call from silently falling back to a local in-process bucket render. Callers can switch to export_wide_parquet (altar-wide/1 column-striped Parquet), export_long_dataset (altar-long/1), or opt into streaming buckets explicitly (allow_bucket_fallback=True or store.result_buckets(...)).

ExportDuplicateRowsError

ExportDuplicateRowsError(
    row_count: int,
    variant_count: int,
    *,
    where: str = "the export's result table",
)

Bases: ValueError

An export holds more than one row for some variant, where its contract is one row per variant.

row_count rows hold variant_count distinct variants. BigQueryScoreStore checks its result table right after building it and raises this before any EXPORT DATA job or Read API session, so nothing has been written. ResultBuckets raises it for any store's bucket that repeats a variant, before a writer renders that bucket. The usual cause is an annotation source that returns several rows for one variant, such as a reference table loaded twice or a relation= that does not aggregate per variant. The stores collapse each source to one row per variant, so this means a store's query or a source broke that rule.

ExportScanLimitExceeded

ExportScanLimitExceeded(
    estimated_bytes: int, maximum_bytes_billed: int
)

Bases: RuntimeError

A store refused an export whose estimated scan exceeds the configured maximum_bytes_billed.

Raised before any export job runs, so nothing is billed. estimated_bytes is the store's estimate (for BigQuery a dry run, an upper bound on a clustered table) and maximum_bytes_billed the configured limit. A host catches it to record the export as unavailable rather than fail the job.

LongDatasetExportUnsupported

Bases: CapabilityNotSupported

A store cannot export this long dataset request, for the reason in the message.

compare_wide_tsvs

compare_wide_tsvs(
    left: WideTsv,
    right: WideTsv,
    *,
    allowed_columns: Iterable[str] = (),
    nan_equals_empty: bool = False,
    semantic: bool = False,
    ignore_lineage_ids: bool = False,
) -> WideTsvComparison

Compare two gzipped wide TSVs as sets of rows keyed by variant_id, cell by cell (provisional).

Each file is the bytes of a gzipped TSV or a local path to one. Row order is ignored. Every differing cell is listed, under allowed when its column is in allowed_columns (a display rider's columns, whose ties and NULL decisions may be broken differently by another export path) and under differences otherwise. Cells of a row only one file has are not compared. A variant_id that appears twice in one file raises ValueError. nan_equals_empty counts a NaN cell (NaN or nan) and an empty one as equal, for comparing with a file written by an exporter that wrote NaN as an empty cell. Altar's TSV writes NaN, and BigQuery's CSV export nan; semantic=True counts those two as equal.

When ignore_lineage_ids=True, <prefix>_score_lineage_id columns are stripped from whichever side carries them before comparing headers and cells, so a lineage-bearing export compares cleanly against a lineage-free 0.10+ export (or across equivalent lineages).

Both files are read as streams: the left file's rows are spilled to a scratch SQLite database keyed by variant_id, and each right row is looked up there, so memory holds a row at a time (and the differences found), whatever the files' size, such as a download of 10,000 columns by 50,000 variants.

compare_prioritized_ndjson

compare_prioritized_ndjson(
    left: Ndjson,
    right: Ndjson,
    *,
    ignore_lineage_ids: bool = False,
) -> NdjsonComparison

Compare two prioritized NDJSON exports record by record, by value (provisional).

Each side is gzipped NDJSON, as bytes or a local path, or a sequence of parts. Records are keyed by variant_id, and each record's model_scores entries by model_id, so order never matters. Values compare as values_equal compares them: an omitted key equals null (BigQuery's JSON export omits a null field, Altar writes it), numbers compare by float64 value, an INT64 written as a JSON string equals the number, and "NaN", "Infinity" and "-Infinity" equal the floats. When ignore_lineage_ids=True, "score_lineage_id" keys inside model_scores entries are ignored on whichever side carries them. Every differing field is reported. A variant_id that appears twice on one side raises ValueError.

The left records are spilled to a scratch SQLite database keyed by variant_id and each right record is looked up there, so memory holds a record at a time (and the differences found).

cells_equal

cells_equal(left: str, right: str) -> bool

Return whether two TSV cells hold the same value, across Altar's and BigQuery's encodings (provisional).

Equal text is equal. A number compares by its float64 value, and the non-finite words of either exporter match. A cell of JSON text (an array or object) compares by its parsed value (values_equal). Any other cell compares as text.

values_equal

values_equal(left: object, right: object) -> bool

Return whether two decoded values are equal by value, across Altar's and BigQuery's encodings (provisional).

Numbers compare by float64 value, a number's text equals the number (an INT64 written as a JSON string), and "NaN", "Infinity" and "-Infinity" (or nan, inf, -inf) equal the corresponding floats. Mappings compare key by key, a missing key counting as null; lists compare item by item, in order. Anything else compares equal only when it is equal.