def test_line_has_time_elapsed(): """Test that TrainingRunInfo can parse time elapsed values from console output.""" info = TrainingRunInfo() assert info.line_has_time_elapsed('\t\tmax_steps:\t3.0e3') is False assert ( info.line_has_time_elapsed( 'INFO:mlagents.trainers: 3DBall_00: 3DBallLearning: Step: 1000. Time Elapsed: 12.398 s Mean Reward: 1.259. Std of Reward: 0.799. Training.' ) is True )
def test_parse_max_steps(training_output): """Test that TrainingRunInfo can parse a max_steps value from console output.""" info = TrainingRunInfo() info.update_from_training_output('Final Mean Reward: 1.763') assert info.max_steps == 0 for line in training_output: info.update_from_training_output(line) assert info.max_steps == 3000
def test_parse_steps(training_output): """Test that TrainingRunInfo can parse a steps value from console output.""" info = TrainingRunInfo() for line in training_output: info.update_from_training_output(line) assert info.step == 3000 info.update_from_training_output( 'INFO:mlagents.trainers: 3DBall_00: 3DBallLearning: Step: 1000. Time Elapsed: 12.398 s Mean Reward: 1.259. Std of Reward: 0.799. Training.' ) assert info.step == 1000
def test_parse_exported_brains(training_output): """Test that TrainingRunInfo can parse exported brain values from console output.""" info = TrainingRunInfo() for line in training_output: info.update_from_training_output(line) assert info.exported_brains == [Path('./models/3DBall_00/3DBallLearning.nn')] info.update_from_training_output( 'INFO:mlagents.trainers:Exported ./models/3DBall_00/3DBallHardLearning.nn file' ) assert info.exported_brains == [ Path('./models/3DBall_00/3DBallLearning.nn'), Path('./models/3DBall_00/3DBallHardLearning.nn'), ]
def test_time_remaining(): """Test that TrainingRunInfo can calculate steps_remaining and time_remaining as well as handle edge cases. Edge cases include: - all values have yet to be found - max_steps has not been found - steps matches max_steps value - steps value exceeds max_steps value """ info = TrainingRunInfo() assert info.time_remaining == 0 info.update_from_training_output( 'INFO:mlagents.trainers: 3DBall_00: 3DBallLearning: Step: 1000. Time Elapsed: 12.398 s Mean Reward: 1.259. Std of Reward: 0.799. Training.' ) assert info.time_remaining == 0 info.max_steps = 3000 info.update_from_training_output( 'INFO:mlagents.trainers: 3DBall_00: 3DBallLearning: Step: 1000. Time Elapsed: 12.398 s Mean Reward: 1.259. Std of Reward: 0.799. Training.' ) assert info.time_remaining == 24.796 info.update_from_training_output( 'INFO:mlagents.trainers: 3DBall_00: 3DBallLearning: Step: 3000. Time Elapsed: 30.652 s Mean Reward: 1.763. Std of Reward: 1.054. Training.' ) assert info.time_remaining == 0.0 info.update_from_training_output( 'INFO:mlagents.trainers: 3DBall_00: 3DBallLearning: Step: 4000. Time Elapsed: 30.652 s Mean Reward: 1.763. Std of Reward: 1.054. Training.' ) assert info.time_remaining == 0.0