Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions replicate/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class ReplicateException(Exception):
class ModelError(ReplicateException):
"""An error from user's code in a model."""

prediction_id: str

def __init__(self, error: Optional[str], prediction_id: str) -> None:
self.prediction_id = prediction_id
super().__init__(error)


class ReplicateError(ReplicateException):
"""
Expand Down
4 changes: 2 additions & 2 deletions replicate/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def output_iterator(self) -> Iterator[Any]:
self.reload()

if self.status == "failed":
raise ModelError(self.error)
raise ModelError(self.error, self.id)

output = self.output or []
new_output = output[len(previous_output) :]
Expand All @@ -272,7 +272,7 @@ async def async_output_iterator(self) -> AsyncIterator[Any]:
await self.async_reload()

if self.status == "failed":
raise ModelError(self.error)
raise ModelError(self.error, self.id)

output = self.output or []
new_output = output[len(previous_output) :]
Expand Down
4 changes: 2 additions & 2 deletions replicate/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def run(
prediction.wait()

if prediction.status == "failed":
raise ModelError(prediction.error)
raise ModelError(prediction.error, prediction.id)

return prediction.output

Expand Down Expand Up @@ -97,7 +97,7 @@ async def async_run(
await prediction.async_wait()

if prediction.status == "failed":
raise ModelError(prediction.error)
raise ModelError(prediction.error, prediction.id)

return prediction.output

Expand Down