浏览代码

Merge pull request #3922 from Unity-Technologies/MLA-973-reenable-backcompat

re-enable backwards compat tests
/docs-update
GitHub 5 年前
当前提交
fe2afc28
共有 3 个文件被更改,包括 37 次插入14 次删除
  1. 4
      .yamato/training-int-tests.yml
  2. 21
      ml-agents/tests/yamato/training_int_tests.py
  3. 26
      ml-agents/tests/yamato/yamato_utils.py

4
.yamato/training-int-tests.yml


# Backwards-compatibility tests.
# If we make a breaking change to the communication protocol, these will need
# to be disabled until the next release.
# - python -u -m ml-agents.tests.yamato.training_int_tests --python=0.15.0
# - python -u -m ml-agents.tests.yamato.training_int_tests --csharp=0.15.0
- python -u -m ml-agents.tests.yamato.training_int_tests --python=0.16.0
- python -u -m ml-agents.tests.yamato.training_int_tests --csharp=1.0.0
dependencies:
- .yamato/standalone-build-test.yml#test_mac_standalone_{{ editor.version }}
triggers:

21
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,
)

print(
f"Running training with python={python_version or latest} and c#={csharp_version or latest}"
)
nn_file_expected = f"./results/{run_id}/3DBall.nn"
output_dir = "models" if python_version else "results"
nn_file_expected = f"./{output_dir}/{run_id}/3DBall.nn"
if os.path.exists(nn_file_expected):
# Should never happen - make sure nothing leftover from an old test.
print("Artifacts from previous build found!")

# 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 --train --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

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


if csharp_version is None:
return
csharp_tag = f"com.unity.ml-agents_{csharp_version}"
subprocess.check_call(
f"git checkout {csharp_version} -- {csharp_dir}", shell=True
)
subprocess.check_call(f"git checkout {csharp_tag} -- {csharp_dir}", shell=True)
def undo_git_checkout():

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-packages_{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)
正在加载...
取消
保存