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
+9 -1
View File
@@ -11,7 +11,12 @@ from pathlib import Path
import httpx
from gpu_rent.civitai import fetch_model_version, pick_preview_image, pick_primary_file
from gpu_rent.civitai import (
fetch_model_version,
file_size_bytes,
pick_preview_image,
pick_primary_file,
)
from gpu_rent.config import Config
from gpu_rent.errors import CloudError, GpuRentError
from gpu_rent.manifests import (
@@ -480,6 +485,9 @@ def seed_civitai(cfg: Config, host: str, log: Log) -> None:
f"{stem}.swarm.json": json.dumps(swarm, ensure_ascii=False, indent=2),
},
}
size_b = file_size_bytes(info)
if size_b:
job["size"] = size_b
preview = pick_preview_image(version)
if preview:
preview_url, preview_suffix = preview