Skip to content

Remove env creation logic from TrainerController #1562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Final tweaks to fix merge issues
  • Loading branch information
harper-u3d committed Jan 24, 2019
commit 9a323f5cf6bd39052e00f91b3ff42c502816b2a8
5 changes: 2 additions & 3 deletions ml-agents/mlagents/trainers/trainer_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def start_learning(self, env, trainer_config):
for _, t in self.trainers.items():
self.logger.info(t)

global_step = 0 # This is only for saving the model
curr_info = self._reset_env()
curr_info = self._reset_env(env)
if self.train_model:
for brain_name, trainer in self.trainers.items():
trainer.write_tensorboard_text('Hyperparameters',
Expand All @@ -211,7 +210,7 @@ def start_learning(self, env, trainer_config):
or not self.train_model:
new_info = self.take_step(env, curr_info)
self.global_step += 1
if global_step % self.save_freq == 0 and self.global_step != 0 \
if self.global_step % self.save_freq == 0 and self.global_step != 0 \
and self.train_model:
# Save Tensorflow model
self._save_model(steps=self.global_step)
Expand Down
6 changes: 3 additions & 3 deletions ml-agents/tests/trainers/test_trainer_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def trainer_controller_with_start_learning_mocks():
tc.trainers = {'testbrain': trainer_mock}
tc.take_step = MagicMock()

def take_step_sideeffect(env, curr_info, global_step):
def take_step_sideeffect(env, curr_info):
tc.trainers['testbrain'].get_step += 1
if tc.trainers['testbrain'].get_step > 10:
raise KeyboardInterrupt
Expand Down Expand Up @@ -382,7 +382,7 @@ def test_take_step_resets_env_on_global_done():
env_mock.reset = MagicMock(return_value=brain_info_mock)
env_mock.global_done = True

tc.take_step(env_mock, brain_info_mock, 0)
tc.take_step(env_mock, brain_info_mock)
env_mock.reset.assert_called_once()


Expand All @@ -407,7 +407,7 @@ def test_take_step_adds_experiences_to_trainer_and_trains():
env_mock.reset = MagicMock(return_value=curr_info_mock)
env_mock.global_done = False

tc.take_step(env_mock, curr_info_mock, 0)
tc.take_step(env_mock, curr_info_mock)
env_mock.reset.assert_not_called()
trainer_mock.take_action.assert_called_once_with(curr_info_mock)
env_mock.step.assert_called_once_with(
Expand Down