Skip to content

Add prediction field to ModelError#326

Merged
mattt merged 4 commits intomainfrom
mattt/modelerror-prediction
Jul 18, 2024
Merged

Add prediction field to ModelError#326
mattt merged 4 commits intomainfrom
mattt/modelerror-prediction

Conversation

@mattt
Copy link
Copy Markdown
Contributor

@mattt mattt commented Jul 18, 2024

This PR extends #325 to add the prediction object itself to ModelError, as opposed to just its ID. This makes it convenient to introspect logs and other information to determine how to handle the failure.

import replicate
from replicate.exceptions import ModelError

try:
  output = replicate.run("stability-ai/stable-diffusion-3", { "prompt": "..." })
except ModelError as e
  if "(some known issue)" in e.prediction.logs:
    pass

  print("Failed prediction: " + e.prediction.id)

rohan-mehta and others added 4 commits July 10, 2024 10:05
Signed-off-by: Rohan Mehta <rohanmehta@fastmail.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
@mattt mattt merged commit 71c124d into main Jul 18, 2024
@mattt mattt deleted the mattt/modelerror-prediction branch July 18, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants