Hi. So I need this resource in every op. How do I ...
# ask-community
l
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!
🤖 1
s
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:
Copy code
@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
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
l
Yes, notice the “config” has no definition of the schema.
s
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