MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / download

Function download

docling/cli/models.py:39–101  ·  view source on GitHub ↗
(
    output_dir: Annotated[
        Path,
        typer.Option(
            ...,
            "-o",
            "--output-dir",
            help="The directory where all the models are downloaded.",
        ),
    ] = (settings.cache_dir / "models"),
    force: Annotated[
        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)",
        ),
    ] = None,
    quiet: Annotated[
        bool,
        typer.Option(
            ...,
            "-q",
            "--quiet",
            help="No extra output is generated, the CLI prints only the directory with the cached models.",
        ),
    ] = False,
)

Source from the content-addressed store, hash-verified

37
38@app.command("download")
39def download(
40 output_dir: Annotated[
41 Path,
42 typer.Option(
43 ...,
44 "-o",
45 "--output-dir",
46 help="The directory where all the models are downloaded.",
47 ),
48 ] = (settings.cache_dir / "models"),
49 force: Annotated[
50 bool, typer.Option(..., help="If true, the download will be forced")
51 ] = False,
52 models: Annotated[
53 Optional[list[_AvailableModels]],
54 typer.Argument(
55 help=f"Models to download (default behavior: all will be downloaded)",
56 ),
57 ] = None,
58 quiet: Annotated[
59 bool,
60 typer.Option(
61 ...,
62 "-q",
63 "--quiet",
64 help="No extra output is generated, the CLI prints only the directory with the cached models.",
65 ),
66 ] = False,
67):
68 if not quiet:
69 FORMAT = "%(message)s"
70 logging.basicConfig(
71 level=logging.INFO,
72 format="[blue]%(message)s[/blue]",
73 datefmt="[%X]",
74 handlers=[RichHandler(show_level=False, show_time=False, markup=True)],
75 )
76 to_download = models or [m for m in _AvailableModels]
77 output_dir = download_models(
78 output_dir=output_dir,
79 force=force,
80 progress=(not quiet),
81 with_layout=_AvailableModels.LAYOUT in to_download,
82 with_tableformer=_AvailableModels.TABLEFORMER in to_download,
83 with_code_formula=_AvailableModels.CODE_FORMULA in to_download,
84 with_picture_classifier=_AvailableModels.PICTURE_CLASSIFIER in to_download,
85 with_smolvlm=_AvailableModels.SMOLVLM in to_download,
86 with_easyocr=_AvailableModels.EASYOCR in to_download,
87 )
88
89 if quiet:
90 typer.echo(output_dir)
91 else:
92 typer.secho(f"\nModels downloaded into: {output_dir}.", fg="green")
93
94 console.print(
95 "\n",
96 "Docling can now be configured for running offline using the local artifacts.\n\n",

Callers

nothing calls this directly

Calls 1

download_modelsFunction · 0.90

Tested by

no test coverage detected