Skip to content

How do I pass a configuration value to multiple ops in a job? (job-level config) #3213

Answered by zyd14
sryza asked this question in Q&A
Discussion options

You must be logged in to vote

@yuhan - it seems like this might be a better answer moving forward (1.5.8+):

from dagster import ConfigurableResource, op, graph, RunConfig, OpExecutionContext


class MyConfig(ConfigurableResource):
    val: str = "default"


@op()
def foo(context: OpExecutionContext, config_resource: MyConfig):
    context.log.info(config_resource.val)


@op()
def bar(context: OpExecutionContext, config_resource: MyConfig):
    context.log.info(config_resource.val)


@graph
def my_graph():
    foo()
    bar()


my_job = my_graph.to_job(
    resource_defs={"config_resource": MyConfig(val="blah")},
)

Replies: 5 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@yuhan
Comment options

@craustin
Comment options

@zyd14
Comment options

@craustin
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by yuhan
Comment options

You must be logged in to vote
3 replies
@skeller88
Comment options

@skeller88
Comment options

@zyd14
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: config Related to Configuration area: resource Related to Resources area: ops/graphs/jobs Related to Dagster ops, graphs and jobs
6 participants