Skip to content

Models Reference

Auto-generated API documentation for brix Pydantic models.

Profile Models

brix.modules.dbt.profile.models

Pydantic models for dbt profile configuration.

These models provide type-safe parsing and validation of dbt profiles.yml files. Supports DuckDB and Databricks adapters.

DuckDbOutput

Bases: BaseModel

DuckDB adapter output configuration.

Supports all dbt-duckdb adapter options including extensions and settings.

Source code in src/brix/modules/dbt/profile/models.py
class DuckDbOutput(BaseModel):
    """DuckDB adapter output configuration.

    Supports all dbt-duckdb adapter options including extensions and settings.
    """

    model_config = ConfigDict(extra="allow", populate_by_name=True)

    type: Literal["duckdb"]
    path: str = ":memory:"
    schema_: str = Field(default="main", alias="schema")
    database: str = "main"
    threads: int = 1
    extensions: list[str] = Field(default_factory=list)
    settings: dict[str, Any] = Field(default_factory=dict)

    @model_validator(mode="after")
    def sync_database_with_memory_path(self) -> Self:
        """Set database to 'memory' when path is ':memory:' for dbt-duckdb compatibility."""
        if self.path == ":memory:" and self.database != "memory":
            self.database = "memory"
        return self

sync_database_with_memory_path()

Set database to 'memory' when path is ':memory:' for dbt-duckdb compatibility.

Source code in src/brix/modules/dbt/profile/models.py
@model_validator(mode="after")
def sync_database_with_memory_path(self) -> Self:
    """Set database to 'memory' when path is ':memory:' for dbt-duckdb compatibility."""
    if self.path == ":memory:" and self.database != "memory":
        self.database = "memory"
    return self

DatabricksOutput

Bases: BaseModel

Databricks adapter output configuration.

Supports multiple authentication methods: - Token-based: Personal Access Token (PAT) - OAuth U2M: User-to-machine (browser-based, no secrets needed) - OAuth M2M (AWS/GCP): Machine-to-machine with client_id/client_secret - OAuth M2M (Azure): Machine-to-machine with azure_client_id/azure_client_secret

