From f257fc999fde8e9695e4755902c75e7f7192fe2b Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Wed, 21 Aug 2024 00:01:34 -0400 Subject: [PATCH] Add optional deprecated/experimental flag to node class (#4506) * Add optional deprecated flag to node class * nit * Add experimental flag --- custom_nodes/example_node.py.example | 12 +++++++++--- server.py | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/custom_nodes/example_node.py.example b/custom_nodes/example_node.py.example index 9c68ab76..29ab2aa7 100644 --- a/custom_nodes/example_node.py.example +++ b/custom_nodes/example_node.py.example @@ -4,14 +4,14 @@ class Example: Class methods ------------- - INPUT_TYPES (dict): + INPUT_TYPES (dict): Tell the main program input parameters of nodes. IS_CHANGED: optional method to control when the node is re executed. Attributes ---------- - RETURN_TYPES (`tuple`): + RETURN_TYPES (`tuple`): The type of each element in the output tuple. RETURN_NAMES (`tuple`): Optional: The name of each output in the output tuple. @@ -23,13 +23,19 @@ class Example: Assumed to be False if not present. CATEGORY (`str`): The category the node should appear in the UI. + DEPRECATED (`bool`): + Indicates whether the node is deprecated. Deprecated nodes are hidden by default in the UI, but remain + functional in existing workflows that use them. + EXPERIMENTAL (`bool`): + Indicates whether the node is experimental. Experimental nodes are marked as such in the UI and may be subject to + significant changes or removal in future versions. Use with caution in production workflows. execute(s) -> tuple || None: The entry point method. The name of this method must be the same as the value of property `FUNCTION`. For example, if `FUNCTION = "execute"` then this method's name must be `execute`, if `FUNCTION = "foo"` then it must be `foo`. """ def __init__(self): pass - + @classmethod def INPUT_TYPES(s): """ diff --git a/server.py b/server.py index a2bb376a..23ebdb7b 100644 --- a/server.py +++ b/server.py @@ -442,6 +442,11 @@ class PromptServer(): if hasattr(obj_class, 'OUTPUT_TOOLTIPS'): info['output_tooltips'] = obj_class.OUTPUT_TOOLTIPS + + if getattr(obj_class, "DEPRECATED", False): + info['deprecated'] = True + if getattr(obj_class, "EXPERIMENTAL", False): + info['experimental'] = True return info @routes.get("/object_info")