浏览代码

handle old config separately

/docs-update
Chris Elion 4 年前
当前提交
e923498d
共有 2 个文件被更改,包括 31 次插入8 次删除
  1. 18
      ml-agents/tests/yamato/training_int_tests.py
  2. 21
      ml-agents/tests/yamato/yamato_utils.py

18
ml-agents/tests/yamato/training_int_tests.py


run_standalone_build,
init_venv,
override_config_file,
override_legacy_config_file,
checkout_csharp_version,
undo_git_checkout,
)

# Copy the default training config but override the max_steps parameter,
# and reduce the batch_size and buffer_size enough to ensure an update step happens.
override_config_file(
"config/ppo/3DBall.yaml",
"override.yaml",
max_steps=100,
batch_size=10,
buffer_size=10,
)
overrides = {"max_steps": 100, "batch_size": 10, "buffer_size": 10}
yaml_out = "override.yaml"
if python_version:
override_legacy_config_file(
python_version, "config/trainer_config.yaml", yaml_out, **overrides
)
else:
override_config_file("config/ppo/3DBall.yaml", yaml_out, **overrides)
f"mlagents-learn override.yaml --force --env="
f"mlagents-learn {yaml_out} --force --env="
f"{os.path.join(get_base_output_path(), standalone_player_path)} "
f"--run-id={run_id} --no-graphics --env-args -logFile -"
) # noqa

21
ml-agents/tests/yamato/yamato_utils.py


with open(dest_path, "w") as f:
yaml.dump(configs, f)
def override_legacy_config_file(python_version, src_path, dest_path, **kwargs):
"""
Override settings in a trainer config file, using an old version of the src_path. For example,
override_config_file("0.16.0", src_path, dest_path, max_steps=42)
will sync the file at src_path from version 0.16.0, copy it to dest_path, and override the
max_steps field to 42 for all brains.
"""
# Sync the old version of the file
python_tag = f"python_{python_version}"
subprocess.check_call(f"git checkout {python_tag} -- {src_path}", shell=True)
with open(src_path) as f:
configs = yaml.safe_load(f)
for config in configs.values():
config.update(**kwargs)
with open(dest_path, "w") as f:
yaml.dump(configs, f)
正在加载...
取消
保存