Is it possible to define resource definitions at t...
# ask-community
b
Is it possible to define resource definitions at the
graph
level? I have
ops
that have a shared config. I'm using
make_value_resources
to define this config. My ultimate goal is to have one reusable graph template, produce different graphs base on my resource configs, and calling all those graphs in a
job
. Is this possible or is there a better way to approach?
c
Not currently possible to define resources at the graph level - only at the job level. What you could do here however, is for each graph you create using the template, set a different required resource key depending on the graph's name that you can use to uniquely specify the config requirements for that graph. For example:
Copy code
def graph_template(graph_name: str):
    @op(required_resource_keys={f"{graph_name}_config"})
    def the_op(context):
        ...
    
    @graph
    def the_graph():
        the_op()
    
    return the_graph
Then in your job, you would specify the particular config resource uniquely for each templated graph