Source code in src/brix/modules/dbt/profile/models.py
class DatabricksOutput(BaseModel):
    """Databricks adapter output configuration.

    Supports multiple authentication methods:
    - Token-based: Personal Access Token (PAT)
    - OAuth U2M: User-to-machine (browser-based, no secrets needed)
    - OAuth M2M (AWS/GCP): Machine-to-machine with client_id/client_secret
    - OAuth M2M (Azure): Machine-to-machine with azure_client_id/azure_client_secret
    """

    model_config = ConfigDict(extra="allow", populate_by_name=True)

    type: Literal["databricks"]

    # Required connection fields
    schema_: str = Field(alias="schema")
    host: str
    http_path: str

    # Authentication - exactly one method required (validated via model_validator)
    token: str | None = None
    auth_type: DatabricksAuthType | None = None
    client_id: str | None = None
    client_secret: str | None = None
    azure_client_id: str | None = None
    azure_client_secret: str | None = None

    # Optional fields
    catalog: str | None = None
    threads: int = 1
    connect_retries: int = 0
    connect_timeout: int | None = None

    @field_validator("host", mode="before")
    @classmethod
    def strip_host_protocol(cls, v: str) -> str:
        """Strip http:// or https:// prefix from host if present."""
        if isinstance(v, str):
            if v.startswith("https://"):
                return v[8:]
            if v.startswith("http://"):
                return v[7:]
        return v

    @field_validator("http_path", mode="before")
    @classmethod
    def ensure_http_path_starts_with_slash(cls, v: str) -> str:
        """Ensure http_path starts with /."""
        if isinstance(v, str) and not v.startswith("/"):
            return f"/{v}"
        return v

    @field_validator("threads", mode="after")
    @classmethod
    def validate_threads(cls, v: int) -> int:
        """Ensure threads is at least 1."""
        if v < 1:
            msg = "threads must be at least 1"
            raise ValueError(msg)
        return v

    @field_validator("connect_retries", mode="after")
    @classmethod
    def validate_connect_retries(cls, v: int) -> int:
        """Ensure connect_retries is non-negative."""
        if v < 0:
            msg = "connect_retries must be non-negative"
            raise ValueError(msg)
        return v

    @model_validator(mode="after")
    def validate_auth_method(self) -> Self:
        """Validate that exactly one authentication method is configured.

        Valid configurations:
        - token alone (PAT)
        - auth_type='oauth' alone (U2M)
        - auth_type='oauth' + client_id + client_secret (M2M AWS/GCP)
        - auth_type='oauth' + azure_client_id + azure_client_secret (M2M Azure)
        """
        has_token = self.token is not None
        has_oauth = self.auth_type == "oauth"
        has_client_creds = self.client_id is not None or self.client_secret is not None
        has_azure_creds = self.azure_client_id is not None or self.azure_client_secret is not None

        # Token-based auth
        if has_token:
            if has_oauth or has_client_creds or has_azure_creds:
                msg = "Cannot use token authentication with OAuth settings"
                raise ValueError(msg)
            return self

        # OAuth-based auth
        if has_oauth:
            # Validate client credentials are complete if provided
            if has_client_creds:
                if not (self.client_id and self.client_secret):
                    msg = "Both client_id and client_secret are required for OAuth M2M (AWS/GCP)"
                    raise ValueError(msg)
                if has_azure_creds:
                    msg = "Cannot mix AWS/GCP and Azure OAuth credentials"
                    raise ValueError(msg)
                return self

            # Validate Azure credentials are complete if provided
            if has_azure_creds:
                if not (self.azure_client_id and self.azure_client_secret):
                    msg = "Both azure_client_id and azure_client_secret are required for OAuth M2M (Azure)"
                    raise ValueError(msg)
                return self

            # U2M OAuth (no credentials needed)
            return self

        # No auth configured - allow this for profiles with env var references
        # The connection test will catch invalid configurations at runtime
        if has_client_creds or has_azure_creds:
            msg = "OAuth credentials require auth_type='oauth'"
            raise ValueError(msg)

        return self

strip_host_protocol(v) classmethod

Strip http:// or https:// prefix from host if present.

Source code in src/brix/modules/dbt/profile/models.py
@field_validator("host", mode="before")
@classmethod
def strip_host_protocol(cls, v: str) -> str:
    """Strip http:// or https:// prefix from host if present."""
    if isinstance(v, str):
        if v.startswith("https://"):
            return v[8:]
        if v.startswith("http://"):
            return v[7:]
    return v

ensure_http_path_starts_with_slash(v) classmethod

Ensure http_path starts with /.

Source code in src/brix/modules/dbt/profile/models.py
@field_validator("http_path", mode="before")
@classmethod
def ensure_http_path_starts_with_slash(cls, v: str) -> str:
    """Ensure http_path starts with /."""
    if isinstance(v, str) and not v.startswith("/"):
        return f"/{v}"
    return v

validate_threads(v) classmethod

Ensure threads is at least 1.

Source code in src/brix/modules/dbt/profile/models.py
@field_validator("threads", mode="after")
@classmethod
def validate_threads(cls, v: int) -> int:
    """Ensure threads is at least 1."""
    if v < 1:
        msg = "threads must be at least 1"
        raise ValueError(msg)
    return v

validate_connect_retries(v) classmethod

Ensure connect_retries is non-negative.

Source code in src/brix/modules/dbt/profile/models.py
@field_validator("connect_retries", mode="after")
@classmethod
def validate_connect_retries(cls, v: int) -> int:
    """Ensure connect_retries is non-negative."""
    if v < 0:
        msg = "connect_retries must be non-negative"
        raise ValueError(msg)
    return v

validate_auth_method()

Validate that exactly one authentication method is configured.

Valid configurations: - token alone (PAT) - auth_type='oauth' alone (U2M) - auth_type='oauth' + client_id + client_secret (M2M AWS/GCP) - auth_type='oauth' + azure_client_id + azure_client_secret (M2M Azure)

Source code in src/brix/modules/dbt/profile/models.py
@model_validator(mode="after")
def validate_auth_method(self) -> Self:
    """Validate that exactly one authentication method is configured.

    Valid configurations:
    - token alone (PAT)
    - auth_type='oauth' alone (U2M)
    - auth_type='oauth' + client_id + client_secret (M2M AWS/GCP)
    - auth_type='oauth' + azure_client_id + azure_client_secret (M2M Azure)
    """
    has_token = self.token is not None
    has_oauth = self.auth_type == "oauth"
    has_client_creds = self.client_id is not None or self.client_secret is not None
    has_azure_creds = self.azure_client_id is not None or self.azure_client_secret is not None

    # Token-based auth
    if has_token:
        if has_oauth or has_client_creds or has_azure_creds:
            msg = "Cannot use token authentication with OAuth settings"
            raise ValueError(msg)
        return self

    # OAuth-based auth
    if has_oauth:
        # Validate client credentials are complete if provided
        if has_client_creds:
            if not (self.client_id and self.client_secret):
                msg = "Both client_id and client_secret are required for OAuth M2M (AWS/GCP)"
                raise ValueError(msg)
            if has_azure_creds:
                msg = "Cannot mix AWS/GCP and Azure OAuth credentials"
                raise ValueError(msg)
            return self

        # Validate Azure credentials are complete if provided
        if has_azure_creds:
            if not (self.azure_client_id and self.azure_client_secret):
                msg = "Both azure_client_id and azure_client_secret are required for OAuth M2M (Azure)"
                raise ValueError(msg)
            return self

        # U2M OAuth (no credentials needed)
        return self

    # No auth configured - allow this for profiles with env var references
    # The connection test will catch invalid configurations at runtime
    if has_client_creds or has_azure_creds:
        msg = "OAuth credentials require auth_type='oauth'"
        raise ValueError(msg)

    return self

ProfileTarget

Bases: BaseModel

A dbt profile with target selection and output configurations.

Source code in src/brix/modules/dbt/profile/models.py
class ProfileTarget(BaseModel):
    """A dbt profile with target selection and output configurations."""

    model_config = ConfigDict(extra="allow")

    target: str
    outputs: dict[str, OutputConfig]

DbtProfiles

Bases: BaseModel

Root model for profiles.yml - a mapping of profile names to configurations.

Source code in src/brix/modules/dbt/profile/models.py
class DbtProfiles(BaseModel):
    """Root model for profiles.yml - a mapping of profile names to configurations."""

    model_config = ConfigDict(extra="allow")

    root: dict[str, ProfileTarget]

    def __getitem__(self, key: str) -> ProfileTarget:
        """Allow dict-like access to profiles."""
        return self.root[key]

    def __contains__(self, key: str) -> bool:
        """Check if profile exists."""
        return key in self.root

    @classmethod
    def from_yaml(cls, content: str) -> DbtProfiles:
        """Parse profiles from YAML string.

        Args:
            content: YAML string content of profiles.yml

        Returns:
            Parsed DbtProfiles instance

        Raises:
            ValueError: If YAML is invalid or doesn't match schema
        """
        import yaml

        try:
            data = yaml.safe_load(content)
        except yaml.YAMLError as e:
            msg = f"Invalid YAML: {e}"
            raise ValueError(msg) from e

        if not isinstance(data, dict):
            msg = "profiles.yml must be a YAML mapping"
            raise ValueError(msg)

        return cls(root=data)

    @classmethod
    def from_file(cls, path: Path) -> DbtProfiles:
        """Load profiles from a file path.

        Args:
            path: Path to profiles.yml file

        Returns:
            Parsed DbtProfiles instance

        Raises:
            FileNotFoundError: If file doesn't exist
            ValueError: If YAML is invalid or doesn't match schema
        """
        content = path.read_text()
        return cls.from_yaml(content)

    def to_yaml(self) -> str:
        """Serialize profiles to YAML string.

        Returns:
            YAML string representation
        """
        import yaml

        # Convert to dict, handling nested models
        # Use by_alias=True to output 'schema' instead of 'schema_'
        data = {name: profile.model_dump(exclude_none=True, by_alias=True) for name, profile in self.root.items()}
        return yaml.dump(data, default_flow_style=False, sort_keys=False)

