How to access/transform task returned data before ...
# ask-community
a
How to access/transform task returned data before sending it to another task i.e. Thanks in advance!
Copy code
with prefect.Flow('myflow') as flow:
    task_1 = my_task_1()
    task_2 = my_task_2(task_1['value'])
z
Hey @Ahmed Ezzat - this will just work. We'll automatically generate a task to access the
"value"
key for you here.
You can't perform any transformations in the flow block and you need an intermediate task to do so. However, we will generate those intermediate tasks in some common cases .
a
Hi @Zanie Is there any workaround for applying transformations? i.e. not using a flow block or some other way?
z
Is there a reason you don't want to use tasks?
a
@Zanie It's just will result in a messy code. I'm ok with creating extra tasks however I want to access return values cleanly. My current Idea is to return a class then access its field. Is this implemented natively or I'll need to hack my way?
k
I don’t think you can do this. The reason
task['value']
works is because Prefect uses a
GetItem
task under the hood when you call that. You will need to use a task for deferred execution. Accessing the class field will try to run during the build time, so no native way to immediate do it