I have a task that is returning an object with att...
# ask-community
d
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
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:
Copy code
@task(log_stdout=True)
def print_response_data(response):
    print(response.data)
d
ah nice, thanks!
👍 1