Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
diffusers
Commits
3c67864c
Unverified
Commit
3c67864c
authored
Mar 25, 2024
by
Sayak Paul
Committed by
GitHub
Mar 25, 2024
Browse files
Remove `distutils` (#7455)
* strtobool * replace Command from setuptools.
parent
36369904
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
setup.py
setup.py
+2
-3
src/diffusers/utils/testing_utils.py
src/diffusers/utils/testing_utils.py
+17
-2
tests/others/test_utils.py
tests/others/test_utils.py
+2
-2
No files found.
setup.py
View file @
3c67864c
...
@@ -81,9 +81,8 @@ To create the package for PyPI.
...
@@ -81,9 +81,8 @@ To create the package for PyPI.
import
os
import
os
import
re
import
re
import
sys
import
sys
from
distutils.core
import
Command
from
setuptools
import
find_packages
,
setup
from
setuptools
import
Command
,
find_packages
,
setup
# IMPORTANT:
# IMPORTANT:
...
@@ -163,7 +162,7 @@ def deps_list(*pkgs):
...
@@ -163,7 +162,7 @@ def deps_list(*pkgs):
class
DepsTableUpdateCommand
(
Command
):
class
DepsTableUpdateCommand
(
Command
):
"""
"""
A custom
distutils
command that updates the dependency table.
A custom command that updates the dependency table.
usage: python setup.py deps_table_update
usage: python setup.py deps_table_update
"""
"""
...
...
src/diffusers/utils/testing_utils.py
View file @
3c67864c
...
@@ -14,7 +14,6 @@ import time
...
@@ -14,7 +14,6 @@ import time
import
unittest
import
unittest
import
urllib.parse
import
urllib.parse
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
distutils.util
import
strtobool
from
io
import
BytesIO
,
StringIO
from
io
import
BytesIO
,
StringIO
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Callable
,
Dict
,
List
,
Optional
,
Union
from
typing
import
Callable
,
Dict
,
List
,
Optional
,
Union
...
@@ -151,7 +150,7 @@ def parse_flag_from_env(key, default=False):
...
@@ -151,7 +150,7 @@ def parse_flag_from_env(key, default=False):
else
:
else
:
# KEY is set, convert it to True or False.
# KEY is set, convert it to True or False.
try
:
try
:
_value
=
strtobool
(
value
)
_value
=
str
_
to
_
bool
(
value
)
except
ValueError
:
except
ValueError
:
# More values are supported, but let's keep the message simple.
# More values are supported, but let's keep the message simple.
raise
ValueError
(
f
"If set,
{
key
}
must be yes or no."
)
raise
ValueError
(
f
"If set,
{
key
}
must be yes or no."
)
...
@@ -921,6 +920,22 @@ def backend_supports_training(device: str):
...
@@ -921,6 +920,22 @@ def backend_supports_training(device: str):
return
BACKEND_SUPPORTS_TRAINING
[
device
]
return
BACKEND_SUPPORTS_TRAINING
[
device
]
# Taken from the following PR:
# https://github.com/huggingface/accelerate/pull/1964
def
str_to_bool
(
value
)
->
int
:
"""
Converts a string representation of truth to `True` (1) or `False` (0).
True values are `y`, `yes`, `t`, `true`, `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
"""
value
=
value
.
lower
()
if
value
in
(
"y"
,
"yes"
,
"t"
,
"true"
,
"on"
,
"1"
):
return
1
elif
value
in
(
"n"
,
"no"
,
"f"
,
"false"
,
"off"
,
"0"
):
return
0
else
:
raise
ValueError
(
f
"invalid truth value
{
value
}
"
)
# Guard for when Torch is not available
# Guard for when Torch is not available
if
is_torch_available
():
if
is_torch_available
():
# Update device function dict mapping
# Update device function dict mapping
...
...
tests/others/test_utils.py
View file @
3c67864c
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
import
os
import
os
import
unittest
import
unittest
from
distutils.util
import
strtobool
import
pytest
import
pytest
from
diffusers
import
__version__
from
diffusers
import
__version__
from
diffusers.utils
import
deprecate
from
diffusers.utils
import
deprecate
from
diffusers.utils.testing_utils
import
str_to_bool
# Used to test the hub
# Used to test the hub
...
@@ -191,7 +191,7 @@ def parse_flag_from_env(key, default=False):
...
@@ -191,7 +191,7 @@ def parse_flag_from_env(key, default=False):
else
:
else
:
# KEY is set, convert it to True or False.
# KEY is set, convert it to True or False.
try
:
try
:
_value
=
strtobool
(
value
)
_value
=
str
_
to
_
bool
(
value
)
except
ValueError
:
except
ValueError
:
# More values are supported, but let's keep the message simple.
# More values are supported, but let's keep the message simple.
raise
ValueError
(
f
"If set,
{
key
}
must be yes or no."
)
raise
ValueError
(
f
"If set,
{
key
}
must be yes or no."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment