-
Notifications
You must be signed in to change notification settings - Fork 17
refactor!: Make QuadprogProjector dependencies optional #683
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7369f6f
refactor: Make quadprog, qpsolvers, and numpy optional dependencies
ValerianRey 9a7ceb8
Protect numpy import against ImportError in NashMTL and CAGrad
ValerianRey 7fcd46d
Add pytest_skip_if_deps_not_installed
ValerianRey a2dbd7f
Fix comment in pyproject.toml
ValerianRey 734a037
Merge branch 'main' into refactor/optional-deps
ValerianRey df26dbe
Remove license info in table
ValerianRey 56d2f36
fix: Rename pytest_skip_if_deps_not_installed to avoid pytest hook co…
ValerianRey d147fb4
Add links in table
ValerianRey fa1f5f0
Skip upgrad and dualproj tests if QuadprogProjector deps are not inst…
ValerianRey ea6fedb
Skip dual_cone tests if QuadprogProjector deps are not installed
ValerianRey 5d9607f
Fix test_values
ValerianRey 7b94cf0
Fix test_flattening.py
ValerianRey 9b8a58f
Use IMTLG in test_cr_mogm
ValerianRey 2591034
Add a dedicated tests/utils/optional_deps.py file to give tools to ha…
ValerianRey db04035
Add test_import_error_at_init
ValerianRey 3ac15c1
Add changelog entry
ValerianRey a7530f0
Move test_import_error to its own file
ValerianRey 2a6ca16
Merge branch 'main' into refactor/optional-deps
ValerianRey 23ca087
Fixes
ValerianRey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| from importlib.util import find_spec | ||
| from typing import Any | ||
|
|
||
|
|
||
| class _WithOptionalDeps: | ||
| """ | ||
| Mixin that raises :class:`ImportError` at instantiation time if required optional dependencies | ||
| are not installed. | ||
|
|
||
| Subclasses must define :attr:`_REQUIRED_DEPS` (list of package names to check via | ||
| :func:`importlib.util.find_spec`) and :attr:`_INSTALL_HINT` (appended to the error message). | ||
|
|
||
| .. warning:: | ||
| This mixin must appear **first** in the inheritance list so that its :meth:`__init__` | ||
| runs before any base class that uses the optional dependencies. | ||
| """ | ||
|
|
||
| _REQUIRED_DEPS: list[str] | ||
| _INSTALL_HINT: str | ||
|
|
||
| def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
| missing = [name for name in self._REQUIRED_DEPS if find_spec(name) is None] | ||
| if len(missing) != 0: | ||
| raise ImportError( | ||
| f"{self.__class__.__name__} requires {missing} to be installed. " | ||
| f"{self._INSTALL_HINT}" | ||
| ) | ||
| super().__init__(*args, **kwargs) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.