I have a task that is returning an object with attribute
data
. But when I try to access this in the flow I get
'FunctionTask' object has no attribute 'data'
. How do I access the response.data?
Copy code
with Flow('data_transformation') as flow:
response = myTask()
response.data //error
a
Anna Geller
02/17/2022, 12:53 PM
Your task would need to return response.data instead of just response. The problem you see is related to what Prefect interprets at build time (during registration) vs. at runtime. Everything in the Flow block is interpreted at build time, while data dependencies are passed between tasks at runtime. So if your task returns the data instead of response, this should fix your issue.
Also, if by doing response.data you intended to print this to the console, you would need to wrap it into a task, like so:
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.