code: def wait_for_ray_health(
      pod_name_filter: str,
      namespace: str,
      tries=60,
      backoff_s=5,
      ray_container="ray-head",
  ) -> None:
      """Waits until a Ray pod passes `ray health-check`.
  
      More precisely, waits until a Ray pod whose name includes the string
      `pod_name_filter` passes `ray health-check`.
      (Ensures Ray has completely started in the pod.)
  
      Use case: Wait until there is a Ray head pod with Ray running on it.
      """
      for i in range(tries):
          try:
              pod = get_pod(
                  pod_name_filter=pod_name_filter, namespace="default"
              )
              assert (
                  pod
              ), f"Couldn't find a pod matching {pod_name_filter}."
              # `ray health-check` yields 0 exit status iff it succeeds
              kubectl_exec(
                  ["ray", "health-check"],
                  pod,
                  namespace,
                  container=ray_container,
              )
              logger.info(f"ray health check passes for pod {pod}")
              return
          except subprocess.CalledProcessError as e:
              logger.info(f"Failed ray health check for pod {pod}.")
              if i < tries - 1:
                  logger.info("Trying again.")
                  time.sleep(backoff_s)
              else:
                  logger.info("Giving up.")
                  raise e from None
  
imports: import atexit
  import contextlib
  import logging
  import pathlib
  import subprocess
  import tempfile
  import time
  from typing import Any, Dict, Generator, List, Optional
  import yaml
  import os
  import ray
  from ray.job_submission import JobStatus, JobSubmissionClient
label_desc: Use image node_id 9 for calling a global function with example usage: wait_for_ray_health(pod_name_filter, namespace, tries, backoff_s, ray_container) without return types