Skip to content

Configs

fyt.utils.configs

BaseExperimentLoggerConfig

Bases: YamlBaseModel

Base configuration for experiment logger implementations.

Uses extra="allow" so that concrete-logger fields (e.g. MLflow's tracking_uri) are preserved when this base type is used as the field type in command configs. The command layer can then pass the raw data to the concrete config class for full validation.

YamlBaseModel

Bases: BaseModel

Base for configs loaded explicitly from a single YAML file.

Unlike YamlBaseSettings, this never reads from the environment, so the same class can be instantiated many times from different files without the instances sharing a process-global env namespace. from_yaml reads DEFAULT_CONFIG_PATH when no path is given, or the provided path otherwise — one load path, one precedence, with the disk read made explicit at the call site.

Unknown keys are rejected (extra="forbid") so that config typos fail loudly at load time instead of being silently dropped.

from_yaml(path=None) classmethod

Load and validate the config from a YAML file.

Parameters:

Name Type Description Default
path str | Path | None

Path to the YAML file. When None, DEFAULT_CONFIG_PATH is used.

None

Returns:

Type Description
Self

The validated config instance.

Raises:

Type Description
ValueError

If no path is given and the class defines no DEFAULT_CONFIG_PATH.

to_yaml(path)

Serialize the config to a YAML file.

Parameters:

Name Type Description Default
path str | Path

Destination path for the YAML file.

required

YamlBaseSettings

Bases: BaseSettings

Base for process-level settings layered over the environment.

Use this for configuration that is singular per process (e.g. logging), where environment variables should be able to override the YAML file. For configs that can be instantiated many times from different files, use YamlBaseModel instead — env vars are a flat, process-global namespace and cannot represent per-instance overrides.

Unknown keys are rejected (extra="forbid") so that config typos fail loudly at load time instead of being silently dropped.