Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
59c1af77
Unverified
Commit
59c1af77
authored
Sep 04, 2022
by
Patrick von Platen
Committed by
GitHub
Sep 04, 2022
Browse files
[Commands] Add env command (#352)
* [Commands] Add env command * Apply suggestions from code review
parent
fd768456
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
1 deletion
+147
-1
.github/ISSUE_TEMPLATE/bug-report.yml
.github/ISSUE_TEMPLATE/bug-report.yml
+8
-0
setup.py
setup.py
+1
-1
src/diffusers/commands/__init__.py
src/diffusers/commands/__init__.py
+27
-0
src/diffusers/commands/diffusers_cli.py
src/diffusers/commands/diffusers_cli.py
+41
-0
src/diffusers/commands/env.py
src/diffusers/commands/env.py
+70
-0
No files found.
.github/ISSUE_TEMPLATE/bug-report.yml
View file @
59c1af77
...
@@ -6,6 +6,14 @@ body:
...
@@ -6,6 +6,14 @@ body:
attributes
:
attributes
:
value
:
|
value
:
|
Thanks for taking the time to fill out this bug report!
Thanks for taking the time to fill out this bug report!
-
type
:
textarea
id
:
system-info
attributes
:
label
:
System Info
description
:
Please share your system info with us. You can run the command `diffusers-cli env` and copy-paste its output below.
placeholder
:
diffusers version, platform, python version, ...
validations
:
required
:
true
-
type
:
textarea
-
type
:
textarea
id
:
bug-description
id
:
bug-description
attributes
:
attributes
:
...
...
setup.py
View file @
59c1af77
...
@@ -201,6 +201,7 @@ setup(
...
@@ -201,6 +201,7 @@ setup(
python_requires
=
">=3.6.0"
,
python_requires
=
">=3.6.0"
,
install_requires
=
install_requires
,
install_requires
=
install_requires
,
extras_require
=
extras
,
extras_require
=
extras
,
entry_points
=
{
"console_scripts"
:
[
"diffusers-cli=diffusers.commands.diffusers_cli:main"
]},
classifiers
=
[
classifiers
=
[
"Development Status :: 5 - Production/Stable"
,
"Development Status :: 5 - Production/Stable"
,
"Intended Audience :: Developers"
,
"Intended Audience :: Developers"
,
...
@@ -209,7 +210,6 @@ setup(
...
@@ -209,7 +210,6 @@ setup(
"License :: OSI Approved :: Apache Software License"
,
"License :: OSI Approved :: Apache Software License"
,
"Operating System :: OS Independent"
,
"Operating System :: OS Independent"
,
"Programming Language :: Python :: 3"
,
"Programming Language :: Python :: 3"
,
"Programming Language :: Python :: 3.6"
,
"Programming Language :: Python :: 3.7"
,
"Programming Language :: Python :: 3.7"
,
"Programming Language :: Python :: 3.8"
,
"Programming Language :: Python :: 3.8"
,
"Programming Language :: Python :: 3.9"
,
"Programming Language :: Python :: 3.9"
,
...
...
src/diffusers/commands/__init__.py
0 → 100644
View file @
59c1af77
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
abc
import
ABC
,
abstractmethod
from
argparse
import
ArgumentParser
class
BaseDiffusersCLICommand
(
ABC
):
@
staticmethod
@
abstractmethod
def
register_subcommand
(
parser
:
ArgumentParser
):
raise
NotImplementedError
()
@
abstractmethod
def
run
(
self
):
raise
NotImplementedError
()
src/diffusers/commands/diffusers_cli.py
0 → 100644
View file @
59c1af77
#!/usr/bin/env python
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
argparse
import
ArgumentParser
from
.env
import
EnvironmentCommand
def
main
():
parser
=
ArgumentParser
(
"Diffusers CLI tool"
,
usage
=
"diffusers-cli <command> [<args>]"
)
commands_parser
=
parser
.
add_subparsers
(
help
=
"diffusers-cli command helpers"
)
# Register commands
EnvironmentCommand
.
register_subcommand
(
commands_parser
)
# Let's go
args
=
parser
.
parse_args
()
if
not
hasattr
(
args
,
"func"
):
parser
.
print_help
()
exit
(
1
)
# Run
service
=
args
.
func
(
args
)
service
.
run
()
if
__name__
==
"__main__"
:
main
()
src/diffusers/commands/env.py
0 → 100644
View file @
59c1af77
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
platform
from
argparse
import
ArgumentParser
import
huggingface_hub
from
..
import
__version__
as
version
from
..utils
import
is_torch_available
,
is_transformers_available
from
.
import
BaseDiffusersCLICommand
def
info_command_factory
(
_
):
return
EnvironmentCommand
()
class
EnvironmentCommand
(
BaseDiffusersCLICommand
):
@
staticmethod
def
register_subcommand
(
parser
:
ArgumentParser
):
download_parser
=
parser
.
add_parser
(
"env"
)
download_parser
.
set_defaults
(
func
=
info_command_factory
)
def
run
(
self
):
hub_version
=
huggingface_hub
.
__version__
pt_version
=
"not installed"
pt_cuda_available
=
"NA"
if
is_torch_available
():
import
torch
pt_version
=
torch
.
__version__
pt_cuda_available
=
torch
.
cuda
.
is_available
()
transformers_version
=
"not installed"
if
is_transformers_available
:
import
transformers
transformers_version
=
transformers
.
__version__
info
=
{
"`diffusers` version"
:
version
,
"Platform"
:
platform
.
platform
(),
"Python version"
:
platform
.
python_version
(),
"PyTorch version (GPU?)"
:
f
"
{
pt_version
}
(
{
pt_cuda_available
}
)"
,
"Huggingface_hub version"
:
hub_version
,
"Transformers version"
:
transformers_version
,
"Using GPU in script?"
:
"<fill in>"
,
"Using distributed or parallel set-up in script?"
:
"<fill in>"
,
}
print
(
"
\n
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
\n
"
)
print
(
self
.
format_dict
(
info
))
return
info
@
staticmethod
def
format_dict
(
d
):
return
"
\n
"
.
join
([
f
"-
{
prop
}
:
{
val
}
"
for
prop
,
val
in
d
.
items
()])
+
"
\n
"
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