def load_variants()

in dockerfiles.py [0:0]


def load_variants(release_dir: str) -> Dict[str, Any]:
    """
    Load variant definitions from public.json in the release directory.

    Args:
        release_dir (str): The path to the release directory.

    Returns:
        Dict[str, Any]: A dictionary of variants from the JSON file.

    Raises:
        SystemExit: If the file is missing, cannot be read, or is invalid JSON.
    """
    public_json_path = os.path.join(release_dir, "public.json")
    if not os.path.isfile(public_json_path):
        logger.error("'%s' not found.", public_json_path)
        sys.exit(1)

    try:
        with open(public_json_path, "r", encoding="utf-8") as file:
            variants = json.load(file)
        return variants
    except json.JSONDecodeError as e:
        logger.error("Error decoding JSON from '%s': %s", public_json_path, e)
        sys.exit(1)
    except OSError as e:
        logger.error("Error reading '%s': %s", public_json_path, e)
        sys.exit(1)