mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-20 11:20:18 +08:00
Merge branch 'comfyanonymous:master' into master
This commit is contained in:
commit
603cacb14a
@ -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`).
|
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
|
default: bool | str | float | int | list | tuple
|
||||||
@ -154,7 +154,7 @@ class HiddenInputTypeDict(TypedDict):
|
|||||||
class InputTypeDict(TypedDict):
|
class InputTypeDict(TypedDict):
|
||||||
"""Provides type hinting for node INPUT_TYPES.
|
"""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]]
|
required: dict[str, tuple[IO, InputTypeOptions]]
|
||||||
@ -164,14 +164,14 @@ class InputTypeDict(TypedDict):
|
|||||||
hidden: HiddenInputTypeDict
|
hidden: HiddenInputTypeDict
|
||||||
"""Offers advanced functionality and server-client communication.
|
"""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):
|
class ComfyNodeABC(ABC):
|
||||||
"""Abstract base class for Comfy nodes. Includes the names and expected types of attributes.
|
"""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
|
DESCRIPTION: str
|
||||||
@ -188,7 +188,7 @@ class ComfyNodeABC(ABC):
|
|||||||
CATEGORY: str
|
CATEGORY: str
|
||||||
"""The category of the node, as per the "Add Node" menu.
|
"""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
|
EXPERIMENTAL: bool
|
||||||
"""Flags a node as experimental, informing users that it may change or not work as expected."""
|
"""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.
|
* 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 ``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": {}}
|
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.
|
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
|
INPUT_IS_LIST: bool
|
||||||
"""A flag indicating if this node implements the additional code necessary to deal with OUTPUT_IS_LIST nodes.
|
"""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``.
|
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]
|
OUTPUT_IS_LIST: tuple[bool]
|
||||||
"""A tuple indicating which node outputs are lists, but will be connected to nodes that expect individual items.
|
"""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`,
|
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.
|
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]
|
RETURN_TYPES: tuple[IO]
|
||||||
@ -258,19 +258,19 @@ class ComfyNodeABC(ABC):
|
|||||||
|
|
||||||
RETURN_TYPES = (IO.INT, "INT", "CUSTOM_TYPE")
|
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]
|
RETURN_NAMES: tuple[str]
|
||||||
"""The output slot names for each item in `RETURN_TYPES`, e.g. ``RETURN_NAMES = ("count", "filter_string")``
|
"""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]
|
OUTPUT_TOOLTIPS: tuple[str]
|
||||||
"""A tuple of strings to use as tooltips for node outputs, one for each item in `RETURN_TYPES`."""
|
"""A tuple of strings to use as tooltips for node outputs, one for each item in `RETURN_TYPES`."""
|
||||||
FUNCTION: str
|
FUNCTION: str
|
||||||
"""The name of the function to execute as a literal string, e.g. `FUNCTION = "execute"`
|
"""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).
|
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).
|
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]
|
need = [name for name in kwargs if kwargs[name] is None]
|
||||||
|
|||||||
@ -1022,8 +1022,6 @@ def is_directml_enabled():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def should_use_fp16(device=None, model_params=0, prioritize_performance=True, manual_cast=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 device is not None:
|
||||||
if is_device_cpu(device):
|
if is_device_cpu(device):
|
||||||
return False
|
return False
|
||||||
@ -1034,8 +1032,8 @@ def should_use_fp16(device=None, model_params=0, prioritize_performance=True, ma
|
|||||||
if FORCE_FP32:
|
if FORCE_FP32:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if directml_enabled:
|
if is_directml_enabled():
|
||||||
return False
|
return True
|
||||||
|
|
||||||
if (device is not None and is_device_mps(device)) or mps_mode():
|
if (device is not None and is_device_mps(device)) or mps_mode():
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -145,7 +145,7 @@ def test_load_extra_model_paths_expands_appdata(
|
|||||||
else:
|
else:
|
||||||
expected_base_path = '/Users/TestUser/AppData/Roaming/ComfyUI'
|
expected_base_path = '/Users/TestUser/AppData/Roaming/ComfyUI'
|
||||||
expected_calls = [
|
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)
|
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)
|
load_extra_path_config(dummy_yaml_name)
|
||||||
|
|
||||||
expected_checkpoints = os.path.abspath(os.path.join(str(tmp_path), sub_folder, "checkpoints"))
|
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), sub_folder, "some_value"))
|
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]
|
actual_paths = folder_paths.folder_names_and_paths["checkpoints"][0]
|
||||||
assert len(actual_paths) == 1, "Should have one path added for 'checkpoints'."
|
assert len(actual_paths) == 1, "Should have one path added for 'checkpoints'."
|
||||||
|
|||||||
@ -29,5 +29,6 @@ def load_extra_path_config(yaml_path):
|
|||||||
full_path = os.path.join(base_path, full_path)
|
full_path = os.path.join(base_path, full_path)
|
||||||
elif not os.path.isabs(full_path):
|
elif not os.path.isabs(full_path):
|
||||||
full_path = os.path.abspath(os.path.join(yaml_dir, y))
|
full_path = os.path.abspath(os.path.join(yaml_dir, y))
|
||||||
logging.info("Adding extra search path {} {}".format(x, full_path))
|
normalized_path = os.path.normpath(full_path)
|
||||||
folder_paths.add_model_folder_path(x, full_path, is_default)
|
logging.info("Adding extra search path {} {}".format(x, normalized_path))
|
||||||
|
folder_paths.add_model_folder_path(x, normalized_path, is_default)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user