generate_json.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:gym-adv 作者: lerrel 项目源码 文件源码
def add_new_rollouts(spec_ids, overwrite):
  environments = [spec for spec in envs.registry.all() if spec._entry_point is not None]
  if spec_ids:
    environments = [spec for spec in environments if spec.id in spec_ids]
    assert len(environments) == len(spec_ids), "Some specs not found"
  with open(ROLLOUT_FILE) as data_file:
    rollout_dict = json.load(data_file)
  modified = False
  for spec in environments:
    if not overwrite and spec.id in rollout_dict:
      logger.debug("Rollout already exists for {}. Skipping.".format(spec.id))
    else:
      modified = update_rollout_dict(spec, rollout_dict) or modified

  if modified:
    logger.info("Writing new rollout file to {}".format(ROLLOUT_FILE))
    with open(ROLLOUT_FILE, "w") as outfile:
      json.dump(rollout_dict, outfile, indent=2, sort_keys=True)
  else:
    logger.info("No modifications needed.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号