__getitem__(key)

Allow dict-like access to profiles.

Source code in src/brix/modules/dbt/profile/models.py
def __getitem__(self, key: str) -> ProfileTarget:
    """Allow dict-like access to profiles."""
    return self.root[key]

__contains__(key)

Check if profile exists.

Source code in src/brix/modules/dbt/profile/models.py
def __contains__(self, key: str) -> bool:
    """Check if profile exists."""
    return key in self.root

from_yaml(content) classmethod

Parse profiles from YAML string.

Parameters:

Name Type Description Default
content str

YAML string content of profiles.yml

required

Returns:

Type Description
DbtProfiles

Parsed DbtProfiles instance

Raises:

Type Description
ValueError

If YAML is invalid or doesn't match schema

Source code in src/brix/modules/dbt/profile/models.py
@classmethod
def from_yaml(cls, content: str) -> DbtProfiles:
    """Parse profiles from YAML string.

    Args:
        content: YAML string content of profiles.yml

    Returns:
        Parsed DbtProfiles instance

    Raises:
        ValueError: If YAML is invalid or doesn't match schema
    """
    import yaml

    try:
        data = yaml.safe_load(content)
    except yaml.YAMLError as e:
        msg = f"Invalid YAML: {e}"
        raise ValueError(msg) from e

    if not isinstance(data, dict):
        msg = "profiles.yml must be a YAML mapping"
        raise ValueError(msg)

    return cls(root=data)

from_file(path) classmethod

Load profiles from a file path.

Parameters:

Name Type Description Default
path Path

Path to profiles.yml file

required

Returns:

Type Description
DbtProfiles

Parsed DbtProfiles instance

Raises:

Type Description
FileNotFoundError

If file doesn't exist

ValueError

If YAML is invalid or doesn't match schema

Source code in src/brix/modules/dbt/profile/models.py
@classmethod
def from_file(cls, path: Path) -> DbtProfiles:
    """Load profiles from a file path.

    Args:
        path: Path to profiles.yml file

    Returns:
        Parsed DbtProfiles instance

    Raises:
        FileNotFoundError: If file doesn't exist
        ValueError: If YAML is invalid or doesn't match schema
    """
    content = path.read_text()
    return cls.from_yaml(content)

to_yaml()

Serialize profiles to YAML string.

Returns:

Type Description
str

YAML string representation

Source code in src/brix/modules/dbt/profile/models.py
def to_yaml(self) -> str:
    """Serialize profiles to YAML string.

    Returns:
        YAML string representation
    """
    import yaml

    # Convert to dict, handling nested models
    # Use by_alias=True to output 'schema' instead of 'schema_'
    data = {name: profile.model_dump(exclude_none=True, by_alias=True) for name, profile in self.root.items()}
    return yaml.dump(data, default_flow_style=False, sort_keys=False)

Project Models

brix.modules.dbt.project.models

Pydantic models for dbt project configuration.

These models provide type-safe parsing and validation of dbt_project.yml and packages.yml files.

ProjectNameError

Bases: ValueError

Raised when project name is invalid.

Source code in src/brix/modules/dbt/project/models.py
class ProjectNameError(ValueError):
    """Raised when project name is invalid."""

PackageNameError

Bases: ValueError

Raised when package name is invalid.

Source code in src/brix/modules/dbt/project/models.py
class PackageNameError(ValueError):
    """Raised when package name is invalid."""

