code: def start_server_subprocess(
      host=defaults.host,
      port=defaults.port,
      graph_creation_extension_dir=None,
      start_local_cuda_cluster=False,
      dask_scheduler_file=None,
      env_additions=None,
  ):
      """
      Start a cugraph_service server as a subprocess. Returns the Popen object
      for the server.
      """
      server_process = None
      env_dict = os.environ.copy()
      if env_additions is not None:
          env_dict.update(env_additions)
  
      # pytest will update sys.path based on the tests it discovers and optional
      # settings in pytest.ini. Make sure any path settings are passed on the the
      # server so modules are properly found.
      env_dict["PYTHONPATH"] = ":".join(sys.path)
  
      # special case: some projects organize their tests/benchmarks by package
      # name, such as "cugraph". Unfortunately, these can collide with installed
      # package names since python will treat them as a namespace package if this
      # is run from a directory with a "cugraph" or similar subdir. Simply change
      # to a temp dir prior to running the server to avoid collisions.
      tempdir_object = TemporaryDirectory()
  
      args = [
          sys.executable,
          "-m",
          "cugraph_service_server",
          "--host",
          host,
          "--port",
          str(port),
      ]
      if graph_creation_extension_dir is not None:
          args += [
              "--graph-creation-extension-dir",
              graph_creation_extension_dir,
          ]
      if dask_scheduler_file is not None:
          args += [
              "--dask-scheduler-file",
              dask_scheduler_file,
          ]
      if start_local_cuda_cluster:
          args += ["--start-local-cuda-cluster"]
  
      try:
          print(
              f"Starting server subprocess using:\n\"{' '.join(args)}\"\n",
              flush=True,
          )
          server_process = subprocess.Popen(
              args,
              env=env_dict,
              stdout=subprocess.PIPE,
              stderr=subprocess.STDOUT,
              text=True,
              cwd=tempdir_object.name,
          )
  
          # Attach tempdir_object to server_process so it is not deleted and
          # removed when it goes out of scope. Instead, it should get deleted
          # when server_process is GC'd
          server_process.tempdir = tempdir_object
  
          print(
              "Launched cugraph_service server, waiting for it to start...",
              end="",
              flush=True,
          )
          client = CugraphServiceClient(host, port)
          max_retries = 60
          retries = 0
          while retries < max_retries:
              try:
                  client.uptime()
                  print("started.")
                  break
              except CugraphServiceError:
                  time.sleep(1)
                  retries += 1
  
              # poll() returns exit code, or None if still running
              if (server_process is not None) and (
                  server_process.poll() is not None
              ):
                  err_output = (
                      _failed_subproc_err_msg
                      % server_process.stdout.read()
                  )
                  server_process = None
                  raise RuntimeError(
                      f"error starting server: {err_output}"
                  )
  
              if retries >= max_retries:
                  raise RuntimeError(
                      "timed out waiting for server to respond"
                  )
  
      except Exception:
          # Stop the server if still running
          if server_process is not None:
              if server_process.poll() is None:
                  server_process.terminate()
                  server_process.wait(timeout=60)
              print(
                  _failed_subproc_err_msg % server_process.stdout.read()
              )
  
          raise
  
      return server_process
  
file_path: cugraph/python/cugraph-service/server/cugraph_service_server/testing/utils.py
imports: import sys
  import os
  import subprocess
  import time
  from tempfile import TemporaryDirectory
  from pathlib import Path
  from cugraph_service_client import CugraphServiceClient, defaults
  from cugraph_service_client.exceptions import CugraphServiceError
label_desc: Use image node_id 2 for calling a global function with example usage: start_server_subprocess(host, port, graph_creation_extension_dir, start_local_cuda_cluster, dask_scheduler_file, env_additions) and returns: server_process