Daniel Nilsen

02/17/2022, 12:47 PM
I have a task that is returning an object with attribute
. But when I try to access this in the flow I get
'FunctionTask' object has no attribute 'data'
. How do I access the
Copy code
with Flow('data_transformation') as flow:
     response = myTask() //error

Anna Geller

02/17/2022, 12:53 PM
Your task would need to return 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 you intended to print this to the console, you would need to wrap it into a task, like so:
Copy code
def print_response_data(response):

Daniel Nilsen

02/17/2022, 1:29 PM
ah nice, thanks!
👍 1