super basic question but how do I access the resul...
# ask-community
a
super basic question but how do I access the result of a mapped task from the
state = flow.run()
object? I always get a
KeyError
when trying to do
state.result[mapped_task].result
but
state.result[not_mapped_task].result
works fine
z
Hi @An Hoang this has to do with the internals of
flow.run()
. In general, we haven't had users ask to include mapped task states in the return value of
flow.run()
. If this is essential to your workflow, I'd suggest opening a GitHub issue for an enhancement. Is there something specific you're trying to do in accessing the mapped result? Happy to help out with workarounds
a
Hi @Zach Angell ! For me checking the
state.result
for each task is just bread and butter in developing and debugging flows, even more so when they are mapped. When I have a downstream reducing task that gathers mapped results into a list, I would like to see what the gathered input looks like since alot of the times the error happen when what I expect doesn't match what the result is. I usually have to do
list(state.result.items())[-2][1]
(-2 is the index from manually looking at
state.result
), which is a bit cumbersome. It'd be great if we can do the same introspection as unmapped tasks!
👍 1
z
@Marvin open "Add mapped tasks to the return state of flow.run()"
z
Makes sense, thanks for bringing this up! I've opened a GitHub issue for this. The change actually should be pretty straightforward, happy to point you in the right direction if you want to take a shot at contributing 🙂