Module dlr.fl.client.exceptions¶
View Source
# SPDX-FileCopyrightText: 2024 Benedikt Franke <benedikt.franke@dlr.de>
# SPDX-FileCopyrightText: 2024 Florian Heinrich <florian.heinrich@dlr.de>
#
# SPDX-License-Identifier: Apache-2.0
import json
from requests import Response
class CommunicationException(Exception):
"""
Server communication exception base class.
"""
def __init__(self, response: Response, *args, **kwargs) -> None:
"""
Create a new communication exception.
Args:
response (Response): http response from the server
"""
message = "Something really went wrong with the server response!"
try:
message = response.text
message = json.loads(message)["message"]
except Exception:
pass
super().__init__(message, *args, **kwargs)
self.response = response
class MetricsUploadException(CommunicationException):
"""Global model metrics upload (to the server) exception."""
pass
class ModelDownloadException(CommunicationException):
"""Global model download (from the server) exception."""
pass
class ModelUploadException(CommunicationException):
"""Local model upload (to the server) exception."""
pass
Classes¶
CommunicationException¶
Server communication exception base class.
View Source
class CommunicationException(Exception):
"""
Server communication exception base class.
"""
def __init__(self, response: Response, *args, **kwargs) -> None:
"""
Create a new communication exception.
Args:
response (Response): http response from the server
"""
message = "Something really went wrong with the server response!"
try:
message = response.text
message = json.loads(message)["message"]
except Exception:
pass
super().__init__(message, *args, **kwargs)
self.response = response
Ancestors (in MRO)¶
- builtins.Exception
- builtins.BaseException
Descendants¶
- dlr.fl.client.exceptions.MetricsUploadException
- dlr.fl.client.exceptions.ModelDownloadException
- dlr.fl.client.exceptions.ModelUploadException
Class variables¶
Methods¶
with_traceback¶
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
MetricsUploadException¶
Global model metrics upload (to the server) exception.
View Source
Ancestors (in MRO)¶
- dlr.fl.client.exceptions.CommunicationException
- builtins.Exception
- builtins.BaseException
Class variables¶
Methods¶
with_traceback¶
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
ModelDownloadException¶
Global model download (from the server) exception.
View Source
Ancestors (in MRO)¶
- dlr.fl.client.exceptions.CommunicationException
- builtins.Exception
- builtins.BaseException
Class variables¶
Methods¶
with_traceback¶
Exception.with_traceback(tb) --
set self.traceback to tb and return self.
ModelUploadException¶
Local model upload (to the server) exception.
View Source
Ancestors (in MRO)¶
- dlr.fl.client.exceptions.CommunicationException
- builtins.Exception
- builtins.BaseException
Class variables¶
Methods¶
with_traceback¶
Exception.with_traceback(tb) --
set self.traceback to tb and return self.