def test_env_runner_load_state_no_file(mock_task, mock_agent): # Assign env_runner = EnvRunner(mock_task, mock_agent, max_iterations=10) env_runner.logger = mock.MagicMock() # Act env_runner.load_state(file_prefix='saved_state') # Assert env_runner.logger.warning.assert_called_once_with( "Couldn't load state. Forcing restart.") mock_agent.load_state.assert_not_called()
def test_env_runner_info_no_data_logger(mock_task, mock_agent): # Assign env_runner = EnvRunner(mock_task, mock_agent) env_runner.logger = mock.MagicMock() info_data = dict(episodes=[2], iterations=[10], scores=[1], mean_scores=[2], epsilons=[1]) # Act env_runner.info(**info_data) # Assert env_runner.logger.info.assert_called_once()
def test_env_runner_info_with_data_logger(mock_task, mock_agent): # Assign data_logger = mock.MagicMock() env_runner = EnvRunner(mock_task, mock_agent, data_logger=data_logger) env_runner.logger = mock.MagicMock() info_data = dict(episodes=[2], iterations=[10], scores=[1], mean_scores=[2], epsilons=[1]) # Act env_runner.info(**info_data) # Assert env_runner.logger.info.assert_called_once() assert data_logger.log_value.call_count == 4 mock_agent.log_metrics.assert_called_once_with(data_logger, mock.ANY, full_log=False)