code: def test_requirements_files(start_cluster, field):
      """Test the use of requirements.txt and environment.yaml.
  
      Tests that requirements files are parsed on the driver, not the cluster.
      This is the desired behavior because the file paths only make sense on the
      driver machine. The files do not exist on the remote cluster.
  
      Also tests the common use case of specifying the option --extra-index-url
      in a pip requirements.txt file.
      """
      cluster, address = start_cluster
  
      # cd into a temporary directory and pass in pip/conda requirements file
      # using a relative path.  Since the cluster has already been started,
      # the cwd of the processes on the cluster nodes will not be this
      # temporary directory.  So if the nodes try to read the requirements file,
      # this test should fail because the relative path won't make sense.
      with tempfile.TemporaryDirectory() as tmpdir, chdir(tmpdir):
          pip_list = [
              "--extra-index-url https://pypi.org/simple",
              "pip-install-test==0.5",
          ]
          if field == "conda":
              conda_dict = {"dependencies": ["pip", {"pip": pip_list}]}
              relative_filepath = "environment.yml"
              conda_file = Path(relative_filepath)
              conda_file.write_text(yaml.dump(conda_dict))
              runtime_env = {"conda": relative_filepath}
          elif field == "pip":
              relative_filepath = "requirements.txt"
              pip_file = Path(relative_filepath)
              pip_file.write_text("\n".join(pip_list))
              runtime_env = {"pip": relative_filepath}
  
          ray.init(address, runtime_env=runtime_env)
  
          @ray.remote
          def f():
              import pip_install_test  # noqa: F401
  
              return True
  
          # Ensure that the runtime env has been installed.
          assert ray.get(f.remote())
  
imports: import os
  import pytest
  import sys
  import platform
  import time
  from ray._private.test_utils import wait_for_condition, chdir, check_local_files_gced, generate_runtime_env_dict
  from ray._private.runtime_env.conda import _get_conda_dict_with_ray_inserted
  from ray._private.runtime_env.pip import INTERNAL_PIP_FILENAME, MAX_INTERNAL_PIP_FILENAME_TRIES, _PathHelper
  from ray.runtime_env import RuntimeEnv
  import yaml
  import tempfile
  from pathlib import Path
  import subprocess
  import ray
label_desc: Use image node_id 2 for calling a global function with example usage: test_requirements_files(start_cluster, field) and returns: True