Ejemplo n.º 1
0
def test_list_files_recursively():
    a = list_files_recursively("example", 'model')
    b = list_files_recursively("example/", 'model')
    c = list_files_recursively(os.path.abspath("example"), 'model')
    assert a == b
    assert a == c
    assert a[0].startswith("models/")
    assert all([x.endswith("model.yaml") for x in a])
    assert all([os.path.exists(os.path.join("example", x)) for x in a])
Ejemplo n.º 2
0
def all_models_to_test(src):
    """Returns a list of models to test

    By default, this method returns all the model. In case a model group has a
    `test_subset.txt` file present in the group directory, then testing is only
    performed for models listed in `test_subset.txt`.

    Args:
      src: Model source
    """
    txt_files = list_files_recursively(src.local_path, "test_subset", "txt")

    exclude = []
    include = []
    for x in txt_files:
        d = os.path.dirname(x)
        exclude += [d]
        include += [os.path.join(d, l)
                    for l in read_txt(os.path.join(src.local_path, x))]

    # try to load every model extra included -- will get tested downstream
    # for m in include:
    #     src.get_model_descr(m)

    models = src.list_models().model
    for excl in exclude:
        models = models[~models.str.startswith(excl)]
    return list(models) + include