# Copyright (c) Facebook, Inc. and its affiliates.
import os
from subprocess import call
import sys

import babyai.utils as utils

folder = os.path.join(utils.storage_dir(), "demos")
for filename in sorted(os.listdir(folder)):
    if filename.endswith(".pkl"):
        env = filename.split("_")[0]
        demos_maker = filename.split("_")[-1].split('.')[0]
        print("> Env: {} - {}".format(env, demos_maker))
        command = ["python evaluate.py --env {} --demos-origin {}".format(env, demos_maker)] + sys.argv[1:]
        call(" ".join(command), shell=True)
Esempio n. 2
0
LEVELS = sorted(list(level_dict.keys()), key=len)[::-1]


def get_levels_from_model_name(model):
    levels = []
    # Assume that our model names are separated with _ or -
    model_name_parts = re.split('_|-', model)
    for part in model_name_parts:
        # Assume that each part contains at most one level name.
        # Sorting LEVELS using length of level name is to avoid scenarios like
        # extracting 'GoTo' from the model name 'GoToLocal-model'
        for level in LEVELS:
            if level in part:
                levels.append('BabyAI-{}-v0'.format(level))
                break
    return list(set(levels))


folder = os.path.join(utils.storage_dir(), "models")

for model in sorted(os.listdir(folder)):
    if model.startswith('.'):
        continue
    envs = get_levels_from_model_name(model)
    print("> Envs: {} > Model: {}".format(envs, model))
    for env in envs:
        command = ["evaluate.py --env {} --model {}".format(env, model)
                   ] + sys.argv[1:]
        print("Command: {}".format(" ".join(command)))
        call(" ".join(command), shell=True)