def test_training_arguments_timestamp(monkeypatch, grim_config): """Test TrainingWrapperArguments correctly applies a timestamp.""" def mock_return(): return '2019-06-29_17-13-41' monkeypatch.setattr(grimagents.common, "get_timestamp", mock_return) grim_config['--timestamp'] = True arguments = TrainingWrapperArguments(grim_config) arguments_string = arguments.get_arguments_as_string() assert '--run-id 3DBall-2019-06-29_17-13-41' in arguments_string
def test_env_args_placed_last(): """Tests that '--env-args' are placed at the end of the training command arguments.""" config = { 'trainer-config-path': 'config/3DBall.yaml', '--env-args': ["--num-orcs", 42], '--env': 'builds/3DBall/3DBall.exe', '--export-path': 'UnitySDK/Assets/ML-Agents/Examples/3DBall/ImportedModels', '--run-id': '3DBall', } arguments = TrainingWrapperArguments(config) result = arguments.get_arguments_as_string() assert result.endswith('--env-args --num-orcs 42')
def test_training_arguments_set_methods(grim_config): """Tests that TrainingWrapperArguments correctly sets argument values.""" arguments = TrainingWrapperArguments(grim_config) arguments.set_env('builds/3DBall/3DBallHard.exe') arguments.set_run_id('ball') arguments.set_num_envs('4') arguments.set_no_graphics_enabled(True) arguments.set_timestamp_enabled(True) arguments.set_multi_gpu_enabled(True) arguments.set_env_args(["--num-orcs", 42]) arguments_string = arguments.get_arguments_as_string() assert '--env builds/3DBall/3DBallHard.exe' in arguments_string assert '--run-id ball' in arguments_string assert '--num-envs 4' in arguments_string assert '--no-graphics' in arguments_string assert '--run-id ball-' in arguments_string assert '--multi-gpu' in arguments_string assert '--num-orcs 42' in arguments_string