Skip to content

Commit 79ebe6e

Browse files
committed
Fix bug in output_iterator when prediction is terminal
1 parent 4ef4d82 commit 79ebe6e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

replicate/prediction.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ def output_iterator(self) -> Iterator[Any]:
248248
"""
249249
Return an iterator of the prediction output.
250250
"""
251+
if (
252+
self.status in ["succeeded", "failed", "canceled"]
253+
and self.output is not None
254+
):
255+
yield from self.output
251256

252257
# TODO: check output is list
253258
previous_output = self.output or []
@@ -270,6 +275,12 @@ async def async_output_iterator(self) -> AsyncIterator[Any]:
270275
"""
271276
Return an asynchronous iterator of the prediction output.
272277
"""
278+
if (
279+
self.status in ["succeeded", "failed", "canceled"]
280+
and self.output is not None
281+
):
282+
for item in self.output:
283+
yield item
273284

274285
# TODO: check output is list
275286
previous_output = self.output or []

0 commit comments

Comments
 (0)