-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from eriknovak/feature/quant
Add support for generator model quantization
- Loading branch information
Showing
6 changed files
with
178 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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 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,34 @@ | ||
from importlib.metadata import requires | ||
from typing import Union | ||
|
||
|
||
def is_installed_with(extra: Union[str, list[str]]) -> bool: | ||
"""Check if anonipy was installed with specific optional dependencies. | ||
Args: | ||
extra: The optional dependency or list of dependencies to check. | ||
Valid values are: 'dev', 'test', 'quant', 'all' | ||
Returns: | ||
True if package was installed with the specified optional dependencies, | ||
False otherwise. | ||
Example: | ||
>>> from anonipy.utils.package import is_installed_with | ||
>>> is_installed_with('dev') # check if dev dependencies are installed | ||
>>> is_installed_with(['dev', 'test']) # check multiple dependency groups | ||
""" | ||
if isinstance(extra, str): | ||
extra = [extra] | ||
|
||
try: | ||
package_requires = requires("anonipy") or [] | ||
installed_extras = set() | ||
|
||
for req in package_requires: | ||
if "extra == " in req: | ||
installed_extras.add(req.split("extra == ")[1].strip("\"'")) | ||
|
||
return any(e in installed_extras for e in extra) | ||
except Exception: | ||
return False |
This file contains 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 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 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 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