czbenchmarks.cli.resolve_reference

Attributes

ANNDATA_REF_PREFIX

Classes

AnnDataReference

DataRef represents a structured reference to a specific slot or field within an AnnData object.

Functions

is_anndata_reference(→ bool)

resolve_value_recursively(→ Any)

resolve_task_parameters(→ dict[str, Any])

Module Contents

czbenchmarks.cli.resolve_reference.ANNDATA_REF_PREFIX = '@'
class czbenchmarks.cli.resolve_reference.AnnDataReference(/, **data: Any)[source]

Bases: pydantic.BaseModel

DataRef represents a structured reference to a specific slot or field within an AnnData object. References are denoted by a leading ‘@’ and can point to various AnnData attributes:

  • ‘@X’ → adata.X (main data matrix)

  • @obs’ → adata.obs (entire observations DataFrame)

  • @obs:cell_type’ → adata.obs[“cell_type”] (specific column in obs)

  • @obsm:X_pca’ → adata.obsm[“X_pca”] (specific key in obsm)

  • @layers:counts’ → adata.layers[“counts”] (specific layer)

  • @var:gene_symbols’ → adata.var[“gene_symbols”] (specific column in var)

  • @varm:some_key’ → adata.varm[“some_key”] (specific key in varm)

  • @uns:some_key’ → adata.uns[“some_key”] (specific key in uns)

space

The AnnData attribute to reference (‘X’, ‘obs’, ‘obsm’, ‘var’, ‘varm’, ‘layers’, ‘uns’).

Type:

str

key

The key or column name within the specified space, if applicable.

Type:

Optional[str]

parse(value

str) -> DataRef: Parse a string reference (e.g., @obs:cell_type’) into a DataRef instance.

resolve(adata

AnnData) -> Any: Resolve the reference against a given AnnData object, returning the referenced data.

Raises:
  • ValueError – If the reference format is invalid or unsupported.

  • KeyError – If the specified key does not exist in the referenced AnnData attribute.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

space: str
key: str | None = None
static parse(ref_string: str) AnnDataReference[source]
resolve(anndata: anndata.AnnData) Any[source]
czbenchmarks.cli.resolve_reference.is_anndata_reference(value: Any) bool[source]
czbenchmarks.cli.resolve_reference.resolve_value_recursively(value: Any, anndata: anndata.AnnData) Any[source]
czbenchmarks.cli.resolve_reference.resolve_task_parameters(task_params: dict[str, Any], anndata: anndata.AnnData) dict[str, Any][source]