Add file size conversion and enhance Civitai job processing

- Introduced the `file_size_bytes` function to convert Civitai model sizes from kilobytes to bytes, improving data handling.
- Updated the `seed_civitai` function to include file size in job definitions, enhancing model processing efficiency.
- Enhanced the `should_skip` function to utilize expected size for faster decision-making during job processing.
- Added tests for new functionality, ensuring robustness in file size handling and job processing logic.
This commit is contained in:
Leonid Pershin
2026-08-21 10:52:44 +03:00
parent 6cdd6ecfa1
commit ef743a6e6d
6 changed files with 260 additions and 14 deletions
+13
View File
@@ -80,6 +80,19 @@ def pick_primary_file(version: dict) -> dict | None:
return None
def file_size_bytes(info: dict) -> int | None:
"""Civitai ``sizeKB`` (float) → bytes, or None."""
raw = info.get("sizeKB")
if raw is None:
raw = info.get("sizeKb")
if raw is None:
return None
try:
return int(round(float(raw) * 1024.0))
except (TypeError, ValueError):
return None
def pick_preview_image(version: dict) -> tuple[str, str] | None:
"""First usable Civitai preview → (url, sidecar_suffix) for SwarmUI.