Skip to content

Commit 5b12b55

Browse files
Add new fields to the config types (comfyanonymous#8507)
1 parent e9e9a03 commit 5b12b55

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

comfy_config/config_parser.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,43 @@
1111
PyProjectSettings
1212
)
1313

14+
def validate_and_extract_os_classifiers(classifiers: list) -> list:
15+
os_classifiers = [c for c in classifiers if c.startswith("Operating System :: ")]
16+
if not os_classifiers:
17+
return []
18+
19+
os_values = [c[len("Operating System :: ") :] for c in os_classifiers]
20+
valid_os_prefixes = {"Microsoft", "POSIX", "MacOS", "OS Independent"}
21+
22+
for os_value in os_values:
23+
if not any(os_value.startswith(prefix) for prefix in valid_os_prefixes):
24+
return []
25+
26+
return os_values
27+
28+
29+
def validate_and_extract_accelerator_classifiers(classifiers: list) -> list:
30+
accelerator_classifiers = [c for c in classifiers if c.startswith("Environment ::")]
31+
if not accelerator_classifiers:
32+
return []
33+
34+
accelerator_values = [c[len("Environment :: ") :] for c in accelerator_classifiers]
35+
36+
valid_accelerators = {
37+
"GPU :: NVIDIA CUDA",
38+
"GPU :: AMD ROCm",
39+
"GPU :: Intel Arc",
40+
"NPU :: Huawei Ascend",
41+
"GPU :: Apple Metal",
42+
}
43+
44+
for accelerator_value in accelerator_values:
45+
if accelerator_value not in valid_accelerators:
46+
return []
47+
48+
return accelerator_values
49+
50+
1451
"""
1552
Extract configuration from a custom node directory's pyproject.toml file or a Python file.
1653
@@ -78,6 +115,24 @@ def extract_node_configuration(path) -> Optional[PyProjectConfig]:
78115
tool_data = raw_settings.tool
79116
comfy_data = tool_data.get("comfy", {}) if tool_data else {}
80117

118+
dependencies = project_data.get("dependencies", [])
119+
supported_comfyui_frontend_version = ""
120+
for dep in dependencies:
121+
if isinstance(dep, str) and dep.startswith("comfyui-frontend-package"):
122+
supported_comfyui_frontend_version = dep.removeprefix("comfyui-frontend-package")
123+
break
124+
125+
supported_comfyui_version = comfy_data.get("requires-comfyui", "")
126+
127+
classifiers = project_data.get('classifiers', [])
128+
supported_os = validate_and_extract_os_classifiers(classifiers)
129+
supported_accelerators = validate_and_extract_accelerator_classifiers(classifiers)
130+
131+
project_data['supported_os'] = supported_os
132+
project_data['supported_accelerators'] = supported_accelerators
133+
project_data['supported_comfyui_frontend_version'] = supported_comfyui_frontend_version
134+
project_data['supported_comfyui_version'] = supported_comfyui_version
135+
81136
return PyProjectConfig(project=project_data, tool_comfy=comfy_data)
82137

83138

comfy_config/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ComfyConfig(BaseModel):
5151
models: List[Model] = Field(default_factory=list, alias="Models")
5252
includes: List[str] = Field(default_factory=list)
5353
web: Optional[str] = None
54-
54+
banner_url: str = ""
5555

5656
class License(BaseModel):
5757
file: str = ""
@@ -66,6 +66,10 @@ class ProjectConfig(BaseModel):
6666
dependencies: List[str] = Field(default_factory=list)
6767
license: License = Field(default_factory=License)
6868
urls: URLs = Field(default_factory=URLs)
69+
supported_os: List[str] = Field(default_factory=list)
70+
supported_accelerators: List[str] = Field(default_factory=list)
71+
supported_comfyui_version: str = ""
72+
supported_comfyui_frontend_version: str = ""
6973

7074
@field_validator('license', mode='before')
7175
@classmethod

0 commit comments

Comments
 (0)