Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: async code that works with a work queue/agent fails with prefect deployment execute #6060

Closed
discdiver opened this issue Jul 25, 2022 · 1 comment

Comments

@discdiver
Copy link
Contributor

Non-async version works fine.

Reproducible example:

import asyncio
from prefect import flow, get_run_logger
from prefect.deployments import Deployment


@flow()
async def test_flow():
    logger = get_run_logger()
    logger.info("Running test flow")


async def main():
    await test_flow()


Deployment(flow=test_flow, name="t1", tags=["async"])

if __name__ == "__main__":
    asyncio.run(main())
(base) test-doc-examples % prefect deployment execute 'test-flow/t1'

stack trace:

Loading flow from deployed location...
Running flow...
Traceback (most recent call last):
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/prefect/utilities/asyncutils.py", line 193, in wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/prefect/utilities/asyncutils.py", line 140, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "/Users/jeffhale/miniforge3/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/jeffhale/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "/Users/jeffhale/miniforge3/lib/python3.9/site-packages/prefect/cli/deployment.py", line 179, in execute
    if state.is_failed():
AttributeError: 'coroutine' object has no attribute 'is_failed'
An exception occurred.
@discdiver discdiver added the v2 label Jul 25, 2022
@discdiver discdiver changed the title async code that works with a work queue/agent fails with prefect deployment execute Bug: async code that works with a work queue/agent fails with prefect deployment execute Jul 25, 2022
@cicdw
Copy link
Member

cicdw commented Jul 28, 2022

Closed by #6085

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants