import re


def find_num_nodes(logfile: str) -> int:
    """
    Find the number of nodes tested.

    Parameters
    ----------
    logfile : str
        A ``string`` of all contents from a logfile.

    Returns
    -------
    int
        Returns an ``integer`` of the number of nodes tested.
    """
    clear_cache_command = re.findall(r'srun.*Clearing cache on ', logfile)
    if len(clear_cache_command) == 0:
        print('Unable to find number of nodes tested. Assuming single node.')
        return 1
    n_tasks = re.findall(r'ntasks=\d+', clear_cache_command[0])
    num_nodes = n_tasks[0].replace('ntasks=', '')
    return num_nodes