Skip to content

climate_ref.doctor.environment #

A description of the deployment, to accompany the findings.

A finding on its own rarely says enough to act on: the same warning means different things on a laptop and on an HPC deployment with a shared software prefix. This collects what a maintainer would otherwise have to ask for, in a form that can be pasted into an issue.

Values that could carry a credential are redacted here rather than at the point of display, so no output format can leak one.

collect_environment(context) #

Describe the deployment being checked.

A section that cannot be collected is reported as such rather than raising. An environment report is only useful if it survives the deployment being broken.

Parameters:

Name Type Description Default
context DoctorContext

The deployment to describe.

required

Returns:

Type Description
dict[str, dict[str, str]]

One entry per area, each holding that area's name: value pairs.

Source code in packages/climate-ref/src/climate_ref/doctor/environment.py
def collect_environment(context: DoctorContext) -> dict[str, dict[str, str]]:
    """
    Describe the deployment being checked.

    A section that cannot be collected is reported as such rather than raising.
    An environment report is only useful if it survives the deployment being broken.

    Parameters
    ----------
    context
        The deployment to describe.

    Returns
    -------
    :
        One entry per area, each holding that area's ``name: value`` pairs.
    """
    sections = {
        "versions": _versions,
        "platform": _platform,
        "configuration": lambda: _configuration(context),
        "paths": lambda: _paths(context),
        "providers": lambda: _providers(context),
        "ingested": lambda: _ingested(context),
        "environment_variables": _environment_variables,
        "checks": _checks,
    }

    collected = {}
    for name, collect in sections.items():
        try:
            collected[name] = collect()
        except Exception as exc:
            logger.exception(f"Could not collect the '{name}' section of the environment report")
            collected[name] = {"error": f"{type(exc).__name__}: {exc}"}

    return collected