Skip to content

How do I define a method using dbt.cli that executes run-operation stage_external_sources? #21457

Answered by Iuke
Iuke asked this question in Q&A
Discussion options

You must be logged in to vote

My teammate @emilee-jurkowski found this related issue and implemented your method and added the out arg.

@op(required_resource_keys={"dbt"}, out=Out(Nothing))
def dbt_run_operation(context: OpExecutionContext, operation_name: str):
    dbt_operation_cmd = ["run-operation", operation_name]
    yield from context.resources.dbt.cli(dbt_operation_cmd).stream()

I would encourage other people who stumble across this discussion to explore different out returns if you need some logging but I think this is good enough for what we need.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Iuke
Comment options

Comment options

You must be logged in to vote
1 reply
@Iuke
Comment options

Answer selected by Iuke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
integration: dbt Related to dagster-dbt
3 participants