In dagster, I have defined two operations, op1 and...
# ask-community
In dagster, I have defined two operations, op1 and op2. In op1, I have computed a certain piece of data and I want to save it to the context. Then, in op2, I want to retrieve that data from the context. How can I do this?
dagster bot responded by community 1
usually you would model this using inputs and outputs. the context is essentially immutable and won't maintain state because a new context is instantiated for each step
@Zach Thank you for your reply. The scenario I imagine is that some operation in job1 needs to call the result of some operations in job2. Since data can't be passed through the context, are there any recommended solutions?
If those are two separate jobs you need to save those data anywhere. there is no possibility to pas the data from one job to another. Maybe you should remodel your solution to have one job instead of two? Don't know what is your use case...
Can’t op1 just call op2 as a function? As in:
Copy code
def do_op_1(v):
     r = do_something_with(v)
     return r

def do_op_2(i):
     result = do_op_1(i)
You make a good point, I will write both operations into one job.
❤️ 1