Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion comfy_config/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import List, Optional

Expand Down Expand Up @@ -50,6 +50,7 @@ class ComfyConfig(BaseModel):
icon: str = Field(default="", alias="Icon")
models: List[Model] = Field(default_factory=list, alias="Models")
includes: List[str] = Field(default_factory=list)
web: Optional[str] = None


class License(BaseModel):
Expand All @@ -66,6 +67,18 @@ class ProjectConfig(BaseModel):
license: License = Field(default_factory=License)
urls: URLs = Field(default_factory=URLs)

@field_validator('license', mode='before')
@classmethod
def validate_license(cls, v):
if isinstance(v, str):
return License(text=v)
elif isinstance(v, dict):
return License(**v)
elif isinstance(v, License):
return v
else:
return License()


class PyProjectConfig(BaseModel):
project: ProjectConfig = Field(default_factory=ProjectConfig)
Expand Down
16 changes: 16 additions & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import latent_preview
import node_helpers

from comfy_config import config_parser

def before_node_execution():
comfy.model_management.throw_exception_if_processing_interrupted()

Expand Down Expand Up @@ -2125,6 +2127,20 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes

LOADED_MODULE_DIRS[module_name] = os.path.abspath(module_dir)

project_config = config_parser.extract_node_configuration(module_path)

web_dir_name = project_config.tool_comfy.web

if web_dir_name:
web_dir_path = os.path.join(module_path, web_dir_name)

if os.path.isdir(web_dir_path):
project_name = project_config.project.name

EXTENSION_WEB_DIRS[project_name] = web_dir_path

logging.info("Automatically register web folder {} for {}".format(web_dir_name, project_name))

if hasattr(module, "WEB_DIRECTORY") and getattr(module, "WEB_DIRECTORY") is not None:
web_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "WEB_DIRECTORY")))
if os.path.isdir(web_dir):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ spandrel
soundfile
av>=14.2.0
pydantic~=2.0
pydantic-settings~=2.0