DbtProject

Bases: BaseModel

Pydantic model for dbt_project.yml configuration.

Represents the structure and configuration options for a dbt project. Supports YAML serialization via from_yaml() and to_yaml() methods.

Source code in src/brix/modules/dbt/project/models.py
class DbtProject(BaseModel):
    """Pydantic model for dbt_project.yml configuration.

    Represents the structure and configuration options for a dbt project.
    Supports YAML serialization via from_yaml() and to_yaml() methods.
    """

    model_config = ConfigDict(extra="allow", populate_by_name=True)

    # Required fields
    name: str
    profile: str

    # Version fields
    version: str = "1.0.0"
    config_version: Literal[2] = Field(default=2, alias="config-version")

    # Path configurations
    model_paths: list[str] = Field(default=["models"], alias="model-paths")
    seed_paths: list[str] = Field(default=["seeds"], alias="seed-paths")
    test_paths: list[str] = Field(default=["tests"], alias="test-paths")
    macro_paths: list[str] = Field(default=["macros"], alias="macro-paths")
    snapshot_paths: list[str] = Field(default=["snapshots"], alias="snapshot-paths")
    analysis_paths: list[str] = Field(default=["analyses"], alias="analysis-paths")
    asset_paths: list[str] = Field(default=["assets"], alias="asset-paths")

    # Build configuration
    clean_targets: list[str] = Field(default=["target", "dbt_packages"], alias="clean-targets")
    require_dbt_version: str | None = Field(default=None, alias="require-dbt-version")

    # Model defaults (optional)
    models: dict[str, Any] | None = None
    seeds: dict[str, Any] | None = None
    vars: dict[str, Any] | None = None

    @field_validator("name", mode="after")
    @classmethod
    def validate_name(cls, v: str) -> str:
        """Validate project name follows dbt requirements."""
        return validate_project_name(v)

    @classmethod
    def from_yaml(cls, content: str) -> DbtProject:
        """Parse project configuration from YAML string.

        Args:
            content: YAML string content of dbt_project.yml

        Returns:
            Parsed DbtProject instance

        Raises:
            ValueError: If YAML is invalid or doesn't match schema
        """
        try:
            data = yaml.safe_load(content)
        except yaml.YAMLError as e:
            msg = f"Invalid YAML: {e}"
            raise ValueError(msg) from e

        if not isinstance(data, dict):
            msg = "dbt_project.yml must be a YAML mapping"
            raise ValueError(msg)

        return cls(**data)

    @classmethod
    def from_file(cls, path: Path) -> DbtProject:
        """Load project configuration from a file path.

        Args:
            path: Path to dbt_project.yml file

        Returns:
            Parsed DbtProject instance

        Raises:
            FileNotFoundError: If file doesn't exist
            ValueError: If YAML is invalid or doesn't match schema
        """
        content = path.read_text()
        return cls.from_yaml(content)

    def to_yaml(self) -> str:
        """Serialize project configuration to YAML string.

        Returns:
            YAML string representation
        """
        # Convert to dict, using aliases for YAML keys
        data = self.model_dump(exclude_none=True, by_alias=True)
        return yaml.dump(data, default_flow_style=False, sort_keys=False)

validate_name(v) classmethod

Validate project name follows dbt requirements.

Source code in src/brix/modules/dbt/project/models.py
@field_validator("name", mode="after")
@classmethod
def validate_name(cls, v: str) -> str:
    """Validate project name follows dbt requirements."""
    return validate_project_name(v)

from_yaml(content) classmethod

Parse project configuration from YAML string.

Parameters:

Name Type Description Default
content str

YAML string content of dbt_project.yml

required

Returns:

Type Description
DbtProject

Parsed DbtProject instance

Raises:

Type Description
ValueError

If YAML is invalid or doesn't match schema

