code: def wait_for_k8s_job_completion(
      namespace: str, entity: str, project: str, num_jobs: int
  ) -> str:
      """W&B's wait_until_finished() doesn't work for image based jobs, so poll the k8s output for job completion."""
      config.load_kube_config()
      v1 = client.CoreV1Api()
      w = watch.Watch()
      status = None
      completed_jobs = 0
      for event in w.stream(
          v1.list_namespaced_pod,
          namespace=namespace,
          timeout_seconds=300,
      ):
          if event["object"].metadata.name.startswith(
              f"launch-{entity}-{project}-"
          ):
              status = event["object"].status.phase
              if status == "Succeeded":
                  completed_jobs += 1
              if completed_jobs == num_jobs:
                  w.stop()
      return status
  
file_path: wandb/tests/release_tests/test_launch/utils.py
imports: import signal
  import subprocess
  import sys
  from time import sleep
  from typing import Optional
  import wandb
  import yaml
  from kubernetes import client, config, watch
  from wandb.apis.public import Api
label_desc: Use image node_id 5 for calling a global function with example usage: wait_for_k8s_job_completion(namespace, entity, project, num_jobs) and returns: status