mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-23 22:38:58 +06:00

* add "info" command to CLI As a convenience, add the info directive to CLI. Running `python transformers-cli info` will return a string containing the transformers version, platform, python version, PT/TF version and GPU support * Swap f-strings for .format Still supporting 3.5 so can't use f-strings (sad face) * Add reference in issue to CLI * Add the expected fields to issue template This way, people can still add the information manually if they want. (Though I fear they'll just ignore it.) * Remove heading from output * black-ify * order of imports Should ensure isort test passes * use is_X_available over import..pass * style * fix copy-paste bug * Rename command info -> env Also adds the command to CONTRIBUTING.md in "Did you find a bug" section
33 lines
1.1 KiB
Python
Executable File
33 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
from argparse import ArgumentParser
|
|
|
|
from transformers.commands.convert import ConvertCommand
|
|
from transformers.commands.download import DownloadCommand
|
|
from transformers.commands.env import EnvironmentCommand
|
|
from transformers.commands.run import RunCommand
|
|
from transformers.commands.serving import ServeCommand
|
|
from transformers.commands.user import UserCommands
|
|
|
|
if __name__ == '__main__':
|
|
parser = ArgumentParser('Transformers CLI tool', usage='transformers-cli <command> [<args>]')
|
|
commands_parser = parser.add_subparsers(help='transformers-cli command helpers')
|
|
|
|
# Register commands
|
|
ConvertCommand.register_subcommand(commands_parser)
|
|
DownloadCommand.register_subcommand(commands_parser)
|
|
EnvironmentCommand.register_subcommand(commands_parser)
|
|
RunCommand.register_subcommand(commands_parser)
|
|
ServeCommand.register_subcommand(commands_parser)
|
|
UserCommands.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()
|