sort execution order by PRIORITY

This commit is contained in:
Chris 2023-08-27 23:22:46 +10:00
parent a57b0c797b
commit 9b5d35c74d

View File

@ -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