Skip to content

pynvml only semi optional #11

Description

@maltevesper

I would like to use pytest-isolate, however, as I have filterwarnings set to error in my pyproject.toml to make sure I do not ship warnings, pytest terminates with an Internal error

pyproject.toml pytest config:

filterwarnings = [
    "error",
]

Resulting output

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pytest_isolate/plugin.py", line 62, in get_available_gpus
INTERNALERROR>     import pynvml
INTERNALERROR> ModuleNotFoundError: No module named 'pynvml'
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/_pytest/main.py", line 285, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/_pytest/config/__init__.py", line 1119, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pluggy/_hooks.py", line 534, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pluggy/_callers.py", line 167, in _multicall
INTERNALERROR>     raise exception
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pytest_isolate/plugin.py", line 336, in pytest_configure
INTERNALERROR>     register_resource_provider("gpu", "CUDA_VISIBLE_DEVICES", get_available_gpus)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pytest_isolate/resource_management.py", line 153, in register_resource_provider
INTERNALERROR>     existing = provider_func()
INTERNALERROR>   File "/workspaces/project/.venv/lib/python3.14/site-packages/pytest_isolate/plugin.py", line 70, in get_available_gpus
INTERNALERROR>     warnings.warn("Failed to get GPU count using pynvml", RuntimeWarning)
INTERNALERROR>     ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> RuntimeWarning: Failed to get GPU count using pynvml

It would be nice to have a configuration option to tell the plugin that one does not care about the GPU parts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions