Skip to content

Resolver

The Resolver turns logical names in a StackConfig into concrete typed handles with secrets resolved and paths expanded.

It is thin dispatch: each resolve_* method looks up the raw config entry and delegates to that entry's own resolve() method. The resolved types themselves (ResolvedConnection, ResolvedDatabase/ResolvedCDMDatabase, ResolvedProvider, ResolvedModel, ResolvedVectorStore) are documented next to their raw counterpart, under Resources, LLM, and Vector Stores.

Resolver

Resolves logical names in a StackConfig into typed, usable handles.

Thin dispatch: each resolve_* method looks up the raw config entry (via the matching get_*) and delegates to that entry's own .resolve() method. The resolution logic itself lives on the schema classes in :mod:oa_configurator.domains, next to the data it resolves.

connection_names

connection_names() -> tuple[str, ...]

Return a sorted tuple of configured connection names.

database_names

database_names() -> tuple[str, ...]

Return a sorted tuple of configured database names.

from_active_config classmethod

from_active_config() -> Resolver

Create a Resolver from the currently active stack config file.

get_connection

get_connection(name: str) -> ConnectionConfig

Return the raw ConnectionConfig for a connection name.

Unlike resolve_connection, this returns the raw config object rather than a resolved target; useful when individual fields (host, port, etc.) are needed directly.

Raises:

Type Description
KeyError

If name does not exist in the config.

get_database

get_database(name: str) -> DatabaseConfig

Return the raw DatabaseConfig for a database name.

Raises:

Type Description
KeyError

If name does not exist in the config.

get_model

get_model(name: str) -> ModelConfig

Return the raw ModelConfig for a model name.

Raises:

Type Description
KeyError

If name does not exist in the config.

get_provider

get_provider(name: str) -> ProviderConfig

Return the raw ProviderConfig for a provider name.

Unlike resolve_provider, this returns the raw config object rather than a resolved target.

Raises:

Type Description
KeyError

If name does not exist in the config.

get_tool

get_tool(name: str) -> dict[str, Any]

Return the raw [tools.<name>] dict for a tool name.

Raises:

Type Description
KeyError

If name does not exist in the config.

get_vector_store

get_vector_store(name: str) -> VectorStoreConfig

Return the raw VectorStoreConfig for a vector store name.

Raises:

Type Description
KeyError

If name does not exist in the config.

model_names

model_names() -> tuple[str, ...]

Return a sorted tuple of configured model names.

provider_names

provider_names() -> tuple[str, ...]

Return a sorted tuple of configured provider names.

resolve_connection

resolve_connection(name: str) -> ResolvedConnection

Resolve a connection name to a concrete target.

resolve_database

resolve_database(name: str) -> ResolvedDatabase

Resolve a database name to a concrete connection and effective schema.

Parameters:

Name Type Description Default
name str

Database name as declared in [databases].

required

Returns:

Type Description
ResolvedDatabase

Fully resolved database. Returns a :class:ResolvedCDMDatabase for a kind="cdm" entry, or a plain :class:ResolvedDatabase for kind="generic".

Raises:

Type Description
KeyError

If name does not exist in the config.

resolve_engine

resolve_engine(database: str, **kwargs: Any) -> Engine

Resolve a database name into an engine.

Parameters:

Name Type Description Default
database str

The database name to resolve. No zero-argument defaulting: the database must be named explicitly.

required
**kwargs Any

Forwarded to :meth:ResolvedDatabase.create_engine.

{}

Returns:

Type Description
Engine

resolve_model

resolve_model(name: str) -> ResolvedModel

Resolve a model name to a concrete, backend-ready configuration.

The unit consuming packages use directly: a package's own config just names an entry here (e.g. embedding_model_name = "embed-default").

Parameters:

Name Type Description Default
name str

Model name as declared in [models].

required

Returns:

Type Description
ResolvedModel

Fully resolved model with a concrete provider connection.

Raises:

Type Description
KeyError

If name (or its provider) does not exist in the config.

resolve_package_config

resolve_package_config(cls: type[TConfig]) -> TConfig

