mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 11:11:26 -03:00
e0052cd237
The download modal's location step decided between checkpoint and unet roots using only the CivitAI file-type signal, while the backend also falls back to DIFFUSION_MODEL_BASE_MODELS. Models like Anima (file type "Model") were offered checkpoint roots in the UI even though use_default_paths would route them to the unet root. - Extract the two-tier decision into py/services/download_routing.py and reuse it in DownloadManager._execute_download - Add POST /api/lm/download/routing so the UI asks the backend for the routing decision; fall back to the local file-type check on failure - ModelVersionsTab: search both checkpoint and unet roots when resolving an existing version's download path
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Tests for the shared download routing decision."""
|
|
|
|
import pytest
|
|
|
|
from py.services.download_routing import is_diffusion_model_download
|
|
|
|
|
|
@pytest.mark.parametrize("file_type", ["UNet", "Diffusion Model"])
|
|
def test_file_type_signal_routes_to_unet(file_type):
|
|
assert is_diffusion_model_download(
|
|
"checkpoint", file_types=[file_type], base_model="SDXL 1.0"
|
|
)
|
|
|
|
|
|
def test_base_model_fallback_routes_to_unet():
|
|
"""The reported Anima case: file type is plain "Model", but the
|
|
baseModel is a known diffusion model."""
|
|
assert is_diffusion_model_download(
|
|
"checkpoint", file_types=["Model"], base_model="Anima"
|
|
)
|
|
|
|
|
|
def test_regular_checkpoint_stays_on_checkpoint_roots():
|
|
assert not is_diffusion_model_download(
|
|
"checkpoint", file_types=["Model"], base_model="SDXL 1.0"
|
|
)
|
|
|
|
|
|
def test_non_checkpoint_types_never_route_to_unet():
|
|
assert not is_diffusion_model_download(
|
|
"lora", file_types=["UNet"], base_model="Anima"
|
|
)
|
|
assert not is_diffusion_model_download(
|
|
"embedding", file_types=["Diffusion Model"], base_model="Anima"
|
|
)
|
|
|
|
|
|
def test_empty_inputs_stay_on_checkpoint_roots():
|
|
assert not is_diffusion_model_download("checkpoint")
|
|
assert not is_diffusion_model_download("checkpoint", file_types=[], base_model="")
|