refactor: centralize source API requests, polling, and path parsing
- Add request_source_response and request_source_json helpers with 429 retry logic - Introduce shared split_path_segments and parse_provider_model_url utilities - Migrate CivitAI, CivArchive, HuggingFace, and ModelList sources to centralized helpers - Add generic pollBackgroundTask utility for frontend progress polling - Add tests for request_source_json, split_path_segments, parse_provider_model_url - Add huggingface-hub to requirements
This commit is contained in:
@@ -1079,3 +1079,22 @@ def find_metadata_sidecar_path(model_path: str) -> str:
|
||||
return path
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
def split_path_segments(path_value: Any, filter_dots: bool = True) -> list[str]:
|
||||
"""Split path into standard segments, replacing backslashes and filtering empty segments."""
|
||||
text = str(path_value or "").replace("\\", "/").strip()
|
||||
if not text:
|
||||
return []
|
||||
|
||||
parts = []
|
||||
for raw_part in text.split("/"):
|
||||
part = raw_part.strip()
|
||||
if not part:
|
||||
continue
|
||||
if filter_dots and part in {".", ".."}:
|
||||
continue
|
||||
parts.append(part)
|
||||
|
||||
return parts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user