docstr: Expect some sub-envs to fail (and not recover).
docstr_tok: ["Expect","some","sub-envs","to","fail","(","and","not","recover",")","."]
code: def test_crash_during_sampling(self):
      """Expect some sub-envs to fail (and not recover)."""
      config = (
          PPOConfig()
          .rollouts(num_rollout_workers=2, num_envs_per_worker=3)
          .environment(
              env=CartPoleCrashing,
              env_config={
                  # Crash prob=20%.
                  "p_crash": 0.2,
                  "init_time_s": 0.3,
                  # Make sure nothing happens during pre-checks.
                  "skip_env_checking": True,
              },
          )
      )
      # Pre-checking disables, so building the Algorithm is save.
      algo = config.build()
      # Expect EnvError due to the sub-env(s) crashing on the different workers
      # and `ignore_worker_failures=False` (so the original EnvError should
      # just be bubbled up by RLlib Algorithm and tune.Trainable during the `step()`
      # call).
      self.assertRaisesRegex(
          EnvError, "Simulated env crash", lambda: algo.train()
      )
  
file_path: ray/python/ray/rllib/evaluation/tests/test_envs_that_crash.py
imports: import unittest
  import ray
  from ray.rllib.algorithms.pg import PGConfig
  from ray.rllib.algorithms.ppo import PPOConfig
  from ray.rllib.algorithms.tests.test_worker_failures import ForwardHealthCheckToEnvWorker
  from ray.rllib.examples.env.cartpole_crashing import CartPoleCrashing
  from ray.rllib.utils.error import EnvError
label_desc: Use image node_id 4 for calling the TestEnvsThatCrash obj's underlying member method code with example usage: obj.test_crash_during_sampling() without return types