Skip to content

Learning

learning

check_learning_profile(project, data)

Check the generated configuration for a declared learning profile.

Source code in packages/axm-init/src/axm_init/checks/learning.py
Python
@requires_toml(
    "learning.profile",
    "learning",
    2,
    _FIX,
)
def check_learning_profile(project: Path, data: TomlTable) -> CheckResult:
    """Check the generated configuration for a declared learning profile."""
    tool = section(data, "tool")
    axm_init = section(tool, "axm-init")
    if "learning" not in axm_init:
        return CheckResult(
            name="learning.profile",
            category="learning",
            passed=True,
            weight=0,
            message="No learning profile declared",
            details=[],
            fix="",
        )

    profile = section(axm_init, "learning")
    domain = profile.get("domain")
    schema_version = profile.get("schema_version")
    problems: list[str] = []
    if not isinstance(domain, str) or not domain:
        problems.append("Missing or invalid domain in [tool.axm-init.learning]")
    if schema_version != _SUPPORTED_SCHEMA_VERSION:
        problems.append(
            "Unsupported schema_version in [tool.axm-init.learning]: "
            f"expected {_SUPPORTED_SCHEMA_VERSION}, got {schema_version!r}"
        )

    missing = [
        name for name in _GENERATED_CONFIG_FILES if not (project / name).is_file()
    ]
    problems.extend(f"Missing generated configuration file: {name}" for name in missing)

    if problems:
        return CheckResult(
            name="learning.profile",
            category="learning",
            passed=False,
            weight=2,
            message="Learning profile configuration is incomplete",
            details=problems,
            fix=_FIX,
        )

    return CheckResult(
        name="learning.profile",
        category="learning",
        passed=True,
        weight=2,
        message=f"Learning profile for {domain} is configured",
        details=[],
        fix="",
    )