https://dagster.io/ logo
Title
c

Cezary Pukownik

12/28/2021, 8:35 AM
Hi everyone! Is there an option to configure a
dbt_resource
in job config, eg. in dagit? In documentation I've seen only in code configuration using
dbt_cli_resource.configured
method. But this requires to set some configs inside the code. I want to set
project_dir
and
dbt_executable
outside of code, to have an option to switch between dev and prod envs without chaning code.
p

prha

12/29/2021, 10:56 AM
Hi Cezary. I think you should be able to omit the
configured
portion of the
dbt_cli_resource
, but that does mean that you will need to fill in the appropriate section of config at the job level. For example:
# run config yaml
resources:
  my_dbt_resource:
    config:
      project_dir: "my/project/dir"
      dbt_executable: "my/dbt/executable"
😛artydagster: 1
1
If you wanted to provide default values for this config, you could pass that into the
config
argument for the job itself, and then override as needed in dagit.
c

Cezary Pukownik

12/29/2021, 2:23 PM
Thank you so much! This is exactly what I was looking for! 😀 In code I've passed
dbt_cli_recource
from
dagster_dbt
directly into
resource_defs
in
to_job
graph method.
# my_graph.py
from dagster_dbt import dbt_cli_resource

@op(required_resource_keys={"my_dbt_resource"})
def dbt_run(context):
    context.resources.my_dbt_resource.run()

@graph
def my_graph():
    dbt_run()

my_job = my_graph.to_job(
    resource_defs={
        'my_dbt_resource': dbt_cli_resource
    }
)

# config yml:
resources:
  my_dbt_resource:
    config:
      project_dir: "my/project/dir"
      dbt_executable: "my/dbt/executable"
y

yuhan

06/22/2022, 4:00 AM
@Dagster Bot discussion Configure
dbt_resource
in job config
d

Dagster Bot

06/22/2022, 4:00 AM
Question in the thread has been surfaced to GitHub Discussions for future discoverability: https://github.com/dagster-io/dagster/discussions/8543