Skip to content

Commit

Permalink
refac: docstrings in import_utils.py (#9583)
Browse files Browse the repository at this point in the history
* refac: docstrings in import_utils.py

* Update import_utils.py
  • Loading branch information
yijun-lee authored Oct 7, 2024
1 parent 2cb383f commit a80f689
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/diffusers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,9 @@ def __getattr__(cls, key):
# This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L319
def compare_versions(library_or_version: Union[str, Version], operation: str, requirement_version: str):
"""
Args:
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`):
Expand All @@ -688,8 +689,9 @@ def compare_versions(library_or_version: Union[str, Version], operation: str, re
# This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L338
def is_torch_version(operation: str, version: str):
"""
Args:
Compares the current PyTorch version to a given reference with an operation.
Args:
operation (`str`):
A string representation of an operator, such as `">"` or `"<="`
version (`str`):
Expand All @@ -700,8 +702,9 @@ def is_torch_version(operation: str, version: str):

def is_transformers_version(operation: str, version: str):
"""
Args:
Compares the current Transformers version to a given reference with an operation.
Args:
operation (`str`):
A string representation of an operator, such as `">"` or `"<="`
version (`str`):
Expand All @@ -714,8 +717,9 @@ def is_transformers_version(operation: str, version: str):

def is_accelerate_version(operation: str, version: str):
"""
Args:
Compares the current Accelerate version to a given reference with an operation.
Args:
operation (`str`):
A string representation of an operator, such as `">"` or `"<="`
version (`str`):
Expand All @@ -728,8 +732,9 @@ def is_accelerate_version(operation: str, version: str):

def is_peft_version(operation: str, version: str):
"""
Args:
Compares the current PEFT version to a given reference with an operation.
Args:
operation (`str`):
A string representation of an operator, such as `">"` or `"<="`
version (`str`):
Expand All @@ -742,8 +747,9 @@ def is_peft_version(operation: str, version: str):

def is_k_diffusion_version(operation: str, version: str):
"""
Args:
Compares the current k-diffusion version to a given reference with an operation.
Args:
operation (`str`):
A string representation of an operator, such as `">"` or `"<="`
version (`str`):
Expand All @@ -756,8 +762,9 @@ def is_k_diffusion_version(operation: str, version: str):

def get_objects_from_module(module):
"""
Args:
Returns a dict of object names and values in a module, while skipping private/internal objects
Args:
module (ModuleType):
Module to extract the objects from.
Expand All @@ -775,7 +782,9 @@ def get_objects_from_module(module):


class OptionalDependencyNotAvailable(BaseException):
"""An error indicating that an optional dependency of Diffusers was not found in the environment."""
"""
An error indicating that an optional dependency of Diffusers was not found in the environment.
"""


class _LazyModule(ModuleType):
Expand Down

0 comments on commit a80f689

Please sign in to comment.