code: def test_worker_stats(shutdown_only):
      ray.init(num_cpus=2, include_dashboard=True)
      raylet = ray.nodes()[0]
      reply = get_node_stats(raylet)
      # Check that there is one connected driver.
      drivers = [
          worker
          for worker in reply.core_workers_stats
          if worker.worker_type == common_pb2.DRIVER
      ]
      assert len(drivers) == 1
      assert os.getpid() == drivers[0].pid
  
      @ray.remote
      def f():
          ray._private.worker.show_in_dashboard("test")
          return os.getpid()
  
      @ray.remote(num_cpus=1)
      class Actor:
          def __init__(self):
              pass
  
          def f(self):
              ray._private.worker.show_in_dashboard("test")
              return os.getpid()
  
      # Test show_in_dashboard for remote functions.
      worker_pid = ray.get(f.remote())
      reply = get_node_stats(raylet)
      target_worker_present = False
      for stats in reply.core_workers_stats:
          if (
              stats.webui_display[""]
              == '{"message": "test", "dtype": "text"}'
          ):
              target_worker_present = True
              assert stats.pid == worker_pid
          else:
              assert stats.webui_display[""] == ""  # Empty proto
      assert target_worker_present
  
      # Test show_in_dashboard for remote actors.
      a = Actor.remote()
      worker_pid = ray.get(a.f.remote())
      reply = get_node_stats(raylet)
      target_worker_present = False
      for stats in reply.core_workers_stats:
          if (
              stats.webui_display[""]
              == '{"message": "test", "dtype": "text"}'
          ):
              target_worker_present = True
          else:
              assert stats.webui_display[""] == ""  # Empty proto
      assert target_worker_present
  
      # 1 actor + 1 worker for task + 1 driver
      num_workers = 3
  
      def verify():
          reply = get_node_stats(raylet)
          # Check that the rest of the processes are workers, 1 for each CPU.
  
          assert len(reply.core_workers_stats) == num_workers
          # Check that all processes are Python.
          pids = [worker.pid for worker in reply.core_workers_stats]
          processes = [
              p.info["name"]
              for p in psutil.process_iter(attrs=["pid", "name"])
              if p.info["pid"] in pids
          ]
          for process in processes:
              # TODO(ekl) why does travis/mi end up in the process list
              assert (
                  "python" in process
                  or "mini" in process
                  or "conda" in process
                  or "travis" in process
                  or "runner" in process
                  or "pytest" in process
                  or "ray" in process
              ), process
  
          return True
  
      wait_for_condition(verify)
  
file_path: ray/python/ray/tests/test_metrics.py
imports: import os
  import platform
  import psutil
  import pytest
  import requests
  import ray
  from ray._private.test_utils import wait_for_condition, wait_until_succeeded_without_exception, get_node_stats
  from ray.core.generated import common_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: test_worker_stats(shutdown_only) and returns: os, True, os