import re


def version_from_name(path):
    """
    Get the file version from the name provided that the file fits the naming convention.

    :param str path: Path to the file.
    :return: Version number
    :rtype: int
    :raises: ValueError if the path does not match the version convention.
    """
    if re.search(r'_v\d\d\d\.', path):
        # Format out the version number and return it as an int
        return int(path.split('.')[0][-3:])
    else:
        raise ValueError('{} Does not match the version naming convention'.format(path))