Download comfy_api/internal/api_registry.py from Elsen001/wan22-animate-character-replace: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/Elsen001/wan22-animate-character-replace/resolve/main/comfy_api/internal/api_registry.py
- Command line
-
hf download hf://spaces/Elsen001/wan22-animate-character-replace/comfy_api/internal/api_registry.py
-
curl -L -o api_registry.py https://huggingface.co/spaces/Elsen001/wan22-animate-character-replace/resolve/main/comfy_api/internal/api_registry.py
1.1 kB
| from typing import NamedTuple | |
| from comfy_api.internal.singleton import ProxiedSingleton | |
| from packaging import version as packaging_version | |
| class ComfyAPIBase(ProxiedSingleton): | |
| def __init__(self): | |
| pass | |
| class ComfyAPIWithVersion(NamedTuple): | |
| version: str | |
| api_class: type[ComfyAPIBase] | |
| def parse_version(version_str: str) -> packaging_version.Version: | |
| """ | |
| Parses a version string into a packaging_version.Version object. | |
| Raises ValueError if the version string is invalid. | |
| """ | |
| if version_str == "latest": | |
| return packaging_version.parse("9999999.9999999.9999999") | |
| return packaging_version.parse(version_str) | |
| registered_versions: list[ComfyAPIWithVersion] = [] | |
| def register_versions(versions: list[ComfyAPIWithVersion]): | |
| versions.sort(key=lambda x: parse_version(x.version)) | |
| global registered_versions | |
| registered_versions = versions | |
| def get_all_versions() -> list[ComfyAPIWithVersion]: | |
| """ | |
| Returns a list of all registered ComfyAPI versions. | |
| """ | |
| return registered_versions | |