Back to Prefect

base

docs/integrations/prefect-dbt/api-ref/prefect_dbt-cli-configs-base.mdx

3.6.30.dev36.8 KB
Original Source

prefect_dbt.cli.configs.base

Module containing models for base configs

Classes

DbtConfigs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L14" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Abstract class for other dbt Configs.

Attributes:

  • extras: Extra target configs' keywords, not yet exposed in prefect-dbt, but available in dbt; if there are duplicate keys between extras and TargetConfigs, an error will be raised.

Methods:

get_configs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L99" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
get_configs(self) -> dict[str, Any]

Returns the dbt configs, likely used eventually for writing to profiles.yml.

Returns:

  • A configs JSON.

BaseTargetConfigs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L109" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Methods:

get_configs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L99" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
get_configs(self) -> dict[str, Any]

Returns the dbt configs, likely used eventually for writing to profiles.yml.

Returns:

  • A configs JSON.

handle_target_configs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L128" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
handle_target_configs(cls, v: Any) -> Any

Handle target configs field aliasing during validation

TargetConfigs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L140" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Target configs contain credentials and settings, specific to the warehouse you're connecting to. To find valid keys, head to the Available adapters page and click the desired adapter's "Profile Setup" hyperlink.

Attributes:

  • type: The name of the database warehouse.
  • schema: The schema that dbt will build objects into; in BigQuery, a schema is actually a dataset.
  • threads: The number of threads representing the max number of paths through the graph dbt may work on at once.

Examples:

Load stored TargetConfigs:

python
from prefect_dbt.cli.configs import TargetConfigs

dbt_cli_target_configs = TargetConfigs.load("BLOCK_NAME")

Methods:

from_profiles_yml <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L169" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
from_profiles_yml(cls: Type[Self], profile_name: Optional[str] = None, target_name: Optional[str] = None, profiles_dir: Optional[str] = None, allow_field_overrides: bool = False) -> 'TargetConfigs'

Create a TargetConfigs instance from a dbt profiles.yml file.

Args:

  • profile_name: Name of the profile to use from profiles.yml. If None, uses the first profile.
  • target_name: Name of the target to use from the profile. If None, uses the default target in the selected profile.
  • profiles_dir: Path to the directory containing profiles.yml. If None, uses the default profiles directory.
  • allow_field_overrides: If enabled, fields from dbt target configs will override fields provided in extras and credentials.

Returns:

  • A TargetConfigs instance populated from the profiles.yml target.

Raises:

  • ValueError: If profiles.yml is not found or if profile/target is invalid

handle_target_configs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L128" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
handle_target_configs(cls, v: Any) -> Any

Handle target configs field aliasing during validation

GlobalConfigs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L247" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Global configs control things like the visual output of logs, the manner in which dbt parses your project, and what to do when dbt finds a version mismatch or a failing model. Docs can be found here.

Attributes:

  • send_anonymous_usage_stats: Whether usage stats are sent to dbt.
  • use_colors: Colorize the output it prints in your terminal.
  • partial_parse: When partial parsing is enabled, dbt will use an stored internal manifest to determine which files have been changed (if any) since it last parsed the project.
  • printer_width: Length of characters before starting a new line.
  • write_json: Determines whether dbt writes JSON artifacts to the target/ directory.
  • warn_error: Whether to convert dbt warnings into errors.
  • log_format: The LOG_FORMAT config specifies how dbt's logs should be formatted. If the value of this config is json, dbt will output fully structured logs in JSON format.
  • debug: Whether to redirect dbt's debug logs to standard out.
  • version_check: Whether to raise an error if a project's version is used with an incompatible dbt version.
  • fail_fast: Make dbt exit immediately if a single resource fails to build.
  • use_experimental_parser: Opt into the latest experimental version of the static parser.
  • static_parser: Whether to use the static parser.

Examples:

Load stored GlobalConfigs:

python
from prefect_dbt.cli.configs import GlobalConfigs

dbt_cli_global_configs = GlobalConfigs.load("BLOCK_NAME")

Methods:

get_configs <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L99" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
get_configs(self) -> dict[str, Any]

Returns the dbt configs, likely used eventually for writing to profiles.yml.

Returns:

  • A configs JSON.

MissingExtrasRequireError <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cli/configs/base.py#L355" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>