From c5be423d6bf0e53d460471f49d75455e621773c0 Mon Sep 17 00:00:00 2001 From: Silver <65376327+silveroxides@users.noreply.github.com> Date: Thu, 20 Feb 2025 13:07:07 +0100 Subject: [PATCH 1/3] Fix link pointing to non-exisiting docs (#6891) * Fix link pointing to non-exisiting docs The current link is pointing to a path that does not exist any longer. I changed it to point to the currect correct path for custom nodes datatypes. * Update node_typing.py --- comfy/comfy_types/node_typing.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/comfy/comfy_types/node_typing.py b/comfy/comfy_types/node_typing.py index 0f70fdb23..0696dbe5e 100644 --- a/comfy/comfy_types/node_typing.py +++ b/comfy/comfy_types/node_typing.py @@ -85,7 +85,7 @@ class InputTypeOptions(TypedDict): Due to IDE limitations with unions, for now all options are available for all types (e.g. `label_on` is hinted even when the type is not `IO.BOOLEAN`). - Comfy Docs: https://docs.comfy.org/essentials/custom_node_datatypes + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/datatypes """ default: bool | str | float | int | list | tuple @@ -154,7 +154,7 @@ class HiddenInputTypeDict(TypedDict): class InputTypeDict(TypedDict): """Provides type hinting for node INPUT_TYPES. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_more_on_inputs + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/more_on_inputs """ required: dict[str, tuple[IO, InputTypeOptions]] @@ -164,14 +164,14 @@ class InputTypeDict(TypedDict): hidden: HiddenInputTypeDict """Offers advanced functionality and server-client communication. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_more_on_inputs#hidden-inputs + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/more_on_inputs#hidden-inputs """ class ComfyNodeABC(ABC): """Abstract base class for Comfy nodes. Includes the names and expected types of attributes. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview """ DESCRIPTION: str @@ -188,7 +188,7 @@ class ComfyNodeABC(ABC): CATEGORY: str """The category of the node, as per the "Add Node" menu. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview#category + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview#category """ EXPERIMENTAL: bool """Flags a node as experimental, informing users that it may change or not work as expected.""" @@ -202,9 +202,9 @@ class ComfyNodeABC(ABC): * Must include the ``required`` key, which describes all inputs that must be connected for the node to execute. * The ``optional`` key can be added to describe inputs which do not need to be connected. - * The ``hidden`` key offers some advanced functionality. More info at: https://docs.comfy.org/essentials/custom_node_more_on_inputs#hidden-inputs + * The ``hidden`` key offers some advanced functionality. More info at: https://docs.comfy.org/custom-nodes/backend/more_on_inputs#hidden-inputs - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview#input-types + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview#input-types """ return {"required": {}} @@ -219,7 +219,7 @@ class ComfyNodeABC(ABC): By default, a node is not considered an output. Set ``OUTPUT_NODE = True`` to specify that it is. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview#output-node + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview#output-node """ INPUT_IS_LIST: bool """A flag indicating if this node implements the additional code necessary to deal with OUTPUT_IS_LIST nodes. @@ -230,7 +230,7 @@ class ComfyNodeABC(ABC): A node can also override the default input behaviour and receive the whole list in a single call. This is done by setting a class attribute `INPUT_IS_LIST` to ``True``. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_lists#list-processing + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/lists#list-processing """ OUTPUT_IS_LIST: tuple[bool] """A tuple indicating which node outputs are lists, but will be connected to nodes that expect individual items. @@ -248,7 +248,7 @@ class ComfyNodeABC(ABC): the node should provide a class attribute `OUTPUT_IS_LIST`, which is a ``tuple[bool]``, of the same length as `RETURN_TYPES`, specifying which outputs which should be so treated. - Comfy Docs: https://docs.comfy.org/essentials/custom_node_lists#list-processing + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/lists#list-processing """ RETURN_TYPES: tuple[IO] @@ -258,19 +258,19 @@ class ComfyNodeABC(ABC): RETURN_TYPES = (IO.INT, "INT", "CUSTOM_TYPE") - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview#return-types + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview#return-types """ RETURN_NAMES: tuple[str] """The output slot names for each item in `RETURN_TYPES`, e.g. ``RETURN_NAMES = ("count", "filter_string")`` - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview#return-names + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview#return-names """ OUTPUT_TOOLTIPS: tuple[str] """A tuple of strings to use as tooltips for node outputs, one for each item in `RETURN_TYPES`.""" FUNCTION: str """The name of the function to execute as a literal string, e.g. `FUNCTION = "execute"` - Comfy Docs: https://docs.comfy.org/essentials/custom_node_server_overview#function + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/server_overview#function """ @@ -288,7 +288,7 @@ class CheckLazyMixin: Params should match the nodes execution ``FUNCTION`` (self, and all inputs by name). Will be executed repeatedly until it returns an empty list, or all requested items were already evaluated (and sent as params). - Comfy Docs: https://docs.comfy.org/essentials/custom_node_lazy_evaluation#defining-check-lazy-status + Comfy Docs: https://docs.comfy.org/custom-nodes/backend/lazy_evaluation#defining-check-lazy-status """ need = [name for name in kwargs if kwargs[name] is None] From 29d4384a75abb4ca90f5b64e70499f2120d76a3a Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Thu, 20 Feb 2025 04:09:45 -0800 Subject: [PATCH 2/3] Normalize extra_model_config.yaml paths to prevent duplicates. (#6885) * Normalize extra_model_config.yaml paths before adding. * Fix tests. * Fix tests. --- tests-unit/utils/extra_config_test.py | 6 +++--- utils/extra_config.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests-unit/utils/extra_config_test.py b/tests-unit/utils/extra_config_test.py index 6d232079e..eae1aa3d3 100644 --- a/tests-unit/utils/extra_config_test.py +++ b/tests-unit/utils/extra_config_test.py @@ -145,7 +145,7 @@ def test_load_extra_model_paths_expands_appdata( else: expected_base_path = '/Users/TestUser/AppData/Roaming/ComfyUI' expected_calls = [ - ('checkpoints', os.path.join(expected_base_path, 'models/checkpoints'), False), + ('checkpoints', os.path.normpath(os.path.join(expected_base_path, 'models/checkpoints')), False), ] assert mock_add_model_folder_path.call_count == len(expected_calls) @@ -197,8 +197,8 @@ def test_load_extra_path_config_relative_base_path( load_extra_path_config(dummy_yaml_name) - expected_checkpoints = os.path.abspath(os.path.join(str(tmp_path), sub_folder, "checkpoints")) - expected_some_value = os.path.abspath(os.path.join(str(tmp_path), sub_folder, "some_value")) + expected_checkpoints = os.path.abspath(os.path.join(str(tmp_path), "my_rel_base", "checkpoints")) + expected_some_value = os.path.abspath(os.path.join(str(tmp_path), "my_rel_base", "some_value")) actual_paths = folder_paths.folder_names_and_paths["checkpoints"][0] assert len(actual_paths) == 1, "Should have one path added for 'checkpoints'." diff --git a/utils/extra_config.py b/utils/extra_config.py index b7196e36f..a0fcda9e8 100644 --- a/utils/extra_config.py +++ b/utils/extra_config.py @@ -29,5 +29,6 @@ def load_extra_path_config(yaml_path): full_path = os.path.join(base_path, full_path) elif not os.path.isabs(full_path): full_path = os.path.abspath(os.path.join(yaml_dir, y)) - logging.info("Adding extra search path {} {}".format(x, full_path)) - folder_paths.add_model_folder_path(x, full_path, is_default) + normalized_path = os.path.normpath(full_path) + logging.info("Adding extra search path {} {}".format(x, normalized_path)) + folder_paths.add_model_folder_path(x, normalized_path, is_default) From 12da6ef581cd9f47a4341d74159ce32f3d2f3e8d Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Thu, 20 Feb 2025 09:29:59 -0500 Subject: [PATCH 3/3] Apparently directml supports fp16. --- comfy/model_management.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/comfy/model_management.py b/comfy/model_management.py index 9ff63f35d..9066e0dc2 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -1021,8 +1021,6 @@ def is_directml_enabled(): return False def should_use_fp16(device=None, model_params=0, prioritize_performance=True, manual_cast=False): - global directml_enabled - if device is not None: if is_device_cpu(device): return False @@ -1033,8 +1031,8 @@ def should_use_fp16(device=None, model_params=0, prioritize_performance=True, ma if FORCE_FP32: return False - if directml_enabled: - return False + if is_directml_enabled(): + return True if (device is not None and is_device_mps(device)) or mps_mode(): return True