Skip to content

Commit 52979a6

Browse files
authored
Fix Prediction.output_iterator (#106)
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. Signed-off-by: Dominic Baggott <dominic.baggott@gmail.com>
1 parent a7c7c5d commit 52979a6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

replicate/prediction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ 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+
yield from new_output
3837
previous_output = output
3938
time.sleep(self._client.poll_interval)
4039
self.reload()

0 commit comments

Comments
 (0)