Skip to content

create_directory_if_not_exists

The directory creation method.

It checks whether the target file directory exists or not, if it doesn't exist, this method will create the directory.

Parameters:

Name Type Description Default
complete_file_path

The complete file path (covering the directory and file name) as a string.

required

Returns:

Type Description
None

This method doesn't have any return values.

Source code in tinybig/util/utility.py
def create_directory_if_not_exists(complete_file_path):
    """
    The directory creation method.

    It checks whether the target file directory exists or not,
    if it doesn't exist, this method will create the directory.

    Parameters
    ----------
    complete_file_path: str
        The complete file path (covering the directory and file name) as a string.

    Returns
    -------
    None
        This method doesn't have any return values.
    """
    directory_path = os.path.dirname(complete_file_path)
    if not os.path.exists(directory_path):
        os.makedirs(directory_path)
        print(f"Directory '{directory_path}' doesn't exit, and it was created...")