class_docstr: Test that no user info (e.g. runtime env env vars) show up in the logs.
class_docstr_tok: ["Test","that","no","user","info","(","e.g",".","runtime","env","env","vars",")","show","up","in","the","logs","."]
docstr: Test driver with and without Ray Client.
docstr_tok: ["Test","driver","with","and","without","Ray","Client","."]
code: def test_basic(
      self, start_cluster, monkeypatch, tmp_path, shutdown_only
  ):
      """Test driver with and without Ray Client."""
  
      cluster, address = start_cluster
  
      # Runtime env logs may still appear in debug logs. Check the debug flag is off.
      assert os.getenv("RAY_BACKEND_LOG_LEVEL") != "debug"
  
      # Reuse the same "secret" for working_dir, pip, env_vars for convenience.
      USER_SECRET = "pip-install-test"
      working_dir = tmp_path / USER_SECRET
      working_dir.mkdir()
      runtime_env = {
          "working_dir": str(working_dir),
          "pip": [USER_SECRET],
          # Append address to ensure different runtime envs for client and non-client
          # code paths to force reinstalling the runtime env instead of reusing it.
          "env_vars": {USER_SECRET: USER_SECRET + str(address)},
      }
      ray.init(runtime_env=runtime_env)
  
      # Run a function to ensure the runtime env is set up.
      @ray.remote
      def f():
          return os.environ.get(USER_SECRET)
  
      assert USER_SECRET in ray.get(f.remote())
  
      @ray.remote
      class Foo:
          def __init__(self):
              self.x = os.environ.get(USER_SECRET)
  
          def get_x(self):
              return self.x
  
      foo = Foo.remote()
      assert USER_SECRET in ray.get(foo.get_x.remote())
  
      # Generate runtime env failure logs too.
      bad_runtime_env = {
          "pip": ["pkg-which-sadly-does-not-exist"],
          "env_vars": {USER_SECRET: USER_SECRET},
      }
      with pytest.raises(Exception):
          ray.get(f.options(runtime_env=bad_runtime_env).remote())
      with pytest.raises(Exception):
          foo2 = Foo.options(runtime_env=bad_runtime_env).remote()
          ray.get(foo2.get_x.remote())
  
      using_ray_client = address.startswith("ray://")
  
      # Test Ray Jobs API codepath. Skip for ray_minimal because Ray Jobs API
      # requires ray[default]. Skip for Windows because Dashboard and Ray Jobs
      # are not tested on Windows.
      if (
          not using_ray_client
          and os.environ.get("RAY_MINIMAL") != "1"
          and not sys.platform == "win32"
      ):
          client = JobSubmissionClient()
          job_id_good_runtime_env = client.submit_job(
              entrypoint="echo 'hello world'", runtime_env=runtime_env
          )
          job_id_bad_runtime_env = client.submit_job(
              entrypoint="echo 'hello world'",
              runtime_env=bad_runtime_env,
          )
  
          def job_succeeded(job_id):
              job_status = client.get_job_status(job_id)
              return job_status == JobStatus.SUCCEEDED
  
          def job_failed(job_id):
              job_status = client.get_job_status(job_id)
              return job_status == JobStatus.FAILED
  
          wait_for_condition(
              lambda: job_succeeded(job_id_good_runtime_env)
          )
          wait_for_condition(
              lambda: job_failed(job_id_bad_runtime_env), timeout=30
          )
  
      with pytest.raises(AssertionError):
          assert_no_user_info_in_logs(USER_SECRET)
  
      assert_no_user_info_in_logs(
          USER_SECRET, file_whitelist=["runtime_env*.log"]
      )
  
file_path: ray/python/ray/tests/test_runtime_env_2.py
imports: import pytest
  import time
  import sys
  import fnmatch
  import os
  from typing import List
  import ray
  from ray.dashboard.modules.job.common import JobStatus
  from ray.exceptions import RuntimeEnvSetupError
  from ray.runtime_env import RuntimeEnv, RuntimeEnvConfig
  from ray._private.test_utils import wait_for_condition
label_desc: Use image node_id 2 for calling the TestNoUserInfoInLogs obj's underlying member method code with example usage: obj.test_basic(start_cluster, monkeypatch, tmp_path, shutdown_only) and returns: os, self, unknown, unknown