Skip to content

Commit 30cc968

Browse files
committed
Fix Prediction.output_iterator
The `output` variable is shadowed by the yielding loop, so when we hit the line: previous_output = output the value of `output` refers to the last value of `output` from the loop above, not the total output we received. That causes the client to shrink the output down to a single string (which, inconveniently, also is a valid argument to `len()`), which means we take the wrong slice of the output the next time through the loop.
1 parent a7c7c5d commit 30cc968

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

replicate/prediction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def output_iterator(self) -> Iterator[Any]:
3333
while self.status not in ["succeeded", "failed", "canceled"]:
3434
output = self.output or []
3535
new_output = output[len(previous_output) :]
36-
for output in new_output:
37-
yield output
36+
for o in new_output:
37+
yield o
3838
previous_output = output
3939
time.sleep(self._client.poll_interval)
4040
self.reload()

0 commit comments

Comments
 (0)