This prevents transformers from being importable simply because the CWD
is the root of the git repository, while not being importable from other
directories. That led to inconsistent behavior, especially in examples.
Once you fetch this commit, in your dev environment, you must run:
$ pip uninstall transformers
$ pip install -e .
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
# coding: utf8
|
|
|
|
|
|
def main():
|
|
import sys
|
|
|
|
if len(sys.argv) < 2 or sys.argv[1] not in ["convert", "train", "predict", "serve"]:
|
|
print(
|
|
"First argument to `transformers` command line interface should be one of: \n"
|
|
">> convert serve train predict"
|
|
)
|
|
if sys.argv[1] == "convert":
|
|
from transformers.commands import convert
|
|
|
|
convert(sys.argv)
|
|
elif sys.argv[1] == "train":
|
|
from transformers.commands import train
|
|
|
|
train(sys.argv)
|
|
elif sys.argv[1] == "serve":
|
|
pass
|
|
# from argparse import ArgumentParser
|
|
# from transformers.commands.serving import ServeCommand
|
|
# parser = ArgumentParser('Transformers CLI tool', usage='transformers serve <command> [<args>]')
|
|
# commands_parser = parser.add_subparsers(help='transformers-cli command helpers')
|
|
|
|
# # Register commands
|
|
# ServeCommand.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()
|