-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch and format prediction result errors
Catch and format as a JSON response, exceptions that occur when converting the result of model.predict() to the expected Response type (as documented in the mlflow model metadata) Fixes #12
- Loading branch information
1 parent
f1fd20b
commit be7521c
Showing
4 changed files
with
50 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Exceptions. | ||
Copyright (C) 2023, Auto Trader UK | ||
Created 17. Apr 2023 | ||
""" | ||
|
||
|
||
class DictSerialisableException(Exception): | ||
"""An Exception wrapper for formatting.""" | ||
|
||
def __init__(self, name: str, message: str): | ||
self.name = name | ||
self.message = message | ||
|
||
@classmethod | ||
def from_exception(cls, exc: Exception): | ||
return cls(name=exc.__class__.__name__, message=str(exc)) | ||
|
||
def to_dict(self): | ||
return {"name": self.name, "message": self.message} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters