Ejemplo n.º 1
0
def test_multi_sync_env_runner_load_state_no_file(mock_task, mock_agent):
    # Assign
    env_runner = MultiSyncEnvRunner(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()
Ejemplo n.º 2
0
def test_multi_sync_env_runner_info_no_data_logger(mock_task, mock_agent):
    # Assign
    mock_tasks: List[TaskType] = [mock_task, mock_task]
    env_runner = MultiSyncEnvRunner(mock_tasks, 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()
Ejemplo n.º 3
0
def test_multi_sync_env_runner_info_with_data_logger(mock_task, mock_agent):
    # Assign
    data_logger = mock.MagicMock()
    env_runner = MultiSyncEnvRunner(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)