Resolve and validate a package's own typed [tools.<name>] section.

Validates every RefTo-marked field (e.g. a package's own cdm_db/embedding_model_name) resolves to a configured entry. Unlike :meth:resolve_tool, a missing tool section itself is not an error here, since a package's own fields may all have usable defaults even before omop-config configure has been run.

Parameters:

Name Type Description Default
cls type[PackageConfigBase]

The package's PackageConfigBase subclass to resolve.

required

Returns:

Type Description
PackageConfigBase

An instance of cls validated from its [tools.<name>] section (or an empty dict, if not yet configured).

Raises:

Type Description
ConfigurationError

If a RefTo-marked field names an entry that doesn't exist, names an entry of the wrong concrete subtype (e.g. a RefTo(CDMDatabaseConfig) field pointing at a GenericDatabaseConfig entry), or names a database whose connection's test_only flag disagrees with the field's own is_test declaration (a production field pointed at a test connection, or vice versa).

resolve_provider

resolve_provider(name: str) -> ResolvedProvider

Resolve a provider name to a concrete connection.

Parameters:

Name Type Description Default
name str

Provider name as declared in [providers].

required

Returns:

Type Description
ResolvedProvider

Resolved provider connection.

Raises:

Type Description
KeyError

If name does not exist in the config.

resolve_tool

resolve_tool(name: str) -> ResolvedToolConfig

Resolve a tool name to its configuration.

Parameters:

Name Type Description Default
name str

Tool name as declared in [tools].

required

Returns:

Type Description
ResolvedToolConfig

Resolved config with the raw extra dict intact. Prefer :meth:resolve_package_config for the typed, validated equivalent.

Raises:

Type Description
KeyError

If name does not exist in the config.

resolve_vector_store

resolve_vector_store(name: str) -> ResolvedVectorStore

Resolve a vector store name to a concrete, backend-ready configuration.

The unit consuming packages use directly: a package's own config just names an entry here (e.g. vector_store_name = "vector_store").

Parameters:

Name Type Description Default
name str

Vector store name as declared in [vector_stores].

required

Returns:

Type Description
ResolvedVectorStore

Fully resolved vector store, with a concrete database when configured.

Raises:

Type Description
KeyError

If name (or its database) does not exist in the config.

tool_names

tool_names() -> tuple[str, ...]

Return a sorted tuple of configured tool names.

vector_store_names

vector_store_names() -> tuple[str, ...]

Return a sorted tuple of configured vector store names.

with_overrides

with_overrides(
    *,
    connections: dict[str, ConnectionConfig] | None = None,
    databases: Mapping[str, DatabaseEntry] | None = None,
    providers: dict[str, ProviderConfig] | None = None,
    models: dict[str, ModelConfig] | None = None,
    vector_stores: dict[str, VectorStoreConfig]
    | None = None,
    tools: dict[str, dict[str, Any]] | None = None,
) -> Resolver

Return a new Resolver with entries merged over the current config.

Useful for session-level overrides without touching the TOML file.

Parameters:

Name Type Description Default
connections dict[str, ConnectionConfig]

Connection entries, keyed by name, merged over the current config.

None
databases Mapping[str, DatabaseEntry]

Database entries, keyed by name, merged over the current config. Mapping so a caller can pass just one concrete kind (e.g. dict[str, GenericDatabaseConfig]) without a dict-invariance error.

None
providers dict[str, ProviderConfig]

Provider entries, keyed by name, merged over the current config.

None
models dict[str, ModelConfig]

Model entries, keyed by name, merged over the current config.

None
vector_stores dict[str, VectorStoreConfig]

Vector-store entries, keyed by name, merged over the current config.

None
tools dict[str, dict[str, Any]]

Per-package [tools.<name>] sections, keyed by tool name, merged over the current config.

None

ResolvedToolConfig

The one resolved type that stays here rather than moving to a domain: a raw, untyped [tools.<name>] section, returned by resolve_tool(). Prefer resolve_package_config() (or PackageConfigBase.get_config()) for the typed, validated equivalent.

Resolved tool section with raw extra dict for PackageConfigBase consumption.