Skip to content

Add prediction field to ModelError #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2024
Merged

Add prediction field to ModelError #326

merged 4 commits into from
Jul 18, 2024

Conversation

mattt
Copy link
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
7 checks passed
@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