Skip to content

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

class CommunicationException(
    response: requests.models.Response,
    *args,
    **kwargs
)

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

args

Methods

with_traceback

def with_traceback(
    ...
)

Exception.with_traceback(tb) --

set self.traceback to tb and return self.

MetricsUploadException

class MetricsUploadException(
    response: requests.models.Response,
    *args,
    **kwargs
)

Global model metrics upload (to the server) exception.

View Source
class MetricsUploadException(CommunicationException):
    """Global model metrics upload (to the server) exception."""
    pass

Ancestors (in MRO)

  • dlr.fl.client.exceptions.CommunicationException
  • builtins.Exception
  • builtins.BaseException

Class variables

args

Methods

with_traceback

def with_traceback(
    ...
)

Exception.with_traceback(tb) --

set self.traceback to tb and return self.

ModelDownloadException

class ModelDownloadException(
    response: requests.models.Response,
    *args,
    **kwargs
)

Global model download (from the server) exception.

View Source
class ModelDownloadException(CommunicationException):
    """Global model download (from the server) exception."""
    pass

Ancestors (in MRO)

  • dlr.fl.client.exceptions.CommunicationException
  • builtins.Exception
  • builtins.BaseException

Class variables

args

Methods

with_traceback

def with_traceback(
    ...
)

Exception.with_traceback(tb) --

set self.traceback to tb and return self.

ModelUploadException

class ModelUploadException(
    response: requests.models.Response,
    *args,
    **kwargs
)

Local model upload (to the server) exception.

View Source
class ModelUploadException(CommunicationException):
    """Local model upload (to the server) exception."""
    pass

Ancestors (in MRO)

  • dlr.fl.client.exceptions.CommunicationException
  • builtins.Exception
  • builtins.BaseException

Class variables

args

Methods

with_traceback

def with_traceback(
    ...
)

Exception.with_traceback(tb) --

set self.traceback to tb and return self.