Skip to content

Commit

Permalink
feat(cli): add option for downloading all models, refine help messages (
Browse files Browse the repository at this point in the history
#1061)

* chore(cli): update download help messages

Signed-off-by: Panos Vagenas <[email protected]>

* add `--all` flag to model download CLI

Signed-off-by: Panos Vagenas <[email protected]>

---------

Signed-off-by: Panos Vagenas <[email protected]>
Signed-off-by: Panos Vagenas <[email protected]>
  • Loading branch information
vagenas authored Feb 26, 2025
1 parent e197225 commit ab683e4
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions docling/cli/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,27 @@ def download(
...,
"-o",
"--output-dir",
help="The directory where all the models are downloaded.",
help="The directory where to download the models.",
),
] = (settings.cache_dir / "models"),
force: Annotated[
bool, typer.Option(..., help="If true, the download will be forced")
bool, typer.Option(..., help="If true, the download will be forced.")
] = False,
models: Annotated[
Optional[list[_AvailableModels]],
typer.Argument(
help=f"Models to download (default behavior: all will be downloaded)",
help=f"Models to download (default behavior: a predefined set of models will be downloaded).",
),
] = None,
all: Annotated[
bool,
typer.Option(
...,
"--all",
help="If true, all available models will be downloaded (mutually exclusive with passing specific models).",
show_default=True,
),
] = False,
quiet: Annotated[
bool,
typer.Option(
Expand All @@ -75,6 +84,10 @@ def download(
),
] = False,
):
if models and all:
raise typer.BadParameter(
"Cannot simultaneously set 'all' parameter and specify models to download."
)
if not quiet:
FORMAT = "%(message)s"
logging.basicConfig(
Expand All @@ -83,7 +96,7 @@ def download(
datefmt="[%X]",
handlers=[RichHandler(show_level=False, show_time=False, markup=True)],
)
to_download = models or _default_models
to_download = models or ([m for m in _AvailableModels] if all else _default_models)
output_dir = download_models(
output_dir=output_dir,
force=force,
Expand Down

0 comments on commit ab683e4

Please sign in to comment.