Source code in src/brix/modules/dbt/project/models.py
@classmethod
def from_yaml(cls, content: str) -> DbtProject:
    """Parse project configuration from YAML string.

    Args:
        content: YAML string content of dbt_project.yml

    Returns:
        Parsed DbtProject instance

    Raises:
        ValueError: If YAML is invalid or doesn't match schema
    """
    try:
        data = yaml.safe_load(content)
    except yaml.YAMLError as e:
        msg = f"Invalid YAML: {e}"
        raise ValueError(msg) from e

    if not isinstance(data, dict):
        msg = "dbt_project.yml must be a YAML mapping"
        raise ValueError(msg)

    return cls(**data)

from_file(path) classmethod

Load project configuration from a file path.

Parameters:

Name Type Description Default
path Path

Path to dbt_project.yml file

required

Returns:

Type Description
DbtProject

Parsed DbtProject instance

Raises:

Type Description
FileNotFoundError

If file doesn't exist

ValueError

If YAML is invalid or doesn't match schema

Source code in src/brix/modules/dbt/project/models.py
@classmethod
def from_file(cls, path: Path) -> DbtProject:
    """Load project configuration from a file path.

    Args:
        path: Path to dbt_project.yml file

    Returns:
        Parsed DbtProject instance

    Raises:
        FileNotFoundError: If file doesn't exist
        ValueError: If YAML is invalid or doesn't match schema
    """
    content = path.read_text()
    return cls.from_yaml(content)

to_yaml()

Serialize project configuration to YAML string.

Returns:

Type Description
str

YAML string representation

Source code in src/brix/modules/dbt/project/models.py
def to_yaml(self) -> str:
    """Serialize project configuration to YAML string.

    Returns:
        YAML string representation
    """
    # Convert to dict, using aliases for YAML keys
    data = self.model_dump(exclude_none=True, by_alias=True)
    return yaml.dump(data, default_flow_style=False, sort_keys=False)

HubPackage

Bases: BaseModel

A package from the dbt Hub (hub.getdbt.com).

Example
  • package: dbt-labs/dbt_utils version: ">=1.0.0"
Source code in src/brix/modules/dbt/project/models.py
class HubPackage(BaseModel):
    """A package from the dbt Hub (hub.getdbt.com).

    Example:
        - package: dbt-labs/dbt_utils
          version: ">=1.0.0"
    """

    model_config = ConfigDict(extra="forbid")

    package: str
    version: str

    @field_validator("package", mode="after")
    @classmethod
    def validate_package_name(cls, v: str) -> str:
        """Validate package name follows hub format."""
        return validate_hub_package_name(v)

validate_package_name(v) classmethod

Validate package name follows hub format.

Source code in src/brix/modules/dbt/project/models.py
@field_validator("package", mode="after")
@classmethod
def validate_package_name(cls, v: str) -> str:
    """Validate package name follows hub format."""
    return validate_hub_package_name(v)

GitPackage

Bases: BaseModel

A package from a Git repository.

Example
  • git: "https://github.com/org/repo.git" revision: main subdirectory: "path/to/dbt_project"
Source code in src/brix/modules/dbt/project/models.py
class GitPackage(BaseModel):
    """A package from a Git repository.

    Example:
        - git: "https://github.com/org/repo.git"
          revision: main
          subdirectory: "path/to/dbt_project"
    """

    model_config = ConfigDict(extra="forbid")

    git: str
    revision: str
    subdirectory: str | None = None

LocalPackage

Bases: BaseModel

A package from the local filesystem.

Example
  • local: ../shared_macros
Source code in src/brix/modules/dbt/project/models.py
class LocalPackage(BaseModel):
    """A package from the local filesystem.

    Example:
        - local: ../shared_macros
    """

    model_config = ConfigDict(extra="forbid")

    local: str

DbtPackages

Bases: BaseModel

Pydantic model for packages.yml configuration.

Represents the list of dbt packages to install.

