From 1e74a4cf08820db067d5adbfb25c4c09e88ab2a9 Mon Sep 17 00:00:00 2001 From: Benjamin Berman Date: Tue, 18 Feb 2025 19:59:09 -0800 Subject: [PATCH] Fix absolute imports, fix linting issue with dataclass --- comfy/nodes/package_typing.py | 4 --- comfy/nodes_context.py | 6 ++--- comfy_extras/nodes/nodes_arithmetic.py | 34 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/comfy/nodes/package_typing.py b/comfy/nodes/package_typing.py index 3fbb50ab5..4ebdb9ec1 100644 --- a/comfy/nodes/package_typing.py +++ b/comfy/nodes/package_typing.py @@ -191,10 +191,6 @@ class ExportedNodes: class _ExportedNodesAsChainMap(ExportedNodes): - NODE_CLASS_MAPPINGS: ChainMap[str, CustomNode] = field(default_factory=ChainMap) - NODE_DISPLAY_NAME_MAPPINGS: ChainMap[str, str] = field(default_factory=ChainMap) - EXTENSION_WEB_DIRS: ChainMap[str, str] = field(default_factory=ChainMap) - @classmethod def from_iter(cls, *exported_nodes: ExportedNodes): en = _ExportedNodesAsChainMap() diff --git a/comfy/nodes_context.py b/comfy/nodes_context.py index f68d71133..e9e08dd6f 100644 --- a/comfy/nodes_context.py +++ b/comfy/nodes_context.py @@ -1,9 +1,9 @@ # todo: this should be defined in a common place, the fact that the nodes are imported by execution the way that they are is pretty radioactive import lazy_object_proxy -from comfy.execution_context import current_execution_context -from comfy.nodes.package import import_all_nodes_in_workspace -from comfy.nodes.package_typing import ExportedNodes, exported_nodes_view +from .execution_context import current_execution_context +from .nodes.package import import_all_nodes_in_workspace +from .nodes.package_typing import ExportedNodes, exported_nodes_view nodes: ExportedNodes = lazy_object_proxy.Proxy(import_all_nodes_in_workspace) diff --git a/comfy_extras/nodes/nodes_arithmetic.py b/comfy_extras/nodes/nodes_arithmetic.py index adef08472..af8f6eba5 100644 --- a/comfy_extras/nodes/nodes_arithmetic.py +++ b/comfy_extras/nodes/nodes_arithmetic.py @@ -513,6 +513,40 @@ class IntToFloat(CustomNode): return float(value), +class IntToString(CustomNode): + @classmethod + def INPUT_TYPES(cls) -> InputTypes: + return { + "required": { + "value": ("INT", {}), + } + } + + CATEGORY = "arithmetic" + RETURN_TYPES = ("STRING",) + FUNCTION = "execute" + + def execute(self, value: int = 0): + return str(value), + + +class FloatToString(CustomNode): + @classmethod + def INPUT_TYPES(cls) -> InputTypes: + return { + "required": { + "value": ("FLOAT", {}), + } + } + + CATEGORY = "arithmetic" + RETURN_TYPES = ("STRING",) + FUNCTION = "execute" + + def execute(self, value: float = 0): + return str(value), + + class FloatToInt(CustomNode): @classmethod def INPUT_TYPES(cls) -> InputTypes: