Hi, what is the correct way to pass a `--full-refr...
# integration-dbt
m
Hi, what is the correct way to pass a
--full-refresh
flag via the LaunchPad configuration for the new dbt Resource questiongif I would like to run that against a specific dbt model. The old resource had a
full_refresh
flag that could be set to
True
Passing it to the
global_config_flags
does not work as the CLI command becomes
dbt --full-refresh run …..
which is incorrect syntax and raises an error from the dbt CLI
a
See the example use of pythonic
Config
in the API reference:
Copy code
from pathlib import Path

from dagster import Config, OpExecutionContext
from dagster_dbt import DagsterDbtTranslator, DbtCliResource, dbt_assets


class MyDbtConfig(Config):
    full_refresh: bool


@dbt_assets(manifest=Path("target", "manifest.json"))
def my_dbt_assets(context: OpExecutionContext, dbt: DbtCliResource, config: MyDbtConfig):
    dbt_build_args = ["build"]
    if config.full_refresh:
        dbt_build_args += ["--full-refresh"]

    yield from dbt.cli(dbt_build_args, context=context).stream()
You can provide a default of
False
here as well and only override manually from the launchpad
🙌 1
d
you can probably customize the dbt resource with something like this
Copy code
class DbtCustomCliResource(DbtCliResource):
    full_refresh: bool = False

    def cli(self, args: List[str], *, context: Optional[OpExecutionContext] = None):

        if self.full_refresh:
            args = [*args, "--full-refresh"]

        return super().cli(args=args, context=context)
🙌 1
s
Here's a discussion with an answer: https://github.com/dagster-io/dagster/discussions/8873 cc @rex in case the discussion needs an update with the latest changes