Skip to content

Commit 5da240a

Browse files
authored
fix: Fail gracefully when "model" arg is missing when downloading (pytorch#1372)
Let's gracefully fail if no model is given to the `download` command. Signed-off-by: Sébastien Han <seb@redhat.com>
1 parent d7b681a commit 5da240a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

torchchat/cli/download.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def _download_direct(
110110
def download_and_convert(
111111
model: str, models_dir: Path, hf_token: Optional[str] = None
112112
) -> None:
113+
if model is None:
114+
raise ValueError("'download' command needs a model name or alias.")
113115
model_config = resolve_model_config(model)
114116
model_dir = models_dir / model_config.name
115117

@@ -234,4 +236,8 @@ def where_main(args) -> None:
234236

235237
# Subcommand to download model artifacts.
236238
def download_main(args) -> None:
237-
download_and_convert(args.model, args.model_directory, args.hf_token)
239+
try:
240+
download_and_convert(args.model, args.model_directory, args.hf_token)
241+
except ValueError as e:
242+
print(e, file=sys.stderr)
243+
sys.exit(1)

0 commit comments

Comments
 (0)