"""Stable Python API for independent cell-curator workflows.
The functions import their implementation lazily so applications can inspect the
package version and configuration models without importing the scientific stack.
"""
from __future__ import annotations
from collections.abc import Callable, Iterable, Mapping, Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any
from .config import CellCuratorConfig, ProviderConfig, RepresentationConfig
from .contracts import ContractError
from .models import Agreement, RiskCoveragePoint
[docs]
def load_annotation_corpus(path: str | Path, *, expected_sha256: str = "") -> Any:
"""Load and validate a pinned multi-source label corpus."""
from .corpus import load_corpus
return load_corpus(path, expected_sha256=expected_sha256)
[docs]
def export_corpus_programs(path: str | Path, *, context: Mapping[str, str] | None = None,
measurements: Sequence[str] | None = None, ontology: Any = None) -> Any:
"""Export reviewed, context-matched corpus definitions as signed programs."""
return load_annotation_corpus(path).programs(context, measurements=measurements, ontology=ontology)
[docs]
def import_annotation_corpus(base_path: str | Path, input_path: str | Path,
output_path: str | Path, **kwargs: Any) -> dict[str, Any]:
"""Import bounded normalized source records without approving their labels."""
from .corpus_import import import_corpus_records
return import_corpus_records(base_path, input_path, output_path, **kwargs)
[docs]
def propose_corpus_update(base_path: str | Path, proposal_path: str | Path, **kwargs: Any) -> Any:
"""Record a proposed corpus change without changing the active snapshot."""
from .corpus import propose_corpus
return propose_corpus(base_path, proposal_path, **kwargs)
[docs]
def review_corpus_update(base_path: str | Path, proposal_path: str | Path,
output_path: str | Path, **kwargs: Any) -> dict[str, Any]:
"""Record a review and publish a new immutable corpus revision."""
from .corpus import review_corpus
return review_corpus(base_path, proposal_path, output_path, **kwargs)
[docs]
def check_corpus_isolation(path: str | Path, donor_split: str | Path, *, test_split: str,
dataset_id: str = "") -> dict[str, Any]:
"""Refuse a corpus whose records were learned from the test split's donors."""
from .corpus import check_test_isolation
return check_test_isolation(load_annotation_corpus(path), donor_split,
test_split=test_split, dataset_id=dataset_id)
[docs]
def compare_annotation_corpora(before_path: str | Path, after_path: str | Path) -> dict[str, Any]:
"""Compare label definitions, source records, and mappings between revisions."""
before, after = load_annotation_corpus(before_path), load_annotation_corpus(after_path)
old = {item.label_id: item.model_dump(mode="json") for item in before.labels}
new = {item.label_id: item.model_dump(mode="json") for item in after.labels}
return {"before": before.revision, "after": after.revision,
"added": sorted(new.keys() - old.keys()), "removed": sorted(old.keys() - new.keys()),
"changed": sorted(key for key in old.keys() & new.keys() if old[key] != new[key]),
"sources_changed": before.sources != after.sources, "mappings_changed": before.mappings != after.mappings}
[docs]
def run_annotation_classifier(config_path: str | Path, name: str) -> dict[str, Any]:
"""Run one configured local classifier as an immutable evidence stage."""
from .annotation import run_classifier
return run_classifier(config_path, name)
[docs]
def collect_annotation_level(config_path: str | Path, level: str) -> dict[str, Any]:
"""Collect parent-scoped markers, classifier corroboration, and state evidence."""
from .annotation import collect_level
return collect_level(config_path, level)
[docs]
def import_consensus_annotation_level(config_path: str | Path, level: str) -> dict[str, Any]:
"""Write one level's decisions from the configured annotation-consensus run."""
from .consensus_import import import_consensus_level
return import_consensus_level(config_path, level)
[docs]
def finalize_corpus_annotation(config_path: str | Path) -> dict[str, Any]:
"""Validate hierarchy nesting and publish cell labels and the evidence report."""
from .annotation import finalize_annotation
return finalize_annotation(config_path)
[docs]
def predict_popv(input_path: str | Path, reference_path: str | Path, **kwargs: Any) -> Any:
"""Run a local pretrained CPU popV subset with full method provenance."""
from .crosschecks import predict_popv_file
return predict_popv_file(input_path=input_path, reference_path=reference_path, **kwargs)
if TYPE_CHECKING:
from .ontology import CellOntology
[docs]
def detect_compute_environment(
config_path: str | Path | None = None, *, validate_cuda: bool = True
) -> Any:
"""Detect CPU, RAM, Apple Silicon, CUDA, and scheduler state without mutation.
Set ``validate_cuda=False`` to skip the CUDA probe, matching the CLI's
``--no-cuda-validation``.
"""
from .environment import detect_environment
cpu: dict[str, Any] = {}
gpu: dict[str, Any] = {}
if config_path is not None:
from .config import load_config
config = load_config(config_path)
cpu, gpu = config.hpc.cpu_resources, config.hpc.gpu_resources
return detect_environment(
configured_cpu_resources=cpu,
configured_gpu_resources=gpu,
validate_cuda=validate_cuda,
)
[docs]
def route_annotation_crosscheck(request: Any) -> Any:
"""Select one deterministic automated cross-check for a hierarchy scope."""
from .routing import RoutingRequest, route_crosscheck
model = (
request
if isinstance(request, RoutingRequest)
else RoutingRequest.model_validate(request)
)
return route_crosscheck(model)
[docs]
def prepare_annotation_scene(config_path: str | Path) -> dict[str, Any]:
"""Persist Stage 1 inspection, context, compute, assumptions, and progress."""
from .guided import prepare_scene
return prepare_scene(config_path)
[docs]
def plan_annotation(config_path: str | Path) -> dict[str, Any]:
"""Persist Stage 2 vocabulary, evidence routes, and unresolved assumptions."""
from .guided import construct_plan
return construct_plan(config_path)
[docs]
def approve_annotation_assumptions(
config_path: str | Path,
*,
reviewer: str,
scope: str = "*",
preauthorized: bool = False,
) -> dict[str, Any]:
"""Record interactive or declared non-interactive assumption approval."""
from .guided import approve_assumptions
return approve_assumptions(
config_path,
reviewer=reviewer,
scope=scope,
preauthorized=preauthorized,
)
[docs]
def annotation_progress(config_path: str | Path) -> dict[str, Any]:
"""Return current stage, scope, blockers, progress, and next action."""
from .guided import status
return status(config_path)
[docs]
def check_review_report(config_path: str | Path, *, level: str | None = None) -> dict[str, Any]:
"""Run strict read-only report validation after approval."""
from .config import load_config
from .pipeline import run_root
from .review import check_report_completeness
config = load_config(config_path)
return check_report_completeness(config, run_root(config), level=level)
[docs]
def initialize_run(config_path: str | Path) -> dict[str, Any]:
"""Initialize or resume an immutable annotation run."""
from .pipeline import initialize
return initialize(Path(config_path))
[docs]
def register_assay_representation(
config: CellCuratorConfig,
*,
assay: str,
name: str,
representation: RepresentationConfig | dict[str, Any],
) -> CellCuratorConfig:
"""Return a validated config copy with one newly registered assay representation."""
if assay not in config.input.assays:
raise ContractError(f"cannot register a representation for unknown assay: {assay}")
if not name.strip():
raise ContractError("representation name must not be blank")
declaration = (
representation
if isinstance(representation, RepresentationConfig)
else RepresentationConfig.model_validate(representation)
)
input_value = config.input.model_dump(mode="python")
representations = input_value["assays"][assay]["representations"]
if name in representations:
raise ContractError(f"assay representation is already registered: {assay}/{name}")
representations[name] = declaration.model_dump(mode="python")
return config.model_copy(
update={"input": config.input.__class__.model_validate(input_value)}
)
[docs]
def register_knowledge_provider(
config: CellCuratorConfig,
provider: ProviderConfig | dict[str, Any],
) -> CellCuratorConfig:
"""Return a validated config copy with one local or optional cached provider."""
declaration = (
provider
if isinstance(provider, ProviderConfig)
else ProviderConfig.model_validate(provider)
)
providers = list(config.knowledge.providers)
identity = (declaration.kind, declaration.path, declaration.version, declaration.url)
if identity in {(item.kind, item.path, item.version, item.url) for item in providers}:
raise ContractError("knowledge provider is already registered")
providers.append(declaration)
knowledge = config.knowledge.model_copy(update={"providers": providers})
return config.model_copy(update={"knowledge": knowledge})
[docs]
def validate_run(config_path: str | Path) -> dict[str, Any]:
"""Validate completeness, hashes, mapping conservation, and review state."""
from .pipeline import validate
return validate(Path(config_path))
[docs]
def preview_writeback(
config_path: str | Path,
ontology_path: str | Path | None = None,
*,
output_path: str | Path | None = None,
in_place: bool = False,
) -> dict[str, Any]:
"""Return a source-preserving write-back diff after computational checks."""
from .config import load_config
from .ontology import CellOntology, ontology_from_config
from .pipeline import run_root
from .writeback import validate_writeback
config = load_config(config_path)
ontology = (
CellOntology.load(Path(ontology_path))
if ontology_path is not None
else ontology_from_config(config)
)
return validate_writeback(
config,
run_root(config),
ontology=ontology,
output_path=Path(output_path) if output_path is not None else None,
in_place=in_place,
)
[docs]
def apply_writeback(
config_path: str | Path,
*,
output_path: str | Path,
confirm: Callable[[dict[str, Any]], str] | None = None,
ontology_path: str | Path | None = None,
in_place: bool = False,
) -> Path:
"""Apply an atomic write-back to a new object by default.
``confirm`` receives the preview and must return its ``approval_token``,
typed by a person. Without it, only a pre-authorized run writes.
"""
from .config import load_config
from .ontology import CellOntology, ontology_from_config
from .pipeline import run_root
from .writeback import write_back
config = load_config(config_path)
ontology = (
CellOntology.load(Path(ontology_path))
if ontology_path is not None
else ontology_from_config(config)
)
return write_back(
config,
run_root(config),
output_path=Path(output_path),
confirm=confirm,
ontology=ontology,
in_place=in_place,
)
[docs]
def annotate(config_path: str | Path) -> Path:
"""Run the configured pipeline; corpus runs execute the compiled Snakemake DAG."""
from .pipeline import run_annotation
return run_annotation(Path(config_path))
# --- configuration, capabilities, and environment -----------------------------
[docs]
def configuration_schema() -> dict[str, Any]:
"""Return the machine-readable schema for configuration version 3."""
from .config import configuration_schema as schema
return schema()
[docs]
def list_capabilities(config_path: str | Path) -> list[Any]:
"""Return the assay-aware capability registry a configuration resolves to."""
from .capabilities import build_capability_registry
from .config import load_config
return build_capability_registry(load_config(config_path))
# --- knowledge and ontology ---------------------------------------------------
[docs]
def validate_knowledge_providers(config_path: str | Path) -> dict[str, Any]:
"""Validate configured local knowledge providers and any configured ontology."""
from .config import load_config
from .knowledge import collect_programs, run_providers
from .ontology import ontology_from_config, validate_program_ontology
config = load_config(config_path)
programs = collect_programs(run_providers(config))
ontology = ontology_from_config(config)
if ontology is not None:
validate_program_ontology(programs, ontology)
return {
"status": "complete",
"external_service_required": False,
"n_programs": len(programs),
"labels": [item.label for item in programs],
"ontology_status": "validated" if ontology is not None else "unavailable",
"ontology_terms": len(ontology.terms) if ontology is not None else 0,
}
[docs]
def validate_ontology_terms(
ontology_path: str | Path,
terms: Sequence[str],
*,
expected_names: Sequence[str | None] | None = None,
) -> dict[str, Any]:
"""Validate ontology accessions against a local ontology file."""
from .ontology import validate_terms
return validate_terms(ontology_path, terms, expected_names=expected_names)
[docs]
def provision_ontology(config_path: str | Path) -> dict[str, Any]:
"""Report the configured ontology provider's provisioning status."""
from .config import load_config
from .ontology import provision_from_config
return provision_from_config(load_config(config_path))
# --- guided workflow ----------------------------------------------------------
[docs]
def confirm_annotation_context(
config_path: str | Path,
*,
input_path: str | Path,
reviewer: str,
) -> dict[str, Any]:
"""Confirm or correct the scene context recorded in Stage 1."""
from .guided import confirm_context
return confirm_context(config_path, input_path=Path(input_path), reviewer=reviewer)
[docs]
def corroborate_ontology_terms(
config_path: str | Path,
terms: Iterable[str],
*,
expected_names: Iterable[str | None] | None = None,
) -> dict[str, Any]:
"""Corroborate CL terms against an optional live service without depending on it.
The local ontology stays authoritative. This reports where a live service
agrees, disagrees, or cannot be reached, and stores each answer it received
as a hashed artifact so the run remains reproducible from its own files.
"""
from .config import load_config
from .ontology import corroborate_terms_live, ontology_from_config
config = load_config(config_path)
return corroborate_terms_live(
config,
list(terms),
expected_names=list(expected_names) if expected_names is not None else None,
ontology=ontology_from_config(config),
)
[docs]
def list_annotation_assumptions(config_path: str | Path) -> dict[str, Any]:
"""Return the living assumptions ledger for a configured run."""
from .guided import list_assumptions
return list_assumptions(config_path)
[docs]
def record_annotation_assumption(
config_path: str | Path,
*,
scope: str,
statement: str,
material: bool = True,
) -> dict[str, Any]:
"""Append one assumption to the living ledger."""
from .guided import record_assumption
return record_assumption(
config_path, scope=scope, statement=statement, material=material
)
# --- pipeline phases ----------------------------------------------------------
[docs]
def freeze_review_packet(config_path: str | Path) -> Path:
"""Freeze the immutable review packet directory for human sign-off."""
from .pipeline import build_review_packet
return build_review_packet(Path(config_path))
[docs]
def build_marker_vocabulary(
config_path: str | Path,
*,
source: Iterable[str | Path] = (),
parent_scope: str | None = None,
parent_cl_id: str | None = None,
include_unscoped: bool = False,
axis: str | None = None,
feature_space: str | None = None,
output_path: str | Path | None = None,
) -> tuple[list[Any], Path]:
"""Assemble and publish the signed marker vocabulary for a configuration."""
from .markers import assemble_marker_programs_from_config
return assemble_marker_programs_from_config(
config_path,
source=source,
parent_scope=parent_scope,
parent_cl_id=parent_cl_id,
include_unscoped=include_unscoped,
axis=axis,
feature_space=feature_space,
output_path=output_path,
)
[docs]
def advisory_confidence(
*, margin: float, specificity: float, agreement: float, coverage: float
) -> float:
"""Combine four evidence dimensions into an explicitly uncalibrated score."""
from .hierarchy import advisory_confidence as confidence
return confidence(
margin=margin,
specificity=specificity,
agreement=agreement,
coverage=coverage,
)
[docs]
def validate_hierarchy_nesting(
level_assignments: Iterable[Any], *, cell_membership: Any | None = None
) -> dict[str, Any]:
"""Enforce one parent per label and optional one-cell-one-leaf membership."""
from .hierarchy import validate_hierarchy_nesting as validate
return validate(level_assignments, cell_membership=cell_membership)
# --- automated cross-checks ---------------------------------------------------
[docs]
def existing_prediction(
*,
input_path: str | Path,
prediction_column: str,
cluster_column: str,
modality: str = "",
output_dir: str | Path | None = None,
) -> tuple[Any, Any, dict[str, Any]]:
"""Turn an existing per-cell prediction column into one auditable hypothesis."""
from .crosschecks import existing_prediction_file
return existing_prediction_file(
input_path=input_path,
prediction_column=prediction_column,
cluster_column=cluster_column,
modality=modality,
output_dir=output_dir,
)
[docs]
def discover_celltypist_models(*, output_dir: str | Path | None = None) -> dict[str, Any]:
"""List locally cached CellTypist models without downloading anything."""
from .crosschecks import discover_celltypist_models as discover
return discover(output_dir=output_dir)
[docs]
def predict_celltypist(
*,
input_path: str | Path,
model: str,
cluster_column: str = "",
modality: str = "",
output_dir: str | Path | None = None,
) -> tuple[Any, dict[str, Any]]:
"""Run a locally cached CellTypist model as one hypothesis."""
from .crosschecks import predict_celltypist_file
return predict_celltypist_file(
input_path=input_path,
model=model,
cluster_column=cluster_column,
modality=modality,
output_dir=output_dir,
)
[docs]
def map_reference(
*,
query_path: str | Path,
reference_path: str | Path,
reference_label_column: str,
query_cluster_column: str = "",
query_modality: str = "",
reference_modality: str = "",
output_dir: str | Path | None = None,
**kwargs: Any,
) -> tuple[Any, Any, dict[str, Any]]:
"""Transfer labels from a labeled reference by nearest neighbours."""
from .crosschecks import map_reference_files
return map_reference_files(
query_path=query_path,
reference_path=reference_path,
reference_label_column=reference_label_column,
query_cluster_column=query_cluster_column,
query_modality=query_modality,
reference_modality=reference_modality,
output_dir=output_dir,
**kwargs,
)
[docs]
def map_curated_human_reference(
*,
query_path: str | Path,
reference_path: str | Path,
reference_label_column: str,
query_cluster_column: str = "",
query_modality: str = "",
reference_modality: str = "",
output_dir: str | Path | None = None,
**kwargs: Any,
) -> tuple[Any, Any, dict[str, Any]]:
"""Map a query onto a curated human reference (Azimuth-style)."""
from .crosschecks import map_curated_human_reference_files
return map_curated_human_reference_files(
query_path=query_path,
reference_path=reference_path,
reference_label_column=reference_label_column,
query_cluster_column=query_cluster_column,
query_modality=query_modality,
reference_modality=reference_modality,
output_dir=output_dir,
**kwargs,
)
[docs]
def map_scimilarity(
*,
input_path: str | Path,
model_path: str | Path,
modality: str = "",
output_dir: str | Path | None = None,
) -> tuple[Any, dict[str, Any]]:
"""Run a local SCimilarity model as one hypothesis."""
from .crosschecks import map_scimilarity_file
return map_scimilarity_file(
input_path=input_path,
model_path=model_path,
modality=modality,
output_dir=output_dir,
)
[docs]
def fetch_census_reference(
*,
organism: str,
tissue: str,
output_path: str | Path,
census_version: str,
max_cells: int = 50_000,
label_columns: Iterable[str] = ("cell_type",),
expected_sha256: str = "",
timeout_seconds: float = 300.0,
) -> dict[str, Any]:
"""Acquire a bounded CELLxGENE Census slice with a versioned cache receipt."""
from .crosschecks import fetch_census_reference as fetch
return fetch(
organism=organism,
tissue=tissue,
output_path=Path(output_path),
census_version=census_version,
max_cells=max_cells,
label_columns=label_columns,
expected_sha256=expected_sha256,
timeout_seconds=timeout_seconds,
)
[docs]
def fetch_azimuth_reference(
*,
url: str,
output_path: str | Path,
expected_sha256: str,
max_bytes: int = 512 * 1024**2,
timeout_seconds: float = 600.0,
) -> dict[str, Any]:
"""Acquire a pinned curated-human reference bundle with a cache receipt."""
from .crosschecks import fetch_azimuth_reference as fetch
return fetch(
url=url,
output_path=Path(output_path),
expected_sha256=expected_sha256,
max_bytes=max_bytes,
timeout_seconds=timeout_seconds,
)
[docs]
def fetch_scimilarity_model(
*,
url: str,
output_path: str | Path,
expected_sha256: str,
max_bytes: int = 32 * 1024**3,
timeout_seconds: float = 3_600.0,
) -> dict[str, Any]:
"""Acquire a pinned SCimilarity model bundle with a cache receipt."""
from .crosschecks import fetch_scimilarity_model as fetch
return fetch(
url=url,
output_path=Path(output_path),
expected_sha256=expected_sha256,
max_bytes=max_bytes,
timeout_seconds=timeout_seconds,
)
[docs]
def train_scanvi_reference_model(
*,
reference_path: str | Path,
labels_key: str,
output_dir: str | Path,
modality: str = "",
counts_layer: str = "counts",
max_epochs: int = 200,
seed: int = 0,
) -> dict[str, Any]:
"""Train a scANVI reference model from a labeled local reference object."""
from .crosschecks import train_scanvi_reference_file
return train_scanvi_reference_file(
reference_path=reference_path,
labels_key=labels_key,
output_dir=output_dir,
modality=modality,
counts_layer=counts_layer,
max_epochs=max_epochs,
seed=seed,
)
[docs]
def map_scarches(
*,
query_path: str | Path,
model_dir: str | Path,
output_dir: str | Path,
modality: str = "",
max_epochs: int = 100,
) -> tuple[Any, dict[str, Any]]:
"""Map a query onto a trained reference model with scArches surgery."""
from .crosschecks import map_scarches_file
return map_scarches_file(
query_path=query_path,
model_dir=model_dir,
output_dir=output_dir,
modality=modality,
max_epochs=max_epochs,
)
# --- review, critics, and reporting ------------------------------------------
[docs]
def build_evidence_cards(config_path: str | Path) -> list[Path]:
"""Scaffold one evidence card per proposed label."""
from .config import load_config
from .pipeline import run_root
from .review import build_evidence_cards as build
config = load_config(config_path)
return build(config, run_root(config))
[docs]
def build_html_report(
config_path: str | Path, *, strict: bool = False, level: str | None = None
) -> Path:
"""Build the self-contained HTML review report."""
from .config import load_config
from .pipeline import run_root
from .review import build_html_report as build
config = load_config(config_path)
return build(config, run_root(config), strict=strict, level=level)
[docs]
def build_critic_packet(config_path: str | Path) -> Path:
"""Build the platform-neutral critic packet for adversarial review."""
from .config import load_config
from .pipeline import run_root
from .review import build_critic_packet as build
config = load_config(config_path)
return build(config, run_root(config))
[docs]
def import_critic_findings(config_path: str | Path, input_path: str | Path) -> dict[str, Any]:
"""Validate and atomically import structured critic findings."""
from .config import load_config
from .pipeline import run_root
from .review import import_critic_findings as import_findings
config = load_config(config_path)
return import_findings(run_root(config), Path(input_path))
[docs]
def import_critic_reconciliation(
config_path: str | Path, input_path: str | Path
) -> dict[str, Any]:
"""Validate and atomically import reviewer dispositions for critic findings."""
from .config import load_config
from .pipeline import run_root
from .review import import_reconciliation
config = load_config(config_path)
return import_reconciliation(run_root(config), Path(input_path))
[docs]
def validate_critic_reconciliation(config_path: str | Path) -> dict[str, Any]:
"""Enforce that every critic finding carries a reviewer disposition."""
from .config import load_config
from .pipeline import run_root
from .review import validate_reconciliation
config = load_config(config_path)
return validate_reconciliation(run_root(config))
# --- benchmarks ---------------------------------------------------------------
[docs]
def evaluate_benchmark_predictions(
prediction_path: str | Path,
*,
system: str,
dataset: str,
output_path: str | Path,
ontology: str | Path | None = None,
) -> Any:
"""Score a neutral-format prediction table against its recorded truth.
The optional ``ontology`` is a local Cell Ontology snapshot. It is required
only when the table carries CL identifiers, and the published result then
records the snapshot's path and digest so the measurement can be traced
back to the file it was taken against.
"""
from .benchmark import evaluate_file
return evaluate_file(
Path(prediction_path),
system=system,
dataset=dataset,
output_path=Path(output_path),
ontology=ontology,
)
[docs]
def sweep_benchmark_risk_coverage(
predictions: str | Path,
*,
thresholds: Sequence[float] | None = None,
agreement: Agreement = "strict",
ontology: str | Path | CellOntology | None = None,
abstain_unknown: bool = False,
) -> list[RiskCoveragePoint]:
"""Report coverage, selective accuracy, and risk across a confidence grid.
This is the form the package's selective-prediction claim takes: comparable
accuracy at matched coverage. It is public because a comparative claim is
only checkable by whoever holds the competing table, so the curve has to be
computable over an export the caller brings, not only over this package's
own runs. It publishes nothing, because a published result is a commitment
and a curve is a reading.
``agreement="relaxed"`` counts a call as correct when its Cell Ontology term
is the true term or an ``is_a`` ancestor or descendant of it, for tables whose
truth is annotated more finely than the system under comparison answers, and
it takes the local snapshot the relaxed criterion is read from. The default
stays exact-label equality, so an existing comparison is unchanged, and the
strict curve ignores ``ontology`` entirely. Each point records the agreement
it was computed under.
"""
from .benchmark import read_predictions, risk_coverage_sweep
from .ontology import CellOntology
if isinstance(ontology, CellOntology):
resolved: CellOntology | None = ontology
else:
resolved = None if ontology is None else CellOntology.load(ontology)
return list(
risk_coverage_sweep(
read_predictions(predictions),
thresholds=thresholds,
agreement=agreement,
ontology=resolved,
abstain_unknown=abstain_unknown,
)
)
[docs]
def validate_dataset_manifest(path: str | Path) -> dict[str, Any]:
"""Validate one public benchmark dataset manifest."""
from .benchmark import validate_dataset_manifest as validate
return validate(Path(path))
[docs]
def export_benchmark_predictions(
config: CellCuratorConfig,
*,
truth_path: str | Path,
output_path: str | Path,
) -> dict[str, Any]:
"""Write a completed run's labels as a neutral-format prediction table.
The truth table must name exactly the barcodes the run labelled. A
prediction table is written next to an immutable receipt recording the run,
the truth digest, and the digests of the mapping and every label table, so
the scored table is attributable to the artifacts it came from.
"""
from .export import export_benchmark_predictions as export
return export(config, truth_path=truth_path, output_path=output_path)