예제 #1
0
def test_list_softlink_dependencies():
    """Test if finding model dependencies works
    """
    component_dir = kipoi.get_source("kipoi").local_path
    deps = list_softlink_dependencies(os.path.join(component_dir, 'HAL'),
                                      component_dir)
    # one of these two, depending on the model source
    assert (deps == {'MaxEntScan'}) or (deps == {'MaxEntScan/template',
                                                 'MaxEntScan/template/example_files',
                                                 'labranchor/example_files'})
    assert list_softlink_dependencies(os.path.join(component_dir, 'deepTarget'),
                                      component_dir) == set()
예제 #2
0
def test_list_softlink_dependencies():
    """Test if finding model dependencies works
    """
    component_dir = kipoi.get_source("kipoi").local_path
    assert list_softlink_dependencies(
        os.path.join(component_dir, 'rbp_eclip/UPF1'),
        component_dir) == {'rbp_eclip/template'}
    assert list_softlink_dependencies(os.path.join(component_dir, 'HAL'),
                                      component_dir) == {
                                          'MaxEntScan/template',
                                          'MaxEntScan/template/example_files',
                                          'labranchor/example_files'
                                      }
    assert list_softlink_dependencies(
        os.path.join(component_dir, 'deepTarget'), component_dir) == set()
예제 #3
0
    def dependency_modified(model_name, modified_files):
        """Test if the dependency was modified
        """
        def contains_any(x, file_list):
            """Test if the directory x contains any files from file_list
            """
            for y in file_list:
                if y.startswith(x + os.sep) or x == y:
                    return True
            return False

        # if model is from a model group, test if any of the files were modified
        group_name = source.get_group_name(model_name, which='model')
        if group_name is not None:
            # Test if any files required by the group were modified
            if contains_any(group_name, modified_files):
                return True

        # get all the dependency directories
        dep_dirs = list_softlink_dependencies(
            os.path.join(source.local_path, model_name), source.local_path)

        for model_dir in [model_name] + list(dep_dirs):
            if contains_any(model_dir, modified_files):
                return True
        return False
예제 #4
0
    def dependency_modified(model_name, modified_files):
        """Test if the dependency was modified
        """
        def contains_any(x, file_list):
            """Test if the directory x contains any files from file_list
            """
            for y in file_list:
                if y.startswith(x + os.sep) or x == y:
                    return True
            return False
        # get all the dependency directories
        dep_dirs = list_softlink_dependencies(os.path.join(source.local_path,
                                                           model_name),
                                              source.local_path)

        for model_dir in [model_name] + list(dep_dirs):
            if contains_any(model_dir, modified_files):
                return True
        return False