Skip to content

UntrustedTypesError

yohou_mlflow.UntrustedTypesError

Bases: YohouMlflowError

A saved forecaster contains types outside the trust policy.

Parameters

Name Type Description Default
types sequence of str

Fully qualified names of the types outside the policy.

required
when ('save', 'load')

Whether the problem was found while saving or while loading.

"save"

Attributes

Name Type Description
types tuple of str

Fully qualified names of the types outside the policy, sorted.

Source Code

Source code in src/yohou_mlflow/_exceptions.py
class UntrustedTypesError(YohouMlflowError):
    """A saved forecaster contains types outside the trust policy.

    Parameters
    ----------
    types : sequence of str
        Fully qualified names of the types outside the policy.
    when : {"save", "load"}
        Whether the problem was found while saving or while loading.

    Attributes
    ----------
    types : tuple of str
        Fully qualified names of the types outside the policy, sorted.
    """

    def __init__(self, types: Sequence[str], when: str) -> None:
        self.types = tuple(sorted(types))
        listed = "\n".join(f"  - {name}" for name in self.types)
        if when == "save":
            action = "It would be refused when loaded, so it was not saved."
        else:
            action = "Nothing from the file was constructed."
        super().__init__(
            f"The forecaster contains types outside yohou-mlflow's trust policy:\n{listed}\n"
            f"{action} If you trust these types, pass them in `extra_trusted_types`, or their "
            "package in `extra_trusted_prefixes`, both when saving and every time the model is loaded."
        )