import pathlib


def parse_log(log_path, root_dir):
    """Extract dataset file and the results from log_test.txt."""
    text = log_path.read_text()
    # ignore the head and the date, get the dataset path and the rest
    head, date, dataset, rest = text.split('\n', 3)
    dataset = pathlib.Path(dataset.strip().split(': ', 1)[-1])
    if dataset.is_absolute():
        # the test data files use relative paths, make this relative too
        dataset = dataset.relative_to(root_dir)
    return dataset, rest