Skip to content

Exceptions

UnknownTypeException

Bases: Exception

Type error with message, followed by type suggestion, chosen by fuzzy matching (out of 'choices' arg passed in init).

Parameters:

Name Type Description Default
unknown_type str

The type that was not found.

required
choices List

List of valid types

required
message str

Explanation of the error

None
Source code in V3_1/src/super_gradients/common/exceptions/factory_exceptions.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class UnknownTypeException(Exception):
    """Type error with message, followed by type suggestion, chosen by fuzzy matching
     (out of 'choices' arg passed in __init__).

    :param unknown_type:    The type that was not found.
    :param choices:         List of valid types
    :param message:         Explanation of the error
    """

    def __init__(self, unknown_type: str, choices: List, message: str = None):
        message = message or f"Unknown object type: {unknown_type} in configuration. valid types are: {choices}"
        err_msg_tip = ""
        if isinstance(unknown_type, str):
            choice, score, _ = process.extractOne(unknown_type, choices, scorer=fuzz.WRatio)
            if score > 70:
                err_msg_tip = f"\n Did you mean: {choice}?"
        self.message = message + err_msg_tip
        super().__init__(self.message)