Hi team. Quick question. If I define two jobs (as...
# ask-community
h
Hi team. Quick question. If I define two jobs (as shown below) how do combine them so that they can be imported into my repo.py and executed one after another?
Copy code
# This is the job to run first
@job(...)
def run_first():
    dbt_seed_op()

# This is the job to run second
run_second = AssetGroup(...).build_job("run_second")
When I try the following pattern I get an error:
Copy code
@job
def combined_job():
    run_second(run_first())
>>>

dagster.core.errors.DagsterInvariantViolationError: Attempted to call job 'combined_job' directly. Jobs should be invoked by using an execution API function (e.g. `job.execute_in_process`).
I could not find an example of the
job.execute_in_process
method in the docs. Does anyone know how to get around this?
c
You can't invoke jobs to be run within other jobs - perhaps what you want is to have
run_first
and
run_second
be graphs, and then orchestrate them within the same graph?
Copy code
@graph
def run_first():
    dbt_seed_op()

@graph
def run_second():
    ...

@job
def combined_job():
    run_second(run_first())
If you need
run_first
and
run_second
to be different jobs for whatever reason, then you can set up
run_second
to be triggered by
run_first
by a sensor.