Skip to content

PackageConfigBase API

Bases: BaseModel

Typed view over a package's [tools.<tool_name>] TOML section.

Subclass this and declare the class variables below. Users who name their resource differently can add a [resource_aliases] section to config.toml (e.g. cdm_db = "my_prod") so all packages resolve correctly without per-package default_resource overrides.

Attributes

tool_name : str Key used in [tools.<name>]. Must be set on every subclass. required_resources : tuple[str, ...] Canonical resource names this package depends on. A missing resource at :meth:from_stack time raises :exc:ConfigurationError. owned_resources : tuple[ResourceSpec, ...] Resources this package is responsible for configuring interactively. omop-config configure prompts for these before package extras. test_resources : tuple[ResourceSpec, ...] Optional test-only resources. omop-config configure presents a Y/N prompt for these after the main resource flow. Marked with a DROP SCHEMA warning; a collision check prevents pointing at any already-configured non-test resource. extra_logging_namespaces : tuple[str, ...] Logger namespaces of transitive dependencies to configure alongside this package. The package's own tool_name are always included -> only list additional roots here, e.g. ("<my_extra_package_to_log",). Missing namespaces are harmless.

configure_logging classmethod

configure_logging(
    config=None, *, verbosity: int = 0, console=None
) -> None

Configure logging for this package and its declared transitive dependencies.

from_stack classmethod

from_stack(config: StackConfig) -> Self

Load this package's section from a :class:StackConfig.

Validates that all :attr:required_resources (or the default_resource override) are present in the config before instantiating. Alias resolution via config.resource_aliases is applied before the existence check. Raises :exc:ConfigurationError with an actionable message if any are missing.

get_config classmethod

get_config() -> Self

Load this package's config from the active stack config file.

get_engine classmethod

get_engine(
    resource_name: str | None = None, **engine_kwargs: Any
) -> Any

Create a SQLAlchemy engine for a resource.

Parameters

resource_name: Resource to resolve. If None, uses tool.default_resource from the config file, or falls back to required_resources[0]. **engine_kwargs: Forwarded to :meth:~oa_configurator.resolver.ResolvedResource.create_engine.

Raises

ConfigurationError If no resource name can be determined.

to_extra_dict

to_extra_dict() -> dict[str, Any]

Serialize back to the dict stored in ToolConfig.extra.