浏览代码

[MLA-867] New integration tests for gym and llapi (#3757)

* [MLA-867] New integration tests for gym and llapi

* Fixing the command line argument in the test

* Fixing a bug that was blocking basic for ever

* Fixing typo
/develop/add-fire
GitHub 5 年前
当前提交
7e3848fe
共有 4 个文件被更改,包括 52 次插入6 次删除
  1. 5
      .yamato/python-ll-api-test.yml
  2. 2
      .yamato/standalone-build-test.yml
  3. 22
      ml-agents/tests/yamato/scripts/run_gym.py
  4. 29
      ml-agents/tests/yamato/scripts/run_llapi.py

5
.yamato/python-ll-api-test.yml


commands:
- pip install pyyaml
- python -u -m ml-agents.tests.yamato.setup_venv
- ./venv/bin/python ml-agents/tests/yamato/scripts/run_llapi.py
- ./venv/bin/python ml-agents/tests/yamato/scripts/run_llapi.py
- ./venv/bin/python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-Basic
- ./venv/bin/python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-WallJump
- ./venv/bin/python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-Bouncer
dependencies:
- .yamato/standalone-build-test.yml#test_mac_standalone_{{ editor.version }}
triggers:

2
.yamato/standalone-build-test.yml


- pip install pyyaml
- python -u -m ml-agents.tests.yamato.standalone_build_tests
- python -u -m ml-agents.tests.yamato.standalone_build_tests --scene=Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity
- python -u -m ml-agents.tests.yamato.standalone_build_tests --scene=Assets/ML-Agents/Examples/Bouncer/Scenes/Bouncer.unity
- python -u -m ml-agents.tests.yamato.standalone_build_tests --scene=Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity
triggers:
cancel_old_ci: true
changes:

22
ml-agents/tests/yamato/scripts/run_gym.py


from gym_unity.envs import UnityEnv
def main(env_name):
def test_run_environment(env_name):
"""
Run the gym test using the specified environment
:param env_name: Name of the Unity environment binary to launch

env.close()
def test_closing(env_name):
"""
Run the gym test and closes the environment multiple times
:param env_name: Name of the Unity environment binary to launch
"""
try:
env1 = UnityEnv(env_name, worker_id=1, use_visual=False, no_graphics=True)
env1.close()
env1 = UnityEnv(env_name, worker_id=1, use_visual=False, no_graphics=True)
env2 = UnityEnv(env_name, worker_id=2, use_visual=False, no_graphics=True)
env2.reset()
finally:
env1.close()
env2.close()
main(args.env)
test_run_environment(args.env)
test_closing(args.env)

29
ml-agents/tests/yamato/scripts/run_llapi.py


)
def main(env_name):
def test_run_environment(env_name):
"""
Run the low-level API test using the specified environment
:param env_name: Name of the Unity environment binary to launch

else:
# Should never happen
action = None
if tracked_agent == -1 and len(decision_steps) > 1:
if tracked_agent == -1 and len(decision_steps) >= 1:
tracked_agent = decision_steps.agent_id[0]
env.set_actions(group_name, action)
env.step()

env.close()
def test_closing(env_name):
"""
Run the low-level API and close the environment
:param env_name: Name of the Unity environment binary to launch
"""
try:
env1 = UnityEnvironment(
file_name=env_name, base_port=5006, no_graphics=True, args=["-logFile", "-"]
)
env1.close()
env1 = UnityEnvironment(
file_name=env_name, base_port=5006, no_graphics=True, args=["-logFile", "-"]
)
env2 = UnityEnvironment(
file_name=env_name, base_port=5007, no_graphics=True, args=["-logFile", "-"]
)
env2.reset()
finally:
env1.close()
env2.close()
main(args.env)
test_run_environment(args.env)
test_closing(args.env)
正在加载...
取消
保存