mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
- Remove backward compatibility code for `model_type` in `ModelScanner._build_cache_entry()` - Update `CheckpointScanner` to only handle `sub_type` in `adjust_metadata()` and `adjust_cached_entry()` - Delete deprecated aliases `resolve_civitai_model_type` and `normalize_civitai_model_type` from `model_query.py` - Update frontend components (`RecipeModal.js`, `ModelCard.js`, etc.) to use `sub_type` instead of `model_type` - Update API response format to return only `sub_type`, removing `model_type` from service responses - Revise technical documentation to mark Phase 5 as completed and remove outdated TODO items All cleanup tasks for the model type refactoring are now complete, ensuring consistent use of `sub_type` across the codebase.
56 lines
2.4 KiB
Python
56 lines
2.4 KiB
Python
import os
|
|
import logging
|
|
from typing import Dict
|
|
|
|
from .base_model_service import BaseModelService
|
|
from ..utils.models import CheckpointMetadata
|
|
from ..config import config
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class CheckpointService(BaseModelService):
|
|
"""Checkpoint-specific service implementation"""
|
|
|
|
def __init__(self, scanner, update_service=None):
|
|
"""Initialize Checkpoint service
|
|
|
|
Args:
|
|
scanner: Checkpoint scanner instance
|
|
update_service: Optional service for remote update tracking.
|
|
"""
|
|
super().__init__("checkpoint", scanner, CheckpointMetadata, update_service=update_service)
|
|
|
|
async def format_response(self, checkpoint_data: Dict) -> Dict:
|
|
"""Format Checkpoint data for API response"""
|
|
# Get sub_type from cache entry (new canonical field)
|
|
sub_type = checkpoint_data.get("sub_type", "checkpoint")
|
|
|
|
return {
|
|
"model_name": checkpoint_data["model_name"],
|
|
"file_name": checkpoint_data["file_name"],
|
|
"preview_url": config.get_preview_static_url(checkpoint_data.get("preview_url", "")),
|
|
"preview_nsfw_level": checkpoint_data.get("preview_nsfw_level", 0),
|
|
"base_model": checkpoint_data.get("base_model", ""),
|
|
"folder": checkpoint_data["folder"],
|
|
"sha256": checkpoint_data.get("sha256", ""),
|
|
"file_path": checkpoint_data["file_path"].replace(os.sep, "/"),
|
|
"file_size": checkpoint_data.get("size", 0),
|
|
"modified": checkpoint_data.get("modified", ""),
|
|
"tags": checkpoint_data.get("tags", []),
|
|
"from_civitai": checkpoint_data.get("from_civitai", True),
|
|
"usage_count": checkpoint_data.get("usage_count", 0),
|
|
"notes": checkpoint_data.get("notes", ""),
|
|
"sub_type": sub_type,
|
|
"favorite": checkpoint_data.get("favorite", False),
|
|
"update_available": bool(checkpoint_data.get("update_available", False)),
|
|
"civitai": self.filter_civitai_data(checkpoint_data.get("civitai", {}), minimal=True)
|
|
}
|
|
|
|
def find_duplicate_hashes(self) -> Dict:
|
|
"""Find Checkpoints with duplicate SHA256 hashes"""
|
|
return self.scanner._hash_index.get_duplicate_hashes()
|
|
|
|
def find_duplicate_filenames(self) -> Dict:
|
|
"""Find Checkpoints with conflicting filenames"""
|
|
return self.scanner._hash_index.get_duplicate_filenames()
|