import pathlib


def get_source_id_from_file_path(file_path: pathlib.Path) -> str:
    """Extrapolates the source id from the file path.

    To retrieve the source id from the file name, the function uses the fact that the
    ICE uses a consistent naming convention consisting of the file type accompanied by
    the source id and the date the data in the file was generated.
    (e.g. COREREF_207_20201023.txt.bz2).

    Parameters
    ----------
    file_path: str
        The path to the file for which the source id has to be extrapolated.

    Returns
    -------
    str
        The source id.
    """
    file_name = file_path.name.split(".")[0]
    name_components = file_name.split('_')
    return name_components[1]