Remove executor hack, convert job to list instead
This makes the node pack work on the latest ComfyUI. Swap the JobIterator node for a JobToList node. Nothing else needs to change. This does mean that the workflow will be evaluated breadth-first instead of depth-first, which means intermediate results will be cached in memory and you won't get any output until the whole job is finished.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 703 KiB After Width: | Height: | Size: 685 KiB |
@@ -160,52 +160,21 @@ for t in ('INT', 'FLOAT', 'STRING'):
|
|||||||
|
|
||||||
|
|
||||||
@register_node
|
@register_node
|
||||||
class JobIterator:
|
class JobToList:
|
||||||
"""Magic node that runs the workflow multiple times until all steps are done."""
|
"""Converts a job into a list."""
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"job": ("JOB",),
|
"job": ("JOB",),
|
||||||
"start_step": ("INT", {"default": 0}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("ATTRIBUTES", "INT", "INT")
|
RETURN_TYPES = ("ATTRIBUTES",)
|
||||||
RETURN_NAMES = ("attributes", "count", "step")
|
RETURN_NAMES = ("attributes",)
|
||||||
|
OUTPUT_IS_LIST = (True,)
|
||||||
FUNCTION = "go"
|
FUNCTION = "go"
|
||||||
CATEGORY = "ali1234/job"
|
CATEGORY = "ali1234/job"
|
||||||
|
|
||||||
def go(self, job, start_step):
|
def go(self, job):
|
||||||
print(f'JobIterator: {start_step + 1} / {len(job)}')
|
return (job,)
|
||||||
return (job[start_step], len(job), start_step)
|
|
||||||
|
|
||||||
|
|
||||||
# finally monkey patch the prompt executor to handle batch prompts.
|
|
||||||
|
|
||||||
orig_execute = PromptExecutor.execute
|
|
||||||
|
|
||||||
|
|
||||||
def execute(self, prompt, prompt_id, extra_data={}, execute_outputs=[]):
|
|
||||||
print("Prompt executor has been patched by Job Iterator!")
|
|
||||||
orig_execute(self, prompt, prompt_id, extra_data, execute_outputs)
|
|
||||||
|
|
||||||
steps = None
|
|
||||||
job_iterator = None
|
|
||||||
for k, v in prompt.items():
|
|
||||||
try:
|
|
||||||
if v['class_type'] == 'JobIterator':
|
|
||||||
steps = self.outputs[k][1][0]
|
|
||||||
job_iterator = k
|
|
||||||
break
|
|
||||||
except KeyError:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
while prompt[job_iterator]['inputs']['start_step'] < (steps - 1):
|
|
||||||
prompt[job_iterator]['inputs']['start_step'] += 1
|
|
||||||
orig_execute(self, prompt, prompt_id, extra_data, execute_outputs)
|
|
||||||
|
|
||||||
|
|
||||||
PromptExecutor.execute = execute
|
|
||||||
|
|||||||
Reference in New Issue
Block a user