MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / compare_versions

Function compare_versions

diffusers/src/diffusers/utils/import_utils.py:669–686  ·  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: Union[str, Version], operation: str, requirement_version: str)

Source from the content-addressed store, hash-verified

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

Callers 5

is_torch_versionFunction · 0.85
is_transformers_versionFunction · 0.85
is_accelerate_versionFunction · 0.85
is_peft_versionFunction · 0.85
is_k_diffusion_versionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected