Download Engine¶
engine
¶
Unified model download engine driven by a JSON catalog.
Replaces 8 separate PowerShell download scripts (~1200 lines) with a single
data-driven engine. The catalog format is model_manifest.json v3,
hosted in the Assets repo and consumed by both the installer and the Toolkit.
v3 format:
- Hierarchical structure: Family → Model → Variant
_family_metaper family (display_name, description)_metaat the model level (bundle_type, loader_type, clip_type)_sourcessection with HuggingFace + ModelScope mirrorspath— same relative path on both mirrorssha256per file for post-download verificationbundle_type(image,video,image_inpaint) for Toolkit filtering- Smart fallback: tries primary source, falls back to secondary on failure
The path_type system maps logical names (e.g. "flux_diff", "clip", "vae") to actual directory paths relative to the models folder.
SourcesConfig
¶
Bases: BaseModel
Mirror base URLs for model downloads.
ModelFile
¶
Bases: BaseModel
A single file within a model variant.
path is a relative path identical on both mirrors
(e.g. diffusion_models/FLUX/flux1-dev-fp16.safetensors).
filename
property
¶
Derive filename from the path.
ModelVariant
¶
Bases: BaseModel
A quality variant (e.g. fp16, GGUF_Q4) with its VRAM requirement.
BundleMeta
¶
Bases: BaseModel
Metadata for a model bundle.
FamilyMeta
¶
Bases: BaseModel
Metadata for a model family.
ModelBundle
¶
Bases: BaseModel
A model bundle (e.g. FLUX/Dev, WAN_2.1/T2V) with metadata and variants.
The meta field contains shared info (loader/clip type, bundle_type). variants maps variant names (fp16, fp8, GGUF_Q8, etc.) to ModelVariant.
ModelCatalog
¶
Bases: BaseModel
The complete model catalog — all bundles from the JSON file.
load_catalog(path)
¶
Load and parse a v3 model catalog JSON file.
v3 uses family nesting: FLUX → Dev → {variants}.
Families are flattened to compound keys: FLUX/Dev.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the JSON catalog file. |
required |
Returns:
| Type | Description |
|---|---|
ModelCatalog
|
Parsed ModelCatalog. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If catalog file doesn't exist. |
Source code in src/downloader/engine.py
resolve_file_path(models_dir, path_type, filename, path_mapping)
¶
Resolve a path_type + filename to an actual file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models_dir
|
Path
|
Root models directory. |
required |
path_type
|
str
|
Logical path type (e.g. "flux_diff", "clip"). |
required |
filename
|
str
|
The filename. |
required |
path_mapping
|
dict[str, str]
|
Dictionary mapping path types to subdirectories. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Full path to the file. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path_type is unknown. |
Source code in src/downloader/engine.py
download_variant(bundle, variant_name, variant, models_dir, catalog)
¶
Download all files for a specific model variant.
Tries each mirror in order (HuggingFace first, ModelScope fallback). Verifies SHA256 after download when available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
ModelBundle
|
The parent bundle. |
required |
variant_name
|
str
|
Name of the variant (e.g. "fp16"). |
required |
variant
|
ModelVariant
|
The variant with its file list. |
required |
models_dir
|
Path
|
Root models directory. |
required |
catalog
|
ModelCatalog
|
The model catalog for sources and path mapping. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of files downloaded. |
Source code in src/downloader/engine.py
list_bundles(catalog)
¶
Display all available model bundles in a numbered table.
Source code in src/downloader/engine.py
interactive_download(catalog, models_dir)
¶
Run an interactive download session.
Shows a numbered table of all models. User picks by number, then chooses a variant for each selected model.