espnet3.utils.run_utils.validate_experiment_context
espnet3.utils.run_utils.validate_experiment_context
espnet3.utils.run_utils.validate_experiment_context(, training_config: DictConfig | None, inference_config: DictConfig | None, metrics_config: DictConfig | None, stages_to_run: Sequence[str]) → None
Validate that runtime configs have enough experiment identity.
This helper enforces the two supported runner modes:
- Training-backed mode, where training_config is present and provides experiment identity for inference and metrics.
- Standalone inference/metrics mode, where the runtime config must define its own exp_tag or concrete exp_dir.
- Parameters:
- training_config (DictConfig | None) – Training config selected for the current run.
- inference_config (DictConfig | None) – Inference config for the infer stage.
- metrics_config (DictConfig | None) – Metrics config for the measure stage.
- stages_to_run (Sequence *[*str ]) – Resolved stage names requested by the runner.
- Returns: Validation succeeds silently.
- Return type: None
- Raises:ValueError – If infer or measure is requested without training_config and the corresponding runtime config does not define exp_tag or a concrete exp_dir.
Notes
Validation is stage-aware. For example, a missing metrics identity is ignored when measure is not in stages_to_run.
Examples
Allow standalone inference when the config already defines its experiment identity:
```python inference_config = OmegaConf.create(
) validate_experiment_context(
training_config=None, inference_config=inference_config, metrics_config=None, stages_to_run=[“infer”],
)
Succeeds because standalone inference can derive exp_dir.
```Reject standalone inference when experiment identity is missing:
```python inference_config = OmegaConf.create(
{“inference_dir”: “${exp_dir}/inference”}
) validate_experiment_context(
training_config=None, inference_config=inference_config, metrics_config=None, stages_to_run=[“infer”],
)
Raises:
ValueError: infer stage requires –training_config or a
standalone inference_config with exp_tag/exp_dir.
```Accept training-backed inference even when inference_config does not define exp_tag:
```python training_config = OmegaConf.create(
) inference_config = OmegaConf.create(
{“inference_dir”: “${exp_dir}/inference”}
) validate_experiment_context(
training_config=training_config, inference_config=inference_config, metrics_config=None, stages_to_run=[“infer”],
)
Succeeds because training-backed mode is active.
```