Skip to content

Config

class_e.config

One configuration for the whole pipeline: model, designs, training, evaluation.

A pipeline YAML is the generation YAML (theory, parameters, derived, observables, samples, output) plus optional train and evaluate sections::

samples:
  constraints: ["w0 + wa < 0"]
  designs:
    train: {method: sobol, N: 1024, seed: 0}
    test:  {method: lhc,   N: 512,  seed: 12345}
train:
  test_design: test                  # design: train by default; or dataset:/test_dataset: paths
  backend: jax
  defaults: {n_pca: 32, config: {steps: 200}}
  inputs: {..., w0: w0, s: "w0 + wa"}
  observables: {TT: {}, EE: {segments: [{ell: [2, 150]}, {ell: [50, 6500]}]}}
  out: bundles/model.cemu
evaluate:
  by: {expr: "w0 + wa", edges: [-3, -1, -0.5, 0]}
  ell_ranges: [2, 30, 500, 2500]

PipelineConfig.load validates all of it at once (unknown keys in these sections are errors, references between sections are checked), so mistakes surface before CLASS runs or an emulator is fitted. Overrides are dotted paths into the YAML ({"samples.designs.train.N": 8}), applied before validation; the CLI's --set and its flags are such overrides. The CLI and the (future) marimo apps both build a PipelineConfig; the training section keeps the format of the separate training YAML (class_e.commands.training), which still works on its own.

PipelineConfig dataclass

PipelineConfig(
    raw: Dict[str, Any],
    samples: SamplesSpec,
    train: Optional[TrainSpec] = None,
    evaluate: Optional[EvaluateSpec] = None,
    path: Optional[Path] = None,
    run: RunSpec = RunSpec(),
    cluster: ClusterSpec = ClusterSpec(),
)

A validated pipeline configuration (see the module docstring).

designs property
designs: List[Optional[str]]

Names of the designs ([None]: a flat samples section, one unnamed design).

load classmethod
load(
    source: Union[str, Path, Mapping[str, Any]],
    overrides: Optional[Mapping[str, Any]] = None,
) -> "PipelineConfig"

Read (YAML path) or take (dict) a configuration, apply overrides, validate.

generation
generation(
    design: Optional[str] = None, **flags
) -> GenerationConfig

The GenerationConfig of design, with the CLI's convenience flags applied (N, method, seed, observables, lmax, kmin/kmax, cov; see class_e.generation.dataset.with_overrides).

dataset_path
dataset_path(
    design: Optional[str] = None,
    out: Optional[Union[str, Path]] = None,
) -> Path

Where design's dataset is written (see class_e.generation.dataset.dataset_path).

model
model()

The pydantic cosmology model of the configuration.

parameter_names
parameter_names() -> List[str]

The sampled parameters (the inputs of the emulators), in order.

train_design
train_design() -> Optional[str]

The design the training set comes from (None: a dataset file, or the unnamed design).

train_config
train_config(overrides: Optional[Mapping[str, Any]] = None)

The TrainConfig of the train section, designs resolved to dataset paths.

overrides are the training CLI's (dataset, n_pca, backend, ...; see class_e.commands.training.load_train_config).

SamplesSpec

Bases: DesignSpec

samples: shared design settings and, optionally, named designs.

DesignSpec

Bases: _Section

One design (samples itself, or an entry of samples.designs).

TrainSpec

Bases: _Section

train: the training YAML (see class_e.commands.training), with designs for datasets.

EvaluateSpec

Bases: _Section

evaluate: how test errors are binned (see class_e.commands.evaluate).

by_bins
by_bins() -> Optional[Tuple[str, List[float]]]

(expression, bin edges) of by (mapping or "EXPR:EDGE,..." form), or None.

PlotsSpec

Bases: _Section

evaluate.plots: figures of class-e evaluate --plots/--report.

The band figure (median, 68% and 95% of the errors per ell, and their range) is always made; floor, corner and worst add the extra figures.

corner_spec
corner_spec() -> Optional[CornerSpec]

The corner (prior heat map) settings: defaults for true, None if disabled.

n_worst
n_worst() -> int

Number of worst test points to plot (true: 4, false: 0).

RunSpec

Bases: _Section

run: how generation runs on this machine (outside the dataset fingerprint).

ClusterSpec

Bases: _Section

cluster: SLURM settings for class-e generate --slurm (outside the fingerprint).

profile: NAME takes defaults from ~/.config/class-e/clusters/NAME.yaml (or $CLASS_E_CLUSTERS/NAME.yaml); keys given here override the profile's.