Skip to content

Conversation

@rohan-mehta
Copy link
Contributor

This is useful for debugging. For issue #324.

mattt added a commit that referenced this pull request 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.

```python
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.logs:
    pass

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

---------

Signed-off-by: Rohan Mehta <[email protected]>
Signed-off-by: Mattt Zmuda <[email protected]>
Co-authored-by: Rohan Mehta <[email protected]>
@mattt
Copy link
Contributor

mattt commented Jul 18, 2024

This is a great idea. Thanks so much for sharing, @rohan-mehta!

I took this PR and ran with it a bit in #326. That PR updates ModelError to include the full prediction object as a field, so you can pull the ID, logs, or any other information as needed.

This is now available in 0.29.0.

@mattt mattt closed this Jul 18, 2024
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