浏览代码

fix subprocess test and style checks on develop (#2248)

* fix tests that broke with new arg

* fix black
/develop-generalizationTraining-TrainerController
GitHub 5 年前
当前提交
d415528a
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 8
      ml-agents-envs/mlagents/envs/subprocess_env_manager.py
  2. 4
      ml-agents-envs/mlagents/envs/tests/test_subprocess_env_manager.py

8
ml-agents-envs/mlagents/envs/subprocess_env_manager.py


elif cmd.name == "reset_parameters":
_send_response("reset_parameters", env.reset_parameters)
elif cmd.name == "reset":
all_brain_info = env.reset(cmd.payload[0], cmd.payload[1], cmd.payload[2])
all_brain_info = env.reset(
cmd.payload[0], cmd.payload[1], cmd.payload[2]
)
_send_response("reset", all_brain_info)
elif cmd.name == "global_done":
_send_response("global_done", env.global_done)

steps.append(step_info)
return steps
def reset(self, config=None, train_mode=True, custom_reset_parameters=None) -> List[StepInfo]:
def reset(
self, config=None, train_mode=True, custom_reset_parameters=None
) -> List[StepInfo]:
self._broadcast_message("reset", (config, train_mode, custom_reset_parameters))
reset_results = [
self.env_workers[i].recv().payload for i in range(len(self.env_workers))

4
ml-agents-envs/mlagents/envs/tests/test_subprocess_env_manager.py


manager = SubprocessEnvManager(mock_env_factory, 1)
params = {"test": "params"}
manager.reset(params, False)
manager.env_workers[0].send.assert_called_with("reset", (params, False))
manager.env_workers[0].send.assert_called_with("reset", (params, False, None))
def test_reset_collects_results_from_all_envs(self):
SubprocessEnvManager.create_worker = lambda em, worker_id, env_factory: MockEnvWorker(

params = {"test": "params"}
res = manager.reset(params)
for i, env in enumerate(manager.env_workers):
env.send.assert_called_with("reset", (params, True))
env.send.assert_called_with("reset", (params, True, None))
env.recv.assert_called()
# Check that the "last steps" are set to the value returned for each step
self.assertEqual(

正在加载...
取消
保存