PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.33k stars 1.5k forks source link

Incompatible with `uvloop="^0.19.0` #13588

Open orangekame3 opened 1 month ago

orangekame3 commented 1 month ago

First check

Bug summary

This might not be the place to discuss this, but I'll share it anyway. It seems that the latest versions of prefect="^2.19.2" and uvloop="^0.19.0" are not compatible. I'm using fastapi in conjunction with prefect, and the issue is that fastapi="^0.111.0" has a dependency on uvloop="^0.19.0" by default. Since fastapi is a widely used package, I thought it would be worth sharing this information here. I managed to circumvent this issue by downgrading fastapi to version 0.110.3.

Reproduction

use following code https://github.com/zzstoatzz/submit-to-runner-demo/blob/main/work.py

#pyproject.toml
[tool.poetry]
name = "backend"
version = "0.1.0"
description = ""
authors = [""]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10.13"
prefect = "^2.19.2"
httpx = "^0.27.0"
uvloop = "^0.19.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Error

11:18:56.144 | ERROR   | prefect.flow_runs.runner - Failed to start process for flow run 'ee1bb4f1-9b6c-4127-8e53-229ea4b8129c'.
Traceback (most recent call last):
  File "/Users/orangekame3/src/github.com/orangekame3/qdash/.venv/lib/python3.10/site-packages/prefect/runner/runner.py", line 970, in _submit_run_and_capture_errors
    status_code = await self._run_process(
  File "/Users/orangekame3/src/github.com/orangekame3/qdash/.venv/lib/python3.10/site-packages/prefect/runner/runner.py", line 584, in _run_process
    process = await run_process(
  File "/Users/orangekame3/src/github.com/orangekame3/qdash/.venv/lib/python3.10/site-packages/prefect/utilities/processutils.py", line 258, in run_process
    async with open_process(
  File "/Users/orangekame3/.pyenv/versions/3.10.13/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/Users/orangekame3/src/github.com/orangekame3/qdash/.venv/lib/python3.10/site-packages/prefect/utilities/processutils.py", line 202, in open_process
    process = await anyio.open_process(command, **kwargs)
  File "/Users/orangekame3/src/github.com/orangekame3/qdash/.venv/lib/python3.10/site-packages/anyio/_core/_subprocesses.py", line 126, in open_process
    return await get_asynclib().open_process(
  File "/Users/orangekame3/src/github.com/orangekame3/qdash/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1041, in open_process
    process = await asyncio.create_subprocess_exec(
  File "/Users/orangekame3/.pyenv/versions/3.10.13/lib/python3.10/asyncio/subprocess.py", line 218, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "/Users/orangekame3/.pyenv/versions/3.10.13/lib/python3.10/asyncio/base_events.py", line 1681, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "/Users/orangekame3/.pyenv/versions/3.10.13/lib/python3.10/asyncio/unix_events.py", line 198, in _make_subprocess_transport
    with events.get_child_watcher() as watcher:
  File "/Users/orangekame3/.pyenv/versions/3.10.13/lib/python3.10/asyncio/events.py", line 788, in get_child_watcher
    return get_event_loop_policy().get_child_watcher()
  File "/Users/orangekame3/.pyenv/versions/3.10.13/lib/python3.10/asyncio/events.py", line 616, in get_child_watcher
    raise NotImplementedError
NotImplementedError

Versions

prefect = "^2.19.2"

Additional context

No response

orangekame3 commented 1 month ago

I shared about this topic in Slack channel This issue is not specific to prefect, so please feel free to close it if it's not relevant.

desertaxle commented 3 weeks ago

Hey @orangekame3, the 2.19.2 version of prefect vendors a specific version of FastAPI to maintain compatibility with Pydantic v2. I think that might be the source of this incompatibility. We will be removing that vendored version in our 3.0.0 release, so you can try with our 3.0.0rc2 version and see if this issue persists.