From 4712df8a05c60fd247fc59d2a934b4822c8dc2cb Mon Sep 17 00:00:00 2001 From: Jacob Segal Date: Sun, 16 Jun 2024 20:33:30 -0700 Subject: [PATCH] Add documentation on `check_lazy_status` --- custom_nodes/example_node.py.example | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/custom_nodes/example_node.py.example b/custom_nodes/example_node.py.example index f066325930d..20f9bea75da 100644 --- a/custom_nodes/example_node.py.example +++ b/custom_nodes/example_node.py.example @@ -54,7 +54,8 @@ class Example: "min": 0, #Minimum value "max": 4096, #Maximum value "step": 64, #Slider's step - "display": "number" # Cosmetic only: display as "number" or "slider" + "display": "number", # Cosmetic only: display as "number" or "slider" + "lazy": True # Will only be evaluated if check_lazy_status requires it }), "float_field": ("FLOAT", { "default": 1.0, @@ -62,11 +63,14 @@ class Example: "max": 10.0, "step": 0.01, "round": 0.001, #The value represeting the precision to round to, will be set to the step value by default. Can be set to False to disable rounding. - "display": "number"}), + "display": "number", + "lazy": True + }), "print_to_screen": (["enable", "disable"],), "string_field": ("STRING", { "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node - "default": "Hello World!" + "default": "Hello World!", + "lazy": True }), }, } @@ -80,6 +84,23 @@ class Example: CATEGORY = "Example" + def check_lazy_status(self, image, string_field, int_field, float_field, print_to_screen): + """ + Return a list of input names that need to be evaluated. + + This function will be called if there are any lazy inputs which have not yet been + evaluated. As long as you return at least one field which has not yet been evaluated + (and more exist), this function will be called again once the value of the requested + field is available. + + Any evaluated inputs will be passed as arguments to this function. Any unevaluated + inputs will have the value None. + """ + if print_to_screen == "enable": + return ["int_field", "float_field", "string_field"] + else: + return [] + def test(self, image, string_field, int_field, float_field, print_to_screen): if print_to_screen == "enable": print(f"""Your input contains: