From 5da240a85093e46cf6f4b9649476329fa561ecbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Sat, 16 Nov 2024 03:51:33 +0100 Subject: [PATCH] fix: Fail gracefully when "model" arg is missing when downloading (#1372) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's gracefully fail if no model is given to the `download` command. Signed-off-by: Sébastien Han --- torchchat/cli/download.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/torchchat/cli/download.py b/torchchat/cli/download.py index f145c93fb..f334eb555 100644 --- a/torchchat/cli/download.py +++ b/torchchat/cli/download.py @@ -110,6 +110,8 @@ def _download_direct( def download_and_convert( model: str, models_dir: Path, hf_token: Optional[str] = None ) -> None: + if model is None: + raise ValueError("'download' command needs a model name or alias.") model_config = resolve_model_config(model) model_dir = models_dir / model_config.name @@ -234,4 +236,8 @@ def where_main(args) -> None: # Subcommand to download model artifacts. def download_main(args) -> None: - download_and_convert(args.model, args.model_directory, args.hf_token) + try: + download_and_convert(args.model, args.model_directory, args.hf_token) + except ValueError as e: + print(e, file=sys.stderr) + sys.exit(1)