yera.config.loaders.providers

Provider config loader — reads and validates provider config from yera.toml.

Symbols

def get_connection — Look up a named connection from a provider config.
def get_provider_config — Look up a named provider from the loaded providers config.
def load_providers — Read ``[providers]`` from yera.toml and build a ``Providers`` instance.
def resolve_connection — Determine the active connection name for a provider from the Yera profile.

get_connection

get_connection(
    connection_name: str,
    provider_type: str,
    provider_config: BaseProviderConfig,
) → BaseConnection

Look up a named connection from a provider config.

Parameters

connection_name
type: str

Name of the connection to retrieve.

provider_type
type: str

Provider type key, used in error messages.

provider_config
type: BaseProviderConfig

The loaded provider config to look up from.

Returns

type: BaseConnection

The matching connection object.

Raises

ConnectionNotFoundInConfigError

If no connection with the given name exists on the provider.

get_provider_config

get_provider_config(
    provider_type: str,
    providers: Providers,
) → BaseProviderConfig

Look up a named provider from the loaded providers config.

Parameters

provider_type
type: str

Provider type key, e.g. "aws", "ollama".

providers
type: Providers

The loaded providers config.

Returns

type: BaseProviderConfig

The provider config for the given type.

Raises

ProviderNotFoundInConfigError

If the provider type is not configured.

load_providers

load_providers() → Providers | None

Read [providers] from yera.toml and build a Providers instance.

Returns an empty Providers when the section or file is absent. Validation is eager — malformed provider config raises immediately via Pydantic.

Returns

type: Providers | None

A Providers instance populated from yera.toml, or an empty instance if the section is absent.

Raises

ProviderInvalidConfigError

If any provider entry fails Pydantic validation.

resolve_connection

resolve_connection(
    provider_type: str,
    provider_config: BaseProviderConfig,
    active_profile: Profile,
) → str

Determine the active connection name for a provider from the Yera profile.

Looks up the connection name for the given provider type in the active Yera profile's provider map. The Yera profile is the sole source of truth for which connection is active — there is no fallback.

Parameters

provider_type
type: str

Provider type key, e.g. "aws", "ollama".

provider_config
type: BaseProviderConfig

The loaded provider config, used to validate that the resolved connection name actually exists.

active_profile
type: Profile

The active Yera profile whose provider map is used for resolution.

Returns

type: str

The resolved connection name string.

Raises

ConnectionNotSpecifiedError

If the provider type is not listed in the active Yera profile's provider map.

ConnectionNotFoundInConfigError

If the resolved connection name does not exist on the provider config.