Skip to content

Resolver

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

Resolver

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

active_profile_name

active_profile_name() -> str | None

Return the name of the currently active profile, or None.

database_names

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

Return a sorted tuple of configured database names.

effective_database

effective_database(name: str) -> DatabaseConfig

Return the active DatabaseConfig for a database name.

Profile overlay databases take precedence over base databases. Unlike resolve_database, this returns the raw config object rather than a resolved target; useful when individual fields (host, port, etc.) are needed directly.

Parameters

name : str Database name as it appears in [databases] or a profile overlay.

Returns

DatabaseConfig The effective database config for the active profile.

Raises

KeyError If name does not exist in the base config or the active profile.

from_active_config classmethod

from_active_config() -> Resolver

Create a Resolver from the currently active stack config file.

profile_names

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

Return a sorted tuple of configured profile names.

resolve_database

resolve_database(name: str) -> ResolvedDatabaseTarget

Resolve a database name to a concrete target.

Profile overlay databases take precedence over base databases.

resolve_resource

resolve_resource(name: str) -> ResolvedResource

Resolve a resource name to a concrete bundle of DB targets and schemas.

Applies profile overlays and resource aliases. The vocab DB falls back to the primary DB when not explicitly configured; the vocab schema falls back to the CDM schema under the same condition.

Parameters

name : str Resource name or alias as declared in [resources] or [resource_aliases].

Returns

ResolvedResource Fully resolved resource with concrete database targets and effective schema names.

Raises

KeyError If name (after alias resolution) does not exist in the config.

resolve_tool

resolve_tool(name: str) -> ResolvedToolConfig

Resolve a tool name to its configuration.

Parameters

name : str Tool name as declared in [tools].

Returns

ResolvedToolConfig Resolved config with the raw extra dict intact for consumption by PackageConfigBase.from_stack.

Raises

KeyError If name does not exist in the config.

resource_names

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

Return a sorted tuple of configured resource names.

tool_names

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

Return a sorted tuple of configured tool names.

with_overrides

with_overrides(
    *,
    databases: dict[str, DatabaseConfig] | None = None,
    resources: dict[str, ResourceConfig] | None = None,
    tools: dict[str, ToolConfig] | None = None,
) -> Resolver

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

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

Resolved types

ResolvedResource

Resolved logical resource with concrete DB targets and effective schema names.

Attributes

name : str Logical name of the resource as declared in the config or an alias. database : ResolvedDatabaseTarget Resolved primary database target for this resource. vocab_database : ResolvedDatabaseTarget Resolved vocabulary database target for this resource. May be the same as database if no separate vocab database is configured. cdm_schema : str Effective CDM schema name for this resource. vocab_schema : str Effective vocabulary schema name for this resource. May be the same as cdm_schema if no separate vocab schema is configured. results_schema : str | None Effective results schema name for this resource, or None if not configured.

create_engine

create_engine(
    role: Literal["primary", "vocab"] = "primary",
    *,
    execution_options: dict[str, Any] | None = None,
    **kwargs: Any,
) -> Engine

Create a SQLAlchemy engine with the schema translate map applied.

The schema translate map routes OMOP ORM models to the correct schemas automatically (None -> cdm_schema, "vocab" -> vocab_schema, "results" -> results_schema when configured).

Parameters

role : {"primary", "vocab"}, optional Which database target to create an engine for. Defaults to "primary". execution_options : dict, optional Additional execution options merged into the engine. The schema_translate_map key is set automatically and must not be supplied here. **kwargs Forwarded to sqlalchemy.create_engine.

Returns

sqlalchemy.engine.Engine Engine configured with schema_translate_map for OMOP ORM routing.

database_target

database_target(
    role: Literal["primary", "vocab"] = "primary",
) -> ResolvedDatabaseTarget

Return the resolved database target for a given role.

Parameters

role : {"primary", "vocab"}, optional Which database target to return. Defaults to "primary". When vocab_database was not configured, "vocab" returns the same target as "primary".

Returns

ResolvedDatabaseTarget The concrete database target for role.

Raises

ValueError If role is not "primary" or "vocab".

schema_translate_map

schema_translate_map() -> dict[str | None, str | None]

SQLAlchemy schema translate map for OMOP ORM models.

Maps

None → cdm_schema (default / unqualified tables → CDM) "vocab" → vocab_schema (or cdm_schema as fallback) "results" → results_schema (omitted when not configured)

ResolvedDatabaseTarget

Concrete database connection ready for engine creation.

Attributes

name : str Logical name of the connection as declared in the config. url : str Full database URL including credentials. TODO: make this a private attribute to avoid accidental password exposure; requires a factory method or __post_init__ since dataclass field visibility can't be changed without breaking callers. safe_url : str Database URL with credentials redacted, safe for logging and display.

create_engine

create_engine(**kwargs: Any) -> Engine

Create a SQLAlchemy engine for this connection.

Parameters

**kwargs Forwarded to sqlalchemy.create_engine. The read_only keyword is silently removed for SQLite connections, which do not support it.

Returns

sqlalchemy.engine.Engine

ResolvedToolConfig

Resolved tool section with raw extra dict for PackageConfigBase consumption.