def write_file()

in google_cloud_automlops/utils/utils.py [0:0]


def write_file(filepath: str, text: str, mode: str):
    """Writes a file at the specified path. Defaults to utf-8 encoding.

    Args:
        filepath (str): Path to the file.
        text (str): Text to be written to file.
        mode (str): Read/write mode to be used.

    Raises:
        Exception: An error is encountered writing the file.
    """
    try:
        with open(filepath, mode, encoding='utf-8') as file:
            file.write(text)
        file.close()
    except OSError as err:
        raise OSError(f'Error writing to file. {err}') from err