-
Notifications
You must be signed in to change notification settings - Fork 784
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
Update pytest_asyncio.fixture default scope and fix broken registry tests #707
base: main
Are you sure you want to change the base?
Conversation
…ests Summary: Addressing the pytest warning: ``` /opt/homebrew/Caskroom/miniconda/base/envs/llama-stack/lib/python3.11/site-packages/pytest_asyncio/plugin.py:208: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) ``` Details in this discussion * #699 (comment) Additional fix: * Tests were broken after registry.get return type was changed from `List[RoutableObjectWithProvider]` to `Optional[RoutableObjectWithProvider]` in efe791b#diff-5de152bae521b7baef01048a4c0142484f8f1c978a04f3b55f4e4dabc52835beL29 Test Plan: Run tests ``` pytest llama_stack/distribution/store/tests/test_registry.py -v collected 6 items llama_stack/distribution/store/tests/test_registry.py::test_registry_initialization PASSED [ 16%] llama_stack/distribution/store/tests/test_registry.py::test_basic_registration PASSED [ 33%] llama_stack/distribution/store/tests/test_registry.py::test_cached_registry_initialization PASSED [ 50%] llama_stack/distribution/store/tests/test_registry.py::test_cached_registry_updates PASSED [ 66%] llama_stack/distribution/store/tests/test_registry.py::test_duplicate_provider_registration PASSED [ 83%] llama_stack/distribution/store/tests/test_registry.py::test_get_all_objects PASSED [100%] ```
@@ -1,3 +1,6 @@ | |||
[build-system] | |||
requires = ["setuptools>=61.0"] | |||
build-backend = "setuptools.build_meta" | |||
|
|||
[tool.pytest.ini_options] |
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.
I'm wondering if it would be a better practice to avoid this project level event loop config to use @pytest.mark.asyncio(loop_scope="function")
for each test case?
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.
Yes, I think being explicit with scopes with fixtures is a good practice and we should keep doing it for our fixtures.
I think it should be fine to have this config. It is not so we can avoid setting explicit scopes, but just to have the default scope when the scope is not specified as pytest-asyncio
will eventually change it "function" by default - in the end we get the same. This way we only explicitly say it so we don't get the warning telling us our default scope will be changed.
Summary:
Addressing the pytest warning:
Details in this discussion
Additional fix:
List[RoutableObjectWithProvider]
toOptional[RoutableObjectWithProvider]
in efe791b#diff-5de152bae521b7baef01048a4c0142484f8f1c978a04f3b55f4e4dabc52835beL29Test Plan:
Run tests