From 9b5d35c74d9e3e737fd1cbf07b6cce5120f2b8fb Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 27 Aug 2023 23:22:46 +1000 Subject: [PATCH] sort execution order by PRIORITY --- execution.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/execution.py b/execution.py index e10fdbb60..93cb27417 100644 --- a/execution.py +++ b/execution.py @@ -367,6 +367,11 @@ class PromptExecutor: while len(to_execute) > 0: #always execute the output that depends on the least amount of unexecuted nodes first to_execute = sorted(list(map(lambda a: (len(recursive_will_execute(prompt, self.outputs, a[-1])), a[-1]), to_execute))) + #except that we execute nodes with higher PRIOIRTY first + def priority(prompt, item): + class_ = nodes.NODE_CLASS_MAPPINGS[prompt[item]['class_type']] + return class_.PRIORITY if hasattr(class_, 'PRIORITY') else 0 + to_execute = sorted( to_execute, key = lambda a : priority(prompt, a[-1]), reverse=True ) output_node_id = to_execute.pop(0)[-1] # This call shouldn't raise anything if there's an error deep in