Source code in src/brix/modules/dbt/project/models.py
class DbtPackages(BaseModel):
    """Pydantic model for packages.yml configuration.

    Represents the list of dbt packages to install.
    """

    model_config = ConfigDict(extra="forbid")

    packages: list[HubPackage | GitPackage | LocalPackage] = Field(default_factory=list)

    @classmethod
    def from_yaml(cls, content: str) -> DbtPackages:
        """Parse packages configuration from YAML string.

        Args:
            content: YAML string content of packages.yml

        Returns:
            Parsed DbtPackages instance

        Raises:
            ValueError: If YAML is invalid or doesn't match schema
        """
        try:
            data = yaml.safe_load(content)
        except yaml.YAMLError as e:
            msg = f"Invalid YAML: {e}"
            raise ValueError(msg) from e

        if data is None:
            return cls(packages=[])

        if not isinstance(data, dict):
            msg = "packages.yml must be a YAML mapping"
            raise ValueError(msg)

        return cls(**data)

    @classmethod
    def from_file(cls, path: Path) -> DbtPackages:
        """Load packages configuration from a file path.

        Args:
            path: Path to packages.yml file

        Returns:
            Parsed DbtPackages instance

        Raises:
            FileNotFoundError: If file doesn't exist
            ValueError: If YAML is invalid or doesn't match schema
        """
        content = path.read_text()
        return cls.from_yaml(content)

    def to_yaml(self) -> str:
        """Serialize packages configuration to YAML string.

        Returns:
            YAML string representation
        """
        data = self.model_dump(exclude_none=True)
        return yaml.dump(data, default_flow_style=False, sort_keys=False)

    def add_hub_package(self, package: str, version: str) -> None:
        """Add a hub package to the list.

        Args:
            package: Package name (e.g., "dbt-labs/dbt_utils")
            version: Version specifier (e.g., ">=1.0.0")
        """
        self.packages.append(HubPackage(package=package, version=version))

    def add_git_package(self, git: str, revision: str, subdirectory: str | None = None) -> None:
        """Add a git package to the list.

        Args:
            git: Git repository URL
            revision: Branch, tag, or commit hash
            subdirectory: Optional subdirectory within repo
        """
        self.packages.append(GitPackage(git=git, revision=revision, subdirectory=subdirectory))

    def add_local_package(self, local: str) -> None:
        """Add a local package to the list.

        Args:
            local: Local filesystem path
        """
        self.packages.append(LocalPackage(local=local))

from_yaml(content) classmethod

Parse packages configuration from YAML string.

Parameters:

Name Type Description Default
content str

YAML string content of packages.yml

required

Returns:

Type Description
DbtPackages

Parsed DbtPackages instance

Raises:

Type Description
ValueError

If YAML is invalid or doesn't match schema

Source code in src/brix/modules/dbt/project/models.py
@classmethod
def from_yaml(cls, content: str) -> DbtPackages:
    """Parse packages configuration from YAML string.

    Args:
        content: YAML string content of packages.yml

    Returns:
        Parsed DbtPackages instance

    Raises:
        ValueError: If YAML is invalid or doesn't match schema
    """
    try:
        data = yaml.safe_load(content)
    except yaml.YAMLError as e:
        msg = f"Invalid YAML: {e}"
        raise ValueError(msg) from e

    if data is None:
        return cls(packages=[])

    if not isinstance(data, dict):
        msg = "packages.yml must be a YAML mapping"
        raise ValueError(msg)

    return cls(**data)

from_file(path) classmethod

Load packages configuration from a file path.

Parameters:

Name Type Description Default
path Path

Path to packages.yml file

required

Returns:

Type Description
DbtPackages

Parsed DbtPackages instance

Raises:

Type Description
FileNotFoundError

If file doesn't exist

ValueError

If YAML is invalid or doesn't match schema

Source code in src/brix/modules/dbt/project/models.py
@classmethod
def from_file(cls, path: Path) -> DbtPackages:
    """Load packages configuration from a file path.

    Args:
        path: Path to packages.yml file

    Returns:
        Parsed DbtPackages instance

    Raises:
        FileNotFoundError: If file doesn't exist
        ValueError: If YAML is invalid or doesn't match schema
    """
    content = path.read_text()
    return cls.from_yaml(content)

to_yaml()

Serialize packages configuration to YAML string.

Returns:

Type Description
str

YAML string representation

Source code in src/brix/modules/dbt/project/models.py
def to_yaml(self) -> str:
    """Serialize packages configuration to YAML string.

    Returns:
        YAML string representation
    """
    data = self.model_dump(exclude_none=True)
    return yaml.dump(data, default_flow_style=False, sort_keys=False)

add_hub_package(package, version)

Add a hub package to the list.

Parameters:

Name Type Description Default
package str

Package name (e.g., "dbt-labs/dbt_utils")

required
version str

Version specifier (e.g., ">=1.0.0")

required
Source code in src/brix/modules/dbt/project/models.py
def add_hub_package(self, package: str, version: str) -> None:
    """Add a hub package to the list.

    Args:
        package: Package name (e.g., "dbt-labs/dbt_utils")
        version: Version specifier (e.g., ">=1.0.0")
    """
    self.packages.append(HubPackage(package=package, version=version))

add_git_package(git, revision, subdirectory=None)

Add a git package to the list.

Parameters:

Name Type Description Default
git str

Git repository URL

required
revision str

Branch, tag, or commit hash

required
subdirectory str | None

Optional subdirectory within repo

None
Source code in src/brix/modules/dbt/project/models.py
def add_git_package(self, git: str, revision: str, subdirectory: str | None = None) -> None:
    """Add a git package to the list.

    Args:
        git: Git repository URL
        revision: Branch, tag, or commit hash
        subdirectory: Optional subdirectory within repo
    """
    self.packages.append(GitPackage(git=git, revision=revision, subdirectory=subdirectory))

add_local_package(local)

Add a local package to the list.

Parameters:

Name Type Description Default
local str

Local filesystem path

required
Source code in src/brix/modules/dbt/project/models.py
def add_local_package(self, local: str) -> None:
    """Add a local package to the list.

    Args:
        local: Local filesystem path
    """
    self.packages.append(LocalPackage(local=local))

validate_project_name(name)

Validate a dbt project name.

Parameters:

Name Type Description Default
name str

Project name to validate

required

Returns:

Type Description
str

The validated project name

Raises:

Type Description
ProjectNameError

If name doesn't match dbt requirements

Source code in src/brix/modules/dbt/project/models.py
def validate_project_name(name: str) -> str:
    """Validate a dbt project name.

    Args:
        name: Project name to validate

    Returns:
        The validated project name

    Raises:
        ProjectNameError: If name doesn't match dbt requirements
    """
    if not PROJECT_NAME_PATTERN.match(name):
        msg = (
            f"Invalid project name: '{name}'. "
            "Project name must start with a letter or underscore and contain only "
            "alphanumeric characters and underscores."
        )
        raise ProjectNameError(msg)
    return name

validate_hub_package_name(name)

Validate a dbt hub package name.

Parameters:

Name Type Description Default
name str

Package name to validate (e.g., "dbt-labs/dbt_utils")

required

Returns:

Type Description
str

The validated package name

Raises:

Type Description
PackageNameError

If name doesn't match hub package format

Source code in src/brix/modules/dbt/project/models.py
def validate_hub_package_name(name: str) -> str:
    """Validate a dbt hub package name.

    Args:
        name: Package name to validate (e.g., "dbt-labs/dbt_utils")

    Returns:
        The validated package name

    Raises:
        PackageNameError: If name doesn't match hub package format
    """
    if not HUB_PACKAGE_PATTERN.match(name):
        msg = (
            f"Invalid hub package name: '{name}'. "
            "Package name must be in 'namespace/package' format "
            "(e.g., 'dbt-labs/dbt_utils')."
        )
        raise PackageNameError(msg)
    return name