def test_reraise_exception_in_step(self): constructor = functools.partial(MockEnvironmentCrashInStep, crash_at_step=3) env = parallel_py_environment.ProcessPyEnvironment(constructor) env.start() env.reset() action_spec = env.action_spec() rng = np.random.RandomState() env.step(array_spec.sample_bounded_spec(action_spec, rng)) env.step(array_spec.sample_bounded_spec(action_spec, rng)) with self.assertRaises(Exception): env.step(array_spec.sample_bounded_spec(action_spec, rng))
def test_close_no_hang_after_init(self): constructor = functools.partial( random_py_environment.RandomPyEnvironment, array_spec.ArraySpec((3, 3), np.float32), array_spec.BoundedArraySpec([1], np.float32, minimum=-1.0, maximum=1.0), episode_end_probability=0, min_duration=2, max_duration=2) env = parallel_py_environment.ProcessPyEnvironment(constructor) env.start() env.close()
def test_close_no_hang_after_step(self): constructor = functools.partial( random_py_environment.RandomPyEnvironment, array_spec.ArraySpec((3, 3), np.float32), array_spec.BoundedArraySpec([1], np.float32, minimum=-1.0, maximum=1.0), episode_end_probability=0, min_duration=5, max_duration=5) rng = np.random.RandomState() env = parallel_py_environment.ProcessPyEnvironment(constructor) env.start() action_spec = env.action_spec() env.reset() env.step(array_spec.sample_bounded_spec(action_spec, rng)) env.step(array_spec.sample_bounded_spec(action_spec, rng)) env.close()
def test_reraise_exception_in_reset(self): constructor = MockEnvironmentCrashInReset env = parallel_py_environment.ProcessPyEnvironment(constructor) env.start() with self.assertRaises(Exception): env.reset()