-
Notifications
You must be signed in to change notification settings - Fork 29.6k
tests: fix asyncio.wait() usage for python>=3.11 #36898
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
Conversation
Passing coroutings directly to `asyncio.wait()` is deprecated since python 3.8 and removed starting from python 3.11. Instead, it's required to explicitly wrap coroutine in the task with `asyncio.create_task()` which first appeared in python 3.7. We step into this issue running the following Transformers tests on a system with python 3.11 or later (for example, Ubuntu 24.04 has python 3.12): * `tests/trainer/test_trainer_distributed.py` * `tests/extended/test_trainer_ext.py` The error will be: ``` src/transformers/testing_utils.py:2380: in execute_subprocess_async result = loop.run_until_complete( /usr/lib/python3.12/asyncio/base_events.py:687: in run_until_complete return future.result() src/transformers/testing_utils.py:2368: in _stream_subprocess await asyncio.wait( ... E TypeError: Passing coroutines is forbidden, use tasks explicitly. ``` See: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait See: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait See: https://docs.python.org/3.7/library/asyncio-task.html#asyncio.create_task Signed-off-by: Dmitry Rogozhkin <[email protected]>
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Confirmed the changes still work on some relevant tests on our current runner env.
merge as the failing tests are irrelevant to this PR |
tests: fix asyncio.wait() usage for python>=3.7 Passing coroutings directly to `asyncio.wait()` is deprecated since python 3.8 and removed starting from python 3.11. Instead, it's required to explicitly wrap coroutine in the task with `asyncio.create_task()` which first appeared in python 3.7. We step into this issue running the following Transformers tests on a system with python 3.11 or later (for example, Ubuntu 24.04 has python 3.12): * `tests/trainer/test_trainer_distributed.py` * `tests/extended/test_trainer_ext.py` The error will be: ``` src/transformers/testing_utils.py:2380: in execute_subprocess_async result = loop.run_until_complete( /usr/lib/python3.12/asyncio/base_events.py:687: in run_until_complete return future.result() src/transformers/testing_utils.py:2368: in _stream_subprocess await asyncio.wait( ... E TypeError: Passing coroutines is forbidden, use tasks explicitly. ``` See: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait See: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait See: https://docs.python.org/3.7/library/asyncio-task.html#asyncio.create_task Signed-off-by: Dmitry Rogozhkin <[email protected]> Co-authored-by: Yih-Dar <[email protected]>
Passing coroutings directly to
asyncio.wait()
is deprecated since python 3.8 and removed starting from python 3.11. Instead, it's required to explicitly wrap coroutine in the task withasyncio.create_task()
which first appeared in python 3.7.We step into this issue running the following Transformers tests on a systems with python 3.11 or later (for example, Ubuntu 24.04 has python 3.12). Note that multi-accelerator system is required to run these tests (multi-CUDA or multi-XPU):
tests/trainer/test_trainer_distributed.py
tests/extended/test_trainer_ext.py
The error will be:
See: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait
See: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait
See: https://docs.python.org/3.7/library/asyncio-task.html#asyncio.create_task
CC: @ydshieh, @SunMarc