dbt CLI
Invoke various dbt CLI commands needed for hooks to function and return their results.
Functions
|
Gets the default args to give to all commands. |
|
Clean the configured paths i.e. run the |
|
Generate and return the dbt catalog for a project i.e. run the |
|
Get the dbt config for the current runtime. |
|
Generate and return the dbt manifest for a project i.e. run the |
|
Get the result of a dbt invocation with the given |
|
Install additional dbt dependencies i.e. run the |
|
Load an artifact from the currently configured dbt target directory. |
- dbt_contracts.dbt_cli.get_config(args: Namespace) RuntimeConfig
Get the dbt config for the current runtime. The runtime config can be used to extract common dbt args for the current runtime e.g. project_dir, profiles_dir, target_dir etc.
- Parameters:
args – The parsed CLI args.
- Returns:
The runtime config.
- dbt_contracts.dbt_cli.add_default_args(*args: str, config: RuntimeConfig | Namespace | None = None) list[str]
Gets the default args to give to all commands.
- Parameters:
config – The runtime config to use for default args.
- Returns:
The formatted CLI args.
- dbt_contracts.dbt_cli.load_artifact(filename: str, config: RuntimeConfig | Namespace) Mapping[str, Any] | None
Load an artifact from the currently configured dbt target directory.
- Parameters:
filename – The filename of the artifact to load.
config – The runtime config to use when trying to load the artifact from the target path.
- Returns:
The loaded artifact if found. None otherwise.
- dbt_contracts.dbt_cli.get_result(*args, runner: dbtRunner = None) dbtRunnerResult
Get the result of a dbt invocation with the given
argsandkwargsagainst a givenrunner.- Parameters:
runner – The
dbtRunnerto invoke commands against. If None, creates a new runner for this invocation.args – Args to pass to the
runner.
- Returns:
The result from the invocation.
- dbt_contracts.dbt_cli.clean_paths(*args, runner: dbtRunner = None, config: RuntimeConfig | Namespace = None) None
Clean the configured paths i.e. run the
dbt cleancommand.- Parameters:
runner – The
dbtRunnerto invoke commands against. If None, creates a new runner for this invocation.config – The runtime config to use.
args – Args to pass to the
runner.
- dbt_contracts.dbt_cli.install_dependencies(*args, runner: dbtRunner = None, config: RuntimeConfig | Namespace = None) None
Install additional dbt dependencies i.e. run the
dbt depscommand.- Parameters:
runner – The
dbtRunnerto invoke commands against. If None, creates a new runner for this invocation.config – The runtime config to use.
args – Args to pass to the
runner.
- dbt_contracts.dbt_cli.get_manifest(*args, runner: dbtRunner = None, config: RuntimeConfig | Namespace = None, refresh: bool = False, logger: Logger = None) Manifest
Generate and return the dbt manifest for a project i.e. run the
dbt parsecommand.- Parameters:
runner – The
dbtRunnerto invoke commands against. If None, creates a new runner for this invocation.config – The runtime config to use.
args – Args to pass to the
runner.refresh – Ignore any stored artifacts and generate a new manifest.
logger – The logger to use for logging.
- Returns:
The manifest.
- dbt_contracts.dbt_cli.get_catalog(*args, runner: dbtRunner = None, config: RuntimeConfig | Namespace = None, refresh: bool = False, logger: Logger = None) CatalogArtifact
Generate and return the dbt catalog for a project i.e. run the
dbt docs generatecommand.- Parameters:
runner – The
dbtRunnerto invoke commands against. If None, creates a new runner for this invocation.config – The runtime config to use.
args – Args to pass to the
runner.refresh – Ignore any stored artifacts and generate a new manifest.
logger – The logger to use for logging.
- Returns:
The catalog.