2019-12-04 05:52:23 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
|
2020-02-01 15:38:14 +00:00
|
|
|
from transformers.commands.convert import ConvertCommand
|
2019-12-03 13:56:57 +00:00
|
|
|
from transformers.commands.download import DownloadCommand
|
2020-02-01 15:38:14 +00:00
|
|
|
from transformers.commands.env import EnvironmentCommand
|
2019-12-15 00:37:16 +00:00
|
|
|
from transformers.commands.run import RunCommand
|
2019-12-20 12:47:35 +00:00
|
|
|
from transformers.commands.serving import ServeCommand
|
2020-02-01 15:38:14 +00:00
|
|
|
from transformers.commands.user import UserCommands
|
2019-12-04 05:52:23 +00:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-10-16 12:17:58 +00:00
|
|
|
parser = ArgumentParser('Transformers CLI tool', usage='transformers-cli <command> [<args>]')
|
2019-12-04 05:52:23 +00:00
|
|
|
commands_parser = parser.add_subparsers(help='transformers-cli command helpers')
|
|
|
|
|
|
|
|
|
|
# Register commands
|
2019-12-03 13:56:57 +00:00
|
|
|
ConvertCommand.register_subcommand(commands_parser)
|
|
|
|
|
DownloadCommand.register_subcommand(commands_parser)
|
2020-02-01 15:38:14 +00:00
|
|
|
EnvironmentCommand.register_subcommand(commands_parser)
|
2019-12-15 00:37:16 +00:00
|
|
|
RunCommand.register_subcommand(commands_parser)
|
2019-10-16 12:17:58 +00:00
|
|
|
ServeCommand.register_subcommand(commands_parser)
|
2019-12-15 00:37:16 +00:00
|
|
|
UserCommands.register_subcommand(commands_parser)
|
2019-12-04 05:52:23 +00:00
|
|
|
|
|
|
|
|
# Let's go
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
if not hasattr(args, 'func'):
|
|
|
|
|
parser.print_help()
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
# Run
|
|
|
|
|
service = args.func(args)
|
|
|
|
|
service.run()
|