From 62b88aae58b408f67e0151499f8c1a777297854a Mon Sep 17 00:00:00 2001 From: StableLlama Date: Mon, 9 Jun 2025 17:32:13 +0200 Subject: [PATCH 1/2] Fix control flow node bugs --- pyproject.toml | 2 +- src/basic_data_handling/control_flow_nodes.py | 14 +++++----- src/basic_data_handling/path_nodes.py | 28 +++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ba588ff..fcf3b52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "basic_data_handling" -version = "0.4.1" +version = "0.4.2" description = """Basic Python functions for manipulating data that every programmer is used to. Comprehensive node collection for data manipulation in ComfyUI workflows. diff --git a/src/basic_data_handling/control_flow_nodes.py b/src/basic_data_handling/control_flow_nodes.py index 772d622..64fa3ed 100644 --- a/src/basic_data_handling/control_flow_nodes.py +++ b/src/basic_data_handling/control_flow_nodes.py @@ -188,7 +188,7 @@ def check_lazy_status(self, select: int, **kwargs) -> list[str]: return needed - def execute(self, selector: int, **kwargs) -> tuple[Any]: + def execute(self, select: int, **kwargs) -> tuple[Any]: # Build a case array from all case_X inputs cases = [] for i in range(len(kwargs)): @@ -199,8 +199,8 @@ def execute(self, selector: int, **kwargs) -> tuple[Any]: break # Return the selected case if valid - if 0 <= selector < len(cases) and cases[selector] is not None: - return (cases[selector],) + if 0 <= select < len(cases) and cases[select] is not None: + return (cases[select],) # If select is out of range or the selected case is None, return default return (kwargs.get("default"),) @@ -229,10 +229,6 @@ def INPUT_TYPES(cls): DESCRIPTION = cleandoc(__doc__ or "") FUNCTION = "execute" - @classmethod - def IS_CHANGED(s, value: Any): - return float("NaN") # not equal to anything -> trigger recalculation - def execute(self, value: Any, select: bool = True) -> tuple[Any]: if select: return (value,) @@ -296,6 +292,10 @@ def INPUT_TYPES(cls): DESCRIPTION = cleandoc(__doc__ or "") FUNCTION = "execute" + @classmethod + def IS_CHANGED(s, value: Any): + return float("NaN") # not equal to anything -> trigger recalculation + def execute(self, value: Any) -> tuple[Any, int]: return (value,) diff --git a/src/basic_data_handling/path_nodes.py b/src/basic_data_handling/path_nodes.py index a7af9e9..a2d020f 100644 --- a/src/basic_data_handling/path_nodes.py +++ b/src/basic_data_handling/path_nodes.py @@ -564,6 +564,32 @@ def split_ext(self, path: str) -> tuple[str, str]: return os.path.splitext(path) +class PathCombo(ComfyNodeABC): + """ + Converts a path to a combo type. + + This node takes a path string input and outputs it as a COMBO type with the path + as the single entry in the options list. This can be useful when you need to pass + a path to nodes that expect a COMBO input selection. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "path": (IO.STRING, {"default": ""}), + } + } + + RETURN_TYPES = ("COMBO",) + RETURN_NAMES = ("path combo",) + CATEGORY = "Basic/Path" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "to_combo" + + def to_combo(self, path: str) -> tuple[str]: + return ([path],) + + NODE_CLASS_MAPPINGS = { "Basic data handling: PathAbspath": PathAbspath, "Basic data handling: PathBasename": PathBasename, @@ -585,6 +611,7 @@ def split_ext(self, path: str) -> tuple[str, str]: "Basic data handling: PathRelative": PathRelative, "Basic data handling: PathSplit": PathSplit, "Basic data handling: PathSplitExt": PathSplitExt, + "Basic data handling: PathCombo": PathCombo, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -608,4 +635,5 @@ def split_ext(self, path: str) -> tuple[str, str]: "Basic data handling: PathRelative": "relative", "Basic data handling: PathSplit": "split", "Basic data handling: PathSplitExt": "splitext", + "Basic data handling: PathCombo": "to combo", } From 02d9d697259f8ee4e717a61b0b50f01bd26dea6c Mon Sep 17 00:00:00 2001 From: StableLlama Date: Mon, 9 Jun 2025 17:38:42 +0200 Subject: [PATCH 2/2] Remove unintended change --- src/basic_data_handling/path_nodes.py | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/src/basic_data_handling/path_nodes.py b/src/basic_data_handling/path_nodes.py index a2d020f..a7af9e9 100644 --- a/src/basic_data_handling/path_nodes.py +++ b/src/basic_data_handling/path_nodes.py @@ -564,32 +564,6 @@ def split_ext(self, path: str) -> tuple[str, str]: return os.path.splitext(path) -class PathCombo(ComfyNodeABC): - """ - Converts a path to a combo type. - - This node takes a path string input and outputs it as a COMBO type with the path - as the single entry in the options list. This can be useful when you need to pass - a path to nodes that expect a COMBO input selection. - """ - @classmethod - def INPUT_TYPES(cls): - return { - "required": { - "path": (IO.STRING, {"default": ""}), - } - } - - RETURN_TYPES = ("COMBO",) - RETURN_NAMES = ("path combo",) - CATEGORY = "Basic/Path" - DESCRIPTION = cleandoc(__doc__ or "") - FUNCTION = "to_combo" - - def to_combo(self, path: str) -> tuple[str]: - return ([path],) - - NODE_CLASS_MAPPINGS = { "Basic data handling: PathAbspath": PathAbspath, "Basic data handling: PathBasename": PathBasename, @@ -611,7 +585,6 @@ def to_combo(self, path: str) -> tuple[str]: "Basic data handling: PathRelative": PathRelative, "Basic data handling: PathSplit": PathSplit, "Basic data handling: PathSplitExt": PathSplitExt, - "Basic data handling: PathCombo": PathCombo, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -635,5 +608,4 @@ def to_combo(self, path: str) -> tuple[str]: "Basic data handling: PathRelative": "relative", "Basic data handling: PathSplit": "split", "Basic data handling: PathSplitExt": "splitext", - "Basic data handling: PathCombo": "to combo", }