https://prefect.io logo
s

Sanjay Patel

06/09/2020, 1:30 AM
Hi, I'm using mapped tasks to run a flow locally using output = flow.run(). My mapped task calls have outputs (which should be an array based on what I'm passing in). Can i please get some assistance with accessing the array outputs from each mapped task call after I've run flow.run() when my result handler looks something like this attached screenshot? The data I need is circled at the bottom but I can't work out the syntax needed to get through the <Task: Save Sim Data> section. Thanks
👀 1
n

nicholas

06/09/2020, 1:46 AM
Hi @Sanjay Patel! I think you can use something like this:
Copy code
output.result[<task_ref>].result
where
<task_ref>
is the reference to the task you defined in your flow. In a simple flow:
Copy code
import prefect
from prefect import Flow, task

@task
def my_task()
  return [1, 2, 3]

with Flow("my-flow") as flow:
  my_task_result = my_task()

output = flow.run()

# this is the result of my_task
output.result[my_task_result].result
Let me know if I understood your question correctly!
s

Sanjay Patel

06/09/2020, 1:53 AM
yep, question understood exactly thanks. I'm calling it from a different location so just trying to access that my_task_result again. I'm trying it now. Thanks
👍 1
@nicholas ok, so I have two problems. 1. I don't have access to
my_task_result
, all I have saved is the
flow
and I run it in a different location. Is it possible to access the
my_task_result
from the
flow
object without it having been run? 2. Which may become clearer after #1 but I'm also using my_task.mapped() so I have an array
n

nicholas

06/09/2020, 2:33 AM
Gotcha @Sanjay Patel - you could try something like this:
Copy code
for ref in flow.get_tasks():
  print(output.result[ref].result)
and then further filter out the results you don't want
s

Sanjay Patel

06/09/2020, 3:08 AM
got it, that worked for now. thank you so much!
n

nicholas

06/09/2020, 3:16 AM
Great! 😄