Skip to content

Commit

Permalink
fix: input model generation no default for path inputs
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Nov 11, 2024
1 parent 9a3d2af commit 3c36cfc
Show file tree
Hide file tree
Showing 3 changed files with 429 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = [{ name = "Frost Ming", email = "frost@bentoml.com" }]
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"comfy-cli>=0.0.14",
"pydantic>=2.9",
"comfy-cli>=1.2.8",
]
dynamic = ["version"]

Expand Down
11 changes: 8 additions & 3 deletions src/comfyui_idl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"BentoOutputImage",
}

BENTO_PATH_INPUT_NODES = {
"BentoInputPath",
"BentoInputImage",
}


def _get_node_value(node: dict) -> Any:
return next(iter(node["inputs"].values()))
Expand Down Expand Up @@ -121,10 +126,10 @@ def generate_input_model(workflow: dict) -> type[BaseModel]:
class_type = node["class_type"]
if class_type in CLASS_TYPES:
ann = CLASS_TYPES[class_type]
if class_type != "BentoInputPath":
field = (ann, Field(default=_get_node_value(node)))
else:
if class_type in BENTO_PATH_INPUT_NODES:
field = (ann, Field())
else:
field = (ann, Field(default=_get_node_value(node)))
input_fields[name] = field
else:
raise ValueError(f"Unsupported class type: {class_type}")
Expand Down
Loading

0 comments on commit 3c36cfc

Please sign in to comment.