I keep getting these "object type 'coroutine' has ...
# ask-community
j
I keep getting these "object type 'coroutine' has no attribute _______" messages whenever I try to follow the python API documentation. Is there a way to work around this? Spyder has the best variable explorer of the Python IDEs, which makes it ideal for data science, but I'm getting different behavior on the same script, in the same environment, between pycharm and spyder. I'd really love to find a workaround for spyder, because as someone who inspects data coming back from new systems and APIs all the time, I like being able to inspect the structure of those with Spyder's great little variable explorer. It's the closest thing we have to RStudio in the python world (RIP yhat rodeo)
t
I have not used spyder previously, so I am not entirely sure what you mean by "has no attribute "`____`" . Is the underscore a place holder for any attribute you are expecting to be there from the output of the function? The asyncio coroutine objects return
futures
until you
await
for their result. They have not necessarily been evaluated when you are inspecting them.
j
The "_" is just a placeholder for whatever method I'm trying to use. For example, I tried using the build_from_flow() method, followed by the .apply(), as stated in this docs page
I'm basically unable to use most of the functionality in the python API now. Total change from v1 (which I'm starting to think was better for my use cases)
r
Many functions in the Python API are designed to be awaitable if called inside an async function - and since Spyder allows top-level await, the Python API behaves the same way there. It's a bit tricky because Spyder doesn't run code directly in a Python interpreter like PyCharm does. One way to make the code behave the same way in Spyder and PyCharm might be to put it inside a non-async function and then run that function, although I'm not sure if that would work well with the way you use Spyder - I can't remember if its variable explorer works when debugging functions or only shows top-level variables. I like Spyder, so I'll install it and experiment a bit. I agree it's a neat way of exploring APIs.
j
I'm trying the same thing in pycharm, getting different errors. I'm trying the most vanilla things I can think of, but I'm just hitting a wall here. Can you see what I'm doing wrong?
I only started running into this 'coroutine' object type after calling blocks etc. from prefect v2. I've been doing data engineering for a long time now and I have to admit I've never seen this object type before 😵‍💫
r
I think the first line of your
build_from_flow
params should be
flow = print_a_message_flow,
without the
()
. That should pass in a reference to
print_a_message_flow
without running it.
j
I think I had so many other errors popping up that I didn't see that one causing a problem
I think I've gotten past that one, but now I'm running into a different issue altogether