Ismael Rodrigues
02/21/2023, 5:43 AM@op(out={"result": Out(dict)})
def my_op():
... stuff
return Output(result_dict, "result")
then on the job
@job
def my_job():
result = my_op()
another_op(result.get('field1'), result.get('field2'), result.get('field3'))
Mark
02/21/2023, 7:40 AM@op(out={"result": Out(dict)})
def my_op():
result_dict = {"field1": "value1", "field2": "value2", "field3": "value3"}
return Output(result_dict, "result")
@op
def another_op(context, result_dict):
<http://context.log.info|context.log.info>(result_dict.get("field1"))
<http://context.log.info|context.log.info>(result_dict.get("field2"))
<http://context.log.info|context.log.info>(result_dict.get("field3"))
@job
def my_job():
result = my_op()
another_op(result)
Ismael Rodrigues
02/21/2023, 3:54 PMZach
02/21/2023, 4:31 PMmy_op
, something like
@op(out={"result": Out(dict)})
def my_op():
... stuff
yield Output(result_dict.get("field1"), "result1")
yield Output(result_dict.get("field2"), "result2")
yield Output(result_dict.get("field3"), "result3")
@job
def my_job():
result1, result2, result3 = my_op()
another_op(result1, result2, result3)
the problem you're running into is that the code within the @job job definition is only executed when your code is initially loaded by Dagster in order to compile the DAG - it isn't run when you execute the graph. this means you can't use general-purpose python code that accesses the results that are produced at runtime from within a @job or @graph definition.Ismael Rodrigues
02/21/2023, 4:35 PM