code: def test_default_worker_import_dependency(shutdown_only):
      """
      Test ray's python worker import doesn't import the not-allowed dependencies.
      """
      # We don't allow numpy to be imported in the worker script to avoid slow
      # worker startup time, as well as interfering with OMP_NUM_THREADS which
      # is used by numpy when imported.
      # See https://github.com/ray-project/ray/issues/33891
      blocked_deps = ["numpy"]
  
      # Ray should not be importing pydantic (used in serialization) eagerly.
      # This introduces regression in worker start up time.
      # https://github.com/ray-project/ray/issues/41338
      blocked_deps += ["pydantic"]
  
      # Remove the ray module and the blocked deps from sys.modules.
      sys.modules.pop("ray", None)
      assert "ray" not in sys.modules
      for dep in blocked_deps:
          sys.modules.pop(dep, None)
          assert dep not in sys.modules
  
      # This imports the python worker.
      import ray._private.workers.default_worker  # noqa: F401
  
      # Check that the ray module is imported.
      assert "ray" in sys.modules
  
      # Check that the blocked deps are not imported.
      for dep in blocked_deps:
          assert dep not in sys.modules
  
      # Test starting a ray workers should not see unwanted deps loaded eagerly.
      ray.init()
  
      @ray.remote
      def f():
          import ray  # noqa: F401
  
          assert "ray" in sys.modules
          for x in blocked_deps:
              assert x not in sys.modules
  
      ray.get(f.remote())
  
imports: import logging
  import os
  import pickle
  import random
  import sys
  import time
  import pytest
  import ray
  import ray.cluster_utils
  from ray._private.test_utils import SignalActor, client_test_enabled, get_error_message, run_string_as_driver
label_desc: Use image node_id 7 for calling a global function with example usage: test_default_worker_import_dependency(shutdown_only) without return types