def get_huggingface_token():
    """Get huggingface token from environment variable or token file."""
    import os

    if os.getenv("HF_TOKEN"):
        return os.getenv("HF_TOKEN")

    token_path = Path.home() / ".huggingface" / "token"
    if not token_path.exists():
        logger.error(
            "Huggingface token is required at this step. Could not find huggingface token at %s. "
            "Please login to huggingface first using `huggingface-cli login`. "
            "If you already logged in, Olive will get token from '~/.huggingface/token' file'. "
            "Please make sure the token file exists.",
            token_path,
        )
        return None
    with Path(token_path).open() as f:
        return f.read().strip()
Get huggingface token from environment variable or token file.
olive/systems/docker/docker_system.py