Skip to content

oversampleqa.config_templates

oversampleqa.config_templates

Predefined configuration templates for the enhanced CLI.

generate_config_file(template_name, output_path)

Generate a YAML configuration file from a named template.

Parameters

template_name: Name of the template (research, production, education). output_path: Destination path for the generated YAML file.

Returns

pathlib.Path Path to the generated configuration file.

Source code in src/oversampleqa/config_templates.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def generate_config_file(template_name: str, output_path: str) -> Path:
    """Generate a YAML configuration file from a named template.

    Parameters
    ----------
    template_name:
        Name of the template (``research``, ``production``, ``education``).
    output_path:
        Destination path for the generated YAML file.

    Returns
    -------
    pathlib.Path
        Path to the generated configuration file.
    """

    if template_name not in CONFIG_TEMPLATES:
        available = ", ".join(sorted(CONFIG_TEMPLATES))
        raise ValueError(
            f"Unknown template '{template_name}'. Choose from: {available}"
        )

    payload: dict[str, Any] = {
        "template": template_name,
        "description": CONFIG_TEMPLATES[template_name]["description"],
        "profiles": {
            template_name: CONFIG_TEMPLATES[template_name]["params"],
        },
    }

    destination = Path(output_path).expanduser().resolve()
    destination.parent.mkdir(parents=True, exist_ok=True)
    with destination.open("w", encoding="utf-8") as fh:
        yaml.safe_dump(payload, fh, sort_keys=False, allow_unicode=True)
    return destination