Esempio n. 1
0
def restore_file_back(restore_id, load_key='default'):
    if restore_id is not None:
        load_file = Config.get_load_filename(restore_id=restore_id)
        filepath = file_to_path(load_file)
        load_data = joblib.load(filepath)

        Config.set_load_data(load_data, load_key=load_key)

        restored_args = load_data['args']
        sub_dict = {}
        res_keys = Config.RES_KEYS

        for key in res_keys:
            if key in restored_args:
                sub_dict[key] = restored_args[key]
            else:
                print('warning key %s not restored' % key)

        Config.parse_args_dict(sub_dict)

    from coinrun.coinrunenv import init_args_and_threads
    init_args_and_threads(4)
Esempio n. 2
0
def restore_file(restore_id,
                 base_name=None,
                 overlap_config=None,
                 load_key='default'):
    """overlap config means you can modify the config in savefile, e.g. test seed"""
    if restore_id is not None:
        load_file = Config.get_load_filename(restore_id=restore_id,
                                             base_name=base_name)
        filepath = file_to_path(load_file)
        assert os.path.exists(filepath), "don't exist"
        load_data = joblib.load(filepath)

        Config.set_load_data(load_data, load_key=load_key)

        restored_args = load_data['args']
        sub_dict = {}
        res_keys = Config.RES_KEYS

        for key in res_keys:
            if key in restored_args:
                sub_dict[key] = restored_args[key]
            else:
                print('warning key %s not restored' % key)

        Config.parse_args_dict(sub_dict)
        print("Load params")
        if overlap_config is not None:
            Config.parse_args_dict(overlap_config)

    from coinrun.coinrunenv import init_args_and_threads
    print("Init coinrun env threads and env args")
    init_args_and_threads(4)
    if restore_id == None:
        return None
    else:
        return load_file