MCPcopy Index your code
hub / github.com/huggingface/diffusers / compare_versions

Function compare_versions

src/diffusers/utils/import_utils.py:665–682  ·  view source on GitHub ↗

Compares a library version to some requirement using a given operation. Args: library_or_version (`str` or `packaging.version.Version`): A library name or a version to check. operation (`str`): A string representation of an operator, such as `">"` or

(library_or_version: str | Version, operation: str, requirement_version: str)

Source from the content-addressed store, hash-verified

663
664# This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L319
665def compare_versions(library_or_version: str | Version, operation: str, requirement_version: str):
666 """
667 Compares a library version to some requirement using a given operation.
668
669 Args:
670 library_or_version (`str` or `packaging.version.Version`):
671 A library name or a version to check.
672 operation (`str`):
673 A string representation of an operator, such as `">"` or `"<="`.
674 requirement_version (`str`):
675 The version to compare the library version against
676 """
677 if operation not in STR_OPERATION_TO_FUNC.keys():
678 raise ValueError(f"`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys())}, received {operation}")
679 operation = STR_OPERATION_TO_FUNC[operation]
680 if isinstance(library_or_version, str):
681 library_or_version = parse(importlib_metadata.version(library_or_version))
682 return operation(library_or_version, parse(requirement_version))
683
684
685# This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L338

Callers 15

is_torch_versionFunction · 0.85
is_torch_xla_versionFunction · 0.85
is_transformers_versionFunction · 0.85
is_kernels_versionFunction · 0.85
is_hf_hub_versionFunction · 0.85
is_accelerate_versionFunction · 0.85
is_peft_versionFunction · 0.85
is_bitsandbytes_versionFunction · 0.85
is_gguf_versionFunction · 0.85
is_torchao_versionFunction · 0.85

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…