Hello :wave: I’m trying to set up dagster to be a...
# integration-dbt
o
Hello 👋 I’m trying to set up dagster to be able to run dbt both as scheduled jobs and ad hoc. For the latter I want to be able to pass any dbt CLI flags (such as
--full-refresh
) to any arbitrary selection of models, all of which are loaded as software defined assets using the
@dbt_assets
decorator. What’s the recommended way of accomplishing this? I can set up a custom op with a config that accepts the flags, but if I understand correctly then that won’t be connecting the assets with the execution, so the asset metadata won’t update - is that right?
🤖 1
r
You can add configuration to
@dbt_assets
if you use pythonic configuration: https://docs.dagster.io/concepts/configuration/config-schema
o
Ah, I see - I was able to get it to work by adding the config to the
dbt_assets
decorated function as an argument, turns out I didn’t have to go down the route of configuring the resource itself Thanks!
👌 1
j
@rex, how I include a configuration if I use an AutoMaterialize policy to materialize the dbt assets? I set it up like this but I can't figured out where to reference the yaml file with my config values
Copy code
@dbt_assets(manifest=manifest, select="*")
def general_dbt_assets(context: OpExecutionContext, dbt: DbtCli, config: DbtConfig):

    vars = {"tags": config.tags}

    yield from dbt.cli(
        args=["build", "--vars", json.dumps(vars)], manifest=manifest, context=context
    ).stream()
Thanks
r
You can configure auto-materialization + freshness policies using the dbt `meta`: we have docs on the way that explain this.
j
Thanks for your answer. Maybe I wasn't clear in my question but I would like to include config values that are coming from a yaml file in my dbt models. For my other Dagster jobs I provide the path to the yaml file for the "config" parameter but in this case I don't where to mention that path since I will auto materialize my dbt assets (i.e. no job creation is needed)
r
I don’t believe that auto-materialization supports passing config into the asset materialization right now — cc @owen @johann
o
hi @Julien DEBLANDER -- will this config path be the same every time, or would it be changing? If changing, what situations would cause this path to change (in an auto-materializing context)? If the path is always the same, another option might be to load that yaml config within the body of your dbt assets, or define a custom config object that contains the default values you're interested in
j
Hi @owen, the path will be always the same. I was thinking to load the yaml within the body of the dbt assets but I was wondering if there is a neater way to load a config file. For now I will do it that way, thanks!
🌈 1