Skip to content

CompatibilityReport

yohou_mlflow.CompatibilityReport dataclass

Result of check_compatibility.

Parameters

Name Type Description Default
loadable bool

True when a default, strict load_model would load the model.

required
problems tuple of str

One sentence per reason the load would be refused. Empty when loadable.

required
format_version str

Format version recorded in the model.

required
version_mismatches tuple of VersionMismatch

Packages whose installed version breaks the comparison rules.

()
untrusted_types tuple of str

Types in the skops file outside the policy and extra_trusted_types.

()

Source Code

Source code in src/yohou_mlflow/_persistence.py
@dataclass(frozen=True)
class CompatibilityReport:
    """Result of `check_compatibility`.

    Parameters
    ----------
    loadable : bool
        ``True`` when a default, strict ``load_model`` would load the model.
    problems : tuple of str
        One sentence per reason the load would be refused. Empty when loadable.
    format_version : str
        Format version recorded in the model.
    version_mismatches : tuple of VersionMismatch, default=()
        Packages whose installed version breaks the comparison rules.
    untrusted_types : tuple of str, default=()
        Types in the skops file outside the policy and ``extra_trusted_types``.
    """

    loadable: bool
    problems: tuple[str, ...]
    format_version: str
    version_mismatches: tuple[VersionMismatch, ...] = ()
    untrusted_types: tuple[str, ...] = ()

    def __str__(self) -> str:
        """Summarize the report in a few lines.

        Returns
        -------
        str
            "Loadable." or the list of problems.
        """
        if self.loadable:
            return "Loadable: a strict load_model would succeed."
        return "Not loadable:\n" + "\n".join(f"  - {problem}" for problem in self.problems)

Methods

__str__()

Summarize the report in a few lines.

Returns
Type Description
str

"Loadable." or the list of problems.

Source Code
Source code in src/yohou_mlflow/_persistence.py
def __str__(self) -> str:
    """Summarize the report in a few lines.

    Returns
    -------
    str
        "Loadable." or the list of problems.
    """
    if self.loadable:
        return "Loadable: a strict load_model would succeed."
    return "Not loadable:\n" + "\n".join(f"  - {problem}" for problem in self.problems)