in google_cloud_automlops/utils/utils.py [0:0]
def read_yaml_file(filepath: str) -> dict:
"""Reads a yaml and returns file contents as a dict. Defaults to utf-8 encoding.
Args:
filepath (str): Path to the yaml.
Returns:
dict: Contents of the yaml.
Raises:
Exception: If an error is encountered reading the file.
"""
try:
with open(filepath, 'r', encoding='utf-8') as file:
file_dict = yaml.safe_load(file)
file.close()
except yaml.YAMLError as err:
raise yaml.YAMLError(f'Error reading file. {err}') from err
return file_dict