|
|
|
|
|
|
external_brains = {"testbrain": brain_params_mock} |
|
|
|
|
|
|
|
def mock_constructor( |
|
|
|
self, |
|
|
|
brain, |
|
|
|
reward_buff_cap, |
|
|
|
trainer_parameters, |
|
|
|
training, |
|
|
|
load, |
|
|
|
seed, |
|
|
|
run_id, |
|
|
|
multi_gpu, |
|
|
|
self, brain, reward_buff_cap, trainer_parameters, training, load, seed, run_id |
|
|
|
): |
|
|
|
assert brain == brain_params_mock.brain_name |
|
|
|
assert trainer_parameters == expected_config |
|
|
|
|
|
|
assert seed == seed |
|
|
|
assert run_id == run_id |
|
|
|
assert multi_gpu == multi_gpu |
|
|
|
|
|
|
|
with patch.object(PPOTrainer, "__init__", mock_constructor): |
|
|
|
trainer_factory = trainer_util.TrainerFactory( |
|
|
|
|
|
|
expected_config["keep_checkpoints"] = keep_checkpoints |
|
|
|
|
|
|
|
def mock_constructor( |
|
|
|
self, |
|
|
|
brain, |
|
|
|
reward_buff_cap, |
|
|
|
trainer_parameters, |
|
|
|
training, |
|
|
|
load, |
|
|
|
seed, |
|
|
|
run_id, |
|
|
|
multi_gpu, |
|
|
|
self, brain, reward_buff_cap, trainer_parameters, training, load, seed, run_id |
|
|
|
): |
|
|
|
assert brain == brain_params_mock.brain_name |
|
|
|
assert trainer_parameters == expected_config |
|
|
|
|
|
|
assert seed == seed |
|
|
|
assert run_id == run_id |
|
|
|
assert multi_gpu == multi_gpu |
|
|
|
|
|
|
|
with patch.object(PPOTrainer, "__init__", mock_constructor): |
|
|
|
trainer_factory = trainer_util.TrainerFactory( |
|
|
|