From d3e49a47cfbdffdc4a6ba68cba6f6464b593ac12 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Wed, 22 May 2024 05:03:54 +0100 Subject: [PATCH] Don't iterate if the job iterator isn't present in outputs If orig_execute encountered an error and did not run, job iterator will be preent in the prompt but not in the outputs. This would cause a second exception if some other node had an error, making it look like the problem is in job iterator when it is not. Fixes #3 --- job.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/job.py b/job.py index 0524729..523439b 100644 --- a/job.py +++ b/job.py @@ -190,20 +190,22 @@ 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 - if job_iterator is not None: - steps = self.outputs[job_iterator][1][0] - 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) + 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