https://dagster.io/ logo
Title
p

Prratek Ramchandani

01/05/2022, 11:13 PM
i’m generating dagster jobs with a function (call in
make_job()
and am running into some trouble. i have a number of dagster jobs that vary only in resource config and so i have a python function that returns a
JobDefinition
to create them. since the graph for each job is identical i have one graph defined using the
@graph
decorator that gets calls in my
make_job()
function but dagster doesn’t like that i now have multiple graphs with the same name. i figured i’d name the graph using the “configured” API but looks like that requires that i also pass in config, which the graph doesn’t need. is there another way to name these graphs?
c

claire

01/05/2022, 11:15 PM
Hi Prratek, you can specify a name in the name parameter of the graph:
@graph(name="foo")
def my_graph:
  ...
If you want to create multiple different jobs from the same graph, you can specify a name in the
to_job
method:
my_graph.to_job(name="foo")
p

Prratek Ramchandani

01/05/2022, 11:18 PM
sorry should have clarified - the graph itself is identical so i have multiple jobs, varying only in config, that use the same graph. this example in the hacker news project is a good one. what if i wanted to use that graph in multiple different jobs? the graph itself is unaware of the job it’s going to be used in so i can’t name it at time of definition
ah okay the
to_job()
method sounds like what i want
i assumed that names the job which is different from naming the graph
c

claire

01/05/2022, 11:19 PM
Yep, that's correct! You can also pass your config into the
to_job
function
p

Prratek Ramchandani

01/05/2022, 11:20 PM
okay yeah perfect i’m already using
to_job()
to pass config so this works. thanks!
:dagsir: 1