Check k-diffusion version is at least 0.0.12 (#2022)
* Check k-diffusion version is at least 0.0.12 * make style
This commit is contained in:
parent
a43bdd01cd
commit
7e29b747f9
2
setup.py
2
setup.py
|
@ -91,7 +91,7 @@ _deps = [
|
|||
"isort>=5.5.4",
|
||||
"jax>=0.2.8,!=0.3.2",
|
||||
"jaxlib>=0.1.65",
|
||||
"k-diffusion",
|
||||
"k-diffusion>=0.0.12",
|
||||
"librosa",
|
||||
"modelcards>=0.1.4",
|
||||
"numpy",
|
||||
|
|
|
@ -6,6 +6,7 @@ from .utils import (
|
|||
is_flax_available,
|
||||
is_inflect_available,
|
||||
is_k_diffusion_available,
|
||||
is_k_diffusion_version,
|
||||
is_librosa_available,
|
||||
is_onnx_available,
|
||||
is_scipy_available,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
deps = {
|
||||
"Pillow": "Pillow",
|
||||
"accelerate": "accelerate>=0.11.0",
|
||||
"black": "black==22.8",
|
||||
"black": "black==22.12",
|
||||
"datasets": "datasets",
|
||||
"filelock": "filelock",
|
||||
"flake8": "flake8>=3.8.3",
|
||||
|
@ -15,7 +15,7 @@ deps = {
|
|||
"isort": "isort>=5.5.4",
|
||||
"jax": "jax>=0.2.8,!=0.3.2",
|
||||
"jaxlib": "jaxlib>=0.1.65",
|
||||
"k-diffusion": "k-diffusion",
|
||||
"k-diffusion": "k-diffusion>=0.0.12",
|
||||
"librosa": "librosa",
|
||||
"modelcards": "modelcards>=0.1.4",
|
||||
"numpy": "numpy",
|
||||
|
|
|
@ -11,6 +11,7 @@ from ...utils import (
|
|||
OptionalDependencyNotAvailable,
|
||||
is_flax_available,
|
||||
is_k_diffusion_available,
|
||||
is_k_diffusion_version,
|
||||
is_onnx_available,
|
||||
is_torch_available,
|
||||
is_transformers_available,
|
||||
|
@ -64,7 +65,7 @@ else:
|
|||
|
||||
|
||||
try:
|
||||
if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()):
|
||||
if not (is_torch_available() and is_transformers_available() and is_k_diffusion_version(">=", "0.0.12")):
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
from ...utils.dummy_torch_and_transformers_and_k_diffusion_objects import * # noqa F403
|
||||
|
|
|
@ -47,6 +47,7 @@ from .import_utils import (
|
|||
is_flax_available,
|
||||
is_inflect_available,
|
||||
is_k_diffusion_available,
|
||||
is_k_diffusion_version,
|
||||
is_librosa_available,
|
||||
is_modelcards_available,
|
||||
is_onnx_available,
|
||||
|
|
|
@ -427,12 +427,26 @@ def is_transformers_version(operation: str, version: str):
|
|||
operation (`str`):
|
||||
A string representation of an operator, such as `">"` or `"<="`
|
||||
version (`str`):
|
||||
A string version of PyTorch
|
||||
A version string
|
||||
"""
|
||||
if not _transformers_available:
|
||||
return False
|
||||
return compare_versions(parse(_transformers_version), operation, version)
|
||||
|
||||
|
||||
def is_k_diffusion_version(operation: str, version: str):
|
||||
"""
|
||||
Args:
|
||||
Compares the current k-diffusion version to a given reference with an operation.
|
||||
operation (`str`):
|
||||
A string representation of an operator, such as `">"` or `"<="`
|
||||
version (`str`):
|
||||
A version string
|
||||
"""
|
||||
if not _k_diffusion_available:
|
||||
return False
|
||||
return compare_versions(parse(_k_diffusion_version), operation, version)
|
||||
|
||||
|
||||
class OptionalDependencyNotAvailable(BaseException):
|
||||
"""An error indicating that an optional dependency of Diffusers was not found in the environment."""
|
||||
|
|
Loading…
Reference in New Issue