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:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user