code: def start_rayservice():
      # step-1: generate the yaml file
      print(f"Using ray image: {ray_image}")
      solution = "\n".join(
          [
              f"    {line}"
              for line in pathlib.Path("./solution.py")
              .read_text()
              .splitlines()
          ]
      )
      locustfile = "\n".join(
          [
              f"    {line}"
              for line in pathlib.Path("./locustfile.py")
              .read_text()
              .splitlines()
          ]
      )
      template = (
          pathlib.Path("ray_v1alpha1_rayservice_template.yaml")
          .read_text()
          .format(
              cluster_id=CLUSTER_ID,
              ray_image=ray_image,
              solution=solution,
              locustfile=locustfile,
          )
      )
  
      print("=== YamlFile ===")
      print(template)
      tmp_yaml = pathlib.Path("/tmp/ray_v1alpha1_rayservice.yaml")
      tmp_yaml.write_text(template)
  
      print("=== Get Pods from ray-system ===")
      print(
          subprocess.check_output(
              [
                  "kubectl",
                  "get",
                  "pods",
                  "--namespace",
                  "ray-system",
                  "--no-headers",
              ]
          ).decode()
      )
  
      # step-2: create the cluter
      print(f"Creating cluster with id: {CLUSTER_ID}")
      print(
          subprocess.check_output(
              ["kubectl", "create", "-f", str(tmp_yaml)]
          ).decode()
      )
  
      # step-3: make sure the ray cluster is up
      w = watch.Watch()
      start_time = time.time()
      head_pod_name = None
      for event in w.stream(
          func=cli.list_namespaced_pod,
          namespace="default",
          label_selector=f"rayCluster={RAY_CLUSTER_NAME},ray.io/node-type=head",
          timeout_seconds=60,
      ):
          if event["object"].status.phase == "Running":
              assert event["object"].kind == "Pod"
              head_pod_name = event["object"].metadata.name
              end_time = time.time()
              print(
                  f"{CLUSTER_ID} started in {end_time-start_time} sec"
              )
              print(f"head pod {head_pod_name}")
              break
      assert head_pod_name is not None
      # step-4: e2e check it's alive
      cmd = """
  import requests
  print(requests.get('http://localhost:8000/?val=123').text)
  """
      while True:
          try:
              resp = (
                  subprocess.check_output(
                      f'kubectl exec {head_pod_name} -- python -c "{cmd}"',
                      shell=True,
                  )
                  .decode()
                  .strip()
              )
              if resp == "375":
                  print("Service is up now!")
                  break
              else:
                  print(f"Failed with msg {resp}")
          except Exception as e:
              print("Error", e)
          time.sleep(2)
  
imports: import enum
  import json
  import subprocess
  from kubernetes import client, config, watch
  import requests
  import random
  import uuid
  import pathlib
  import time
  import ray
  import os
label_desc: Use image node_id 3 for calling a global function with example usage: start_rayservice() without return types