Module aiolirest.exceptions
HPE Machine Learning Inference Software (MLIS/Aioli)
HPE MLIS is Aioli – The AI On-line Inference Platform that enables easy deployment, tracking, and serving of your packaged models regardless of your preferred AI framework.
The version of the OpenAPI document: 1.0.0 Contact: community@determined-ai Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
Expand source code
# coding: utf-8
"""
HPE Machine Learning Inference Software (MLIS/Aioli)
HPE MLIS is *Aioli* -- The AI On-line Inference Platform that enables easy deployment, tracking, and serving of your packaged models regardless of your preferred AI framework.
The version of the OpenAPI document: 1.0.0
Contact: community@determined-ai
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions"""
class ApiTypeError(OpenApiException, TypeError):
def __init__(self, msg, path_to_item=None, valid_classes=None,
key_type=None) -> None:
""" Raises an exception for TypeErrors
Args:
msg (str): the exception message
Keyword Args:
path_to_item (list): a list of keys an indices to get to the
current_item
None if unset
valid_classes (tuple): the primitive classes that current item
should be an instance of
None if unset
key_type (bool): False if our value is a value in a dict
True if it is a key in a dict
False if our item is an item in a list
None if unset
"""
self.path_to_item = path_to_item
self.valid_classes = valid_classes
self.key_type = key_type
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiTypeError, self).__init__(full_msg)
class ApiValueError(OpenApiException, ValueError):
def __init__(self, msg, path_to_item=None) -> None:
"""
Args:
msg (str): the exception message
Keyword Args:
path_to_item (list) the path to the exception in the
received_data dict. None if unset
"""
self.path_to_item = path_to_item
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiValueError, self).__init__(full_msg)
class ApiAttributeError(OpenApiException, AttributeError):
def __init__(self, msg, path_to_item=None) -> None:
"""
Raised when an attribute reference or assignment fails.
Args:
msg (str): the exception message
Keyword Args:
path_to_item (None/list) the path to the exception in the
received_data dict
"""
self.path_to_item = path_to_item
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiAttributeError, self).__init__(full_msg)
class ApiKeyError(OpenApiException, KeyError):
def __init__(self, msg, path_to_item=None) -> None:
"""
Args:
msg (str): the exception message
Keyword Args:
path_to_item (None/list) the path to the exception in the
received_data dict
"""
self.path_to_item = path_to_item
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiKeyError, self).__init__(full_msg)
class ApiException(OpenApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None:
if http_resp:
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data.decode('utf-8')
self.headers = http_resp.getheaders()
else:
self.status = status
self.reason = reason
self.body = None
self.headers = None
def __str__(self):
"""Custom error messages for exception"""
error_message = "({0})\n"\
"Reason: {1}\n".format(self.status, self.reason)
if self.headers:
error_message += "HTTP response headers: {0}\n".format(
self.headers)
if self.body:
error_message += "HTTP response body: {0}\n".format(self.body)
return error_message
class BadRequestException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(BadRequestException, self).__init__(status, reason, http_resp)
class NotFoundException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)
class UnauthorizedException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)
class ForbiddenException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)
class ServiceException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)
def render_path(path_to_item):
"""Returns a string representation of a path"""
result = ""
for pth in path_to_item:
if isinstance(pth, int):
result += "[{0}]".format(pth)
else:
result += "['{0}']".format(pth)
return result
Functions
def render_path(path_to_item)
-
Returns a string representation of a path
Expand source code
def render_path(path_to_item): """Returns a string representation of a path""" result = "" for pth in path_to_item: if isinstance(pth, int): result += "[{0}]".format(pth) else: result += "['{0}']".format(pth) return result
Classes
class ApiAttributeError (msg, path_to_item=None)
-
The base exception class for all OpenAPIExceptions
Raised when an attribute reference or assignment fails.
Args
msg
:str
- the exception message
Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict
Expand source code
class ApiAttributeError(OpenApiException, AttributeError): def __init__(self, msg, path_to_item=None) -> None: """ Raised when an attribute reference or assignment fails. Args: msg (str): the exception message Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict """ self.path_to_item = path_to_item full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiAttributeError, self).__init__(full_msg)
Ancestors
- OpenApiException
- builtins.AttributeError
- builtins.Exception
- builtins.BaseException
class ApiException (status=None, reason=None, http_resp=None)
-
The base exception class for all OpenAPIExceptions
Expand source code
class ApiException(OpenApiException): def __init__(self, status=None, reason=None, http_resp=None) -> None: if http_resp: self.status = http_resp.status self.reason = http_resp.reason self.body = http_resp.data.decode('utf-8') self.headers = http_resp.getheaders() else: self.status = status self.reason = reason self.body = None self.headers = None def __str__(self): """Custom error messages for exception""" error_message = "({0})\n"\ "Reason: {1}\n".format(self.status, self.reason) if self.headers: error_message += "HTTP response headers: {0}\n".format( self.headers) if self.body: error_message += "HTTP response body: {0}\n".format(self.body) return error_message
Ancestors
- OpenApiException
- builtins.Exception
- builtins.BaseException
Subclasses
class ApiKeyError (msg, path_to_item=None)
-
The base exception class for all OpenAPIExceptions
Args
msg
:str
- the exception message
Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict
Expand source code
class ApiKeyError(OpenApiException, KeyError): def __init__(self, msg, path_to_item=None) -> None: """ Args: msg (str): the exception message Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict """ self.path_to_item = path_to_item full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiKeyError, self).__init__(full_msg)
Ancestors
- OpenApiException
- builtins.KeyError
- builtins.LookupError
- builtins.Exception
- builtins.BaseException
class ApiTypeError (msg, path_to_item=None, valid_classes=None, key_type=None)
-
The base exception class for all OpenAPIExceptions
Raises an exception for TypeErrors
Args
msg
:str
- the exception message
Keyword Args: path_to_item (list): a list of keys an indices to get to the current_item None if unset valid_classes (tuple): the primitive classes that current item should be an instance of None if unset key_type (bool): False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list None if unset
Expand source code
class ApiTypeError(OpenApiException, TypeError): def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: """ Raises an exception for TypeErrors Args: msg (str): the exception message Keyword Args: path_to_item (list): a list of keys an indices to get to the current_item None if unset valid_classes (tuple): the primitive classes that current item should be an instance of None if unset key_type (bool): False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list None if unset """ self.path_to_item = path_to_item self.valid_classes = valid_classes self.key_type = key_type full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiTypeError, self).__init__(full_msg)
Ancestors
- OpenApiException
- builtins.TypeError
- builtins.Exception
- builtins.BaseException
class ApiValueError (msg, path_to_item=None)
-
The base exception class for all OpenAPIExceptions
Args
msg
:str
- the exception message
Keyword Args: path_to_item (list) the path to the exception in the received_data dict. None if unset
Expand source code
class ApiValueError(OpenApiException, ValueError): def __init__(self, msg, path_to_item=None) -> None: """ Args: msg (str): the exception message Keyword Args: path_to_item (list) the path to the exception in the received_data dict. None if unset """ self.path_to_item = path_to_item full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiValueError, self).__init__(full_msg)
Ancestors
- OpenApiException
- builtins.ValueError
- builtins.Exception
- builtins.BaseException
class BadRequestException (status=None, reason=None, http_resp=None)
-
The base exception class for all OpenAPIExceptions
Expand source code
class BadRequestException(ApiException): def __init__(self, status=None, reason=None, http_resp=None) -> None: super(BadRequestException, self).__init__(status, reason, http_resp)
Ancestors
- ApiException
- OpenApiException
- builtins.Exception
- builtins.BaseException
class ForbiddenException (status=None, reason=None, http_resp=None)
-
The base exception class for all OpenAPIExceptions
Expand source code
class ForbiddenException(ApiException): def __init__(self, status=None, reason=None, http_resp=None) -> None: super(ForbiddenException, self).__init__(status, reason, http_resp)
Ancestors
- ApiException
- OpenApiException
- builtins.Exception
- builtins.BaseException
class NotFoundException (status=None, reason=None, http_resp=None)
-
The base exception class for all OpenAPIExceptions
Expand source code
class NotFoundException(ApiException): def __init__(self, status=None, reason=None, http_resp=None) -> None: super(NotFoundException, self).__init__(status, reason, http_resp)
Ancestors
- ApiException
- OpenApiException
- builtins.Exception
- builtins.BaseException
class OpenApiException (*args, **kwargs)
-
The base exception class for all OpenAPIExceptions
Expand source code
class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions"""
Ancestors
- builtins.Exception
- builtins.BaseException
Subclasses
class ServiceException (status=None, reason=None, http_resp=None)
-
The base exception class for all OpenAPIExceptions
Expand source code
class ServiceException(ApiException): def __init__(self, status=None, reason=None, http_resp=None) -> None: super(ServiceException, self).__init__(status, reason, http_resp)
Ancestors
- ApiException
- OpenApiException
- builtins.Exception
- builtins.BaseException
-
The base exception class for all OpenAPIExceptions
Expand source code
class UnauthorizedException(ApiException): def __init__(self, status=None, reason=None, http_resp=None) -> None: super(UnauthorizedException, self).__init__(status, reason, http_resp)
Ancestors
- ApiException
- OpenApiException
- builtins.Exception
- builtins.BaseException