From 4ee1053dcf535340704dedb703db013fb87389d4 Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Thu, 10 Sep 2020 01:58:29 -0700 Subject: [PATCH] add -y to bypass prompt for transformers-cli upload (#7035) --- docs/source/model_sharing.rst | 7 +++++++ src/transformers/commands/user.py | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/source/model_sharing.rst b/docs/source/model_sharing.rst index bdb11bc36b..96ad1d813b 100644 --- a/docs/source/model_sharing.rst +++ b/docs/source/model_sharing.rst @@ -136,6 +136,13 @@ Then log in using the same credentials as on huggingface.co. To upload your mode This will upload the folder containing the weights, tokenizer and configuration we prepared in the previous section. +By default you will be prompted to confirm that you want these files to be uploaded. If you are uploading multiple models and need to script that process, you can add `-y` to bypass the prompt. For example: + +:: + + transformers-cli upload -y path/to/awesome-name-you-picked/ + + If you want to upload a single file (a new version of your model, or the other framework checkpoint you want to add), just type: diff --git a/src/transformers/commands/user.py b/src/transformers/commands/user.py index 7fab28c31f..820d2c1510 100644 --- a/src/transformers/commands/user.py +++ b/src/transformers/commands/user.py @@ -40,6 +40,7 @@ class UserCommands(BaseTransformersCLICommand): upload_parser.add_argument( "--filename", type=str, default=None, help="Optional: override individual object filename on S3." ) + upload_parser.add_argument("-y", "--yes", action="store_true", help="Optional: answer Yes to the prompt") upload_parser.set_defaults(func=lambda args: UploadCommand(args)) @@ -221,10 +222,11 @@ class UploadCommand(BaseUserCommand): ) ) - choice = input("Proceed? [Y/n] ").lower() - if not (choice == "" or choice == "y" or choice == "yes"): - print("Abort") - exit() + if not self.args.yes: + choice = input("Proceed? [Y/n] ").lower() + if not (choice == "" or choice == "y" or choice == "yes"): + print("Abort") + exit() print(ANSI.bold("Uploading... This might take a while if files are large")) for filepath, filename in files: try: