Skip to content

climate_ref.doctor.report #

What examining a deployment produced.

Running the checks, ordering what they found, counting them, and describing the deployment they ran against are one job, so diagnose does all of it and hands back one value. A caller that wants to display a report does not have to know how any of that is assembled.

DoctorReport #

What the checks found, and the deployment they ran against.

Source code in packages/climate-ref/src/climate_ref/doctor/report.py
@frozen
class DoctorReport:
    """
    What the checks found, and the deployment they ran against.
    """

    findings: tuple[Finding, ...]
    """Everything the checks found, worst first, then by the check that produced them."""

    check_count: int
    """How many checks ran, including those that found nothing."""

    environment: dict[str, dict[str, str]] | None = None
    """
    A description of the deployment as sections of ``name: value`` pairs, or ``None``.

    This is deliberately an untyped blob of data.
    It is used as context for a bug report and the shape may change at any time.

    Sensitive values have been redacted.
    """

    @property
    def worst_severity(self) -> Severity | None:
        """The most serious severity found, or ``None`` when nothing was found."""
        return worst_severity(self.findings)

check_count instance-attribute #

How many checks ran, including those that found nothing.

environment = None class-attribute instance-attribute #

A description of the deployment as sections of name: value pairs, or None.

This is deliberately an untyped blob of data. It is used as context for a bug report and the shape may change at any time.

Sensitive values have been redacted.

findings instance-attribute #

Everything the checks found, worst first, then by the check that produced them.

worst_severity property #

The most serious severity found, or None when nothing was found.

diagnose(context, *, environment=False) #

Examine a REF deployment and generate a report.

Every check runs. One that raises becomes a finding rather than stopping the rest, so a broken check cannot make the deployment look healthy.

Parameters:

Name Type Description Default
context DoctorContext

The deployment to examine.

required
environment bool

Whether to describe the deployment as well as check it.

False

Returns:

Type Description
DoctorReport

What the checks found, and the deployment they ran against.

Source code in packages/climate-ref/src/climate_ref/doctor/report.py
def diagnose(context: DoctorContext, *, environment: bool = False) -> DoctorReport:
    """
    Examine a REF deployment and generate a report.

    Every check runs.
    One that raises becomes a finding rather than stopping the rest,
    so a broken check cannot make the deployment look healthy.

    Parameters
    ----------
    context
        The deployment to examine.
    environment
        Whether to describe the deployment as well as check it.

    Returns
    -------
    :
        What the checks found, and the deployment they ran against.
    """
    return DoctorReport(
        findings=tuple(run_checks(context)),
        check_count=len(iter_checks()),
        environment=collect_environment(context) if environment else None,
    )