def _assert_key_exists_in_custom_metadata(key: str, dictionary: Dict[str, Any]):
    """Raises a formatted KeyError if key is not a key of the dictionary."""
    if key not in dictionary.keys():
        raise KeyError(
            f"Key {key} not found in custom metadata.\n"
            f"Found keys: {dictionary.keys()}"
        )
Raises a formatted KeyError if key is not a key of the dictionary.
lightly/api/api_workflow_upload_metadata.py