I'm using Dagster with DBT and i was wondering how...
# ask-community
f
I'm using Dagster with DBT and i was wondering how can i run a custom command , i'm talking about this : https://docs.dagster.io/_apidocs/libraries/dagster-dbt#resources-dbt-core let's say i want to run the command
build
from dbt using the dbt cli ressource . i understood that if i want to do an
@op
i can pass a
context
parameter to use it in the function . i tried this but it doesn't work
Copy code
resources = {
    "dbt": dbt_cli_resource.configured(
        {
            "project_dir": DBT_PROJECT_PATH,
            "profiles_dir": DBT_PROFILES,
        },
    )
}


@op(required_resource_keys={"dbt"})
def custom_run(context):
    context.build(models=["mymodel"])
The end goal is to do a custom
dbt build --select mymodel+
dagster bot responded by community 1
🤖 1
g
Hi! The op context object provides access to all of your op config and resources so you need to specify that you want to access the dbt resource. Assuming the rest of the code is correct (I don’t know enough to verify your kwargs in the build call) the correct way to call is:
Copy code
@op(required_resource_keys={"dbt"})
def custom_run(context):
    context.resources.dbt.build(models=["mymodel"])
f
Indeed i was missing this resource_key . thank you very much.
g
No problem! Always happy to help daggy love