From 8a45be1bfcd2d94b057b0ae9e40a491b376aa778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 13 Nov 2024 11:02:47 +0100 Subject: [PATCH] fix: mark model argument as mandatory 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)