How do I define dependencies between jobs? #16143
-
I have two jobs, and I want to run one after the other. How do I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You can use sensors, specifically If you have two jobs, @run_status_sensor(
run_status=DagsterRunStatus.SUCCESS,
monitored_jobs=[job_1]
request_job=job_2,
)
def run_job_2_sensor(context):
return RunRequest(run_key=None, run_config=run_config) Note that this kind of dependency is only an ordering dependency - it ensures that |
Beta Was this translation helpful? Give feedback.
-
Another option is to write both jobs as @op
def op1():
return 1
@op
def op2(x):
return x + 1
@graph
def graph_1():
res = op2(op1())
return {
"result": res
}
@graph
def graph_2(x):
op2(x)
@job
def job_1():
graph_2(graph_1()) |
Beta Was this translation helpful? Give feedback.
You can use sensors, specifically
run_status_sensor
s to accomplish this. Relevant documentation can be found here: https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors#run-status-sensorsIf you have two jobs,
job_1
andjob_2
and you want to runjob_2
wheneverjob_1
has run and succeeded, you can write arun_status_sensor
like this:Note that this kind of dependency is only an ordering dependency - it ensures that
job_2
will be run every timejob_1
succeeds. You won't b…