Skip to content

Commit

Permalink
fix: Fail gracefully when "model" arg is missing when downloading (#1372
Browse files Browse the repository at this point in the history
)

Let's gracefully fail if no model is given to the `download` command.

Signed-off-by: Sébastien Han <[email protected]>
  • Loading branch information
leseb authored Nov 16, 2024
1 parent d7b681a commit 5da240a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion torchchat/cli/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

0 comments on commit 5da240a

Please sign in to comment.