https://dagster.io/ logo
#ask-community
Title
# ask-community
u

马钰鹏

01/30/2023, 2:25 AM
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
z

Zach

01/30/2023, 4:13 AM
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
u

马钰鹏

01/30/2023, 7:29 AM
@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?
j

Jakub Zgrzebnicki

01/30/2023, 10:05 AM
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...
f

Fraser Marlow

01/30/2023, 4:24 PM
Can’t op1 just call op2 as a function? As in:
Copy code
@op
def do_op_1(v):
     r = do_something_with(v)
     return r

@op
def do_op_2(i):
     result = do_op_1(i)
u

马钰鹏

01/31/2023, 5:57 AM
You make a good point, I will write both operations into one job.
❤️ 1
2 Views