https://dagster.io/ logo
Title
l

Leigh Stoller

02/08/2023, 7:52 PM
Hi. So I need this resource in every op. How do I do this without having to specify it in every op, but in the job definition instead? I think this is possible, but I cannot find a specification in the documentation for exactly what the job config looks like. Thanks!
:dagster-bot-resolve: 1
s

sean

02/10/2023, 3:56 PM
Hi Leigh, thanks for the question-- relevant docs here: https://docs.dagster.io/concepts/resources#using-resources-with-ops You’ll need to specify the resource key for each op, but the resource definition need only be passed to the job:
@op(required_resource_keys={"foo_resource"})
def foo_op(context):
    return context.resources.foo_resource

@op(required_resource_keys={"foo_resource"})
def bar_op(context, foo):
    return foo + context.resources.foo_resource

@job(resource_defs={"foo_resource": foo_resource})
def foo_graph():
    bar_op(foo_op())
l

Leigh Stoller

02/10/2023, 4:11 PM
Yep, I read that. Thanks. I think its a bit unwieldy for a job with lots of ops, but okay. Also, where is the precise description of the job decorator configuration (the schema). I’ve resorted to passing in what I know is invalid so I can see it in the error handler. 🙂
s

sean

02/10/2023, 4:12 PM
l

Leigh Stoller

02/10/2023, 4:13 PM
Yes, notice the “config” has no definition of the schema.
s

sean

02/13/2023, 10:16 PM
Ah I see what you mean-- that’s an oversight, we have this elsewhere in our docs, or it at least used to render. I’ve created an issue and will investigate. Thanks for the feedback! https://github.com/dagster-io/dagster/issues/12316