docstr: Tests that detached actor's conda env is GC'd only when it exits.
docstr_tok: ["Tests","that","detached","actor","'s","conda","env","is","GC","'d","only","when","it","exits","."]
code: def test_detached_actor_gc(
      self,
      runtime_env_disable_URI_cache,
      start_cluster,
      field,
      spec_format,
      tmp_path,
  ):
      """Tests that detached actor's conda env is GC'd only when it exits."""
      cluster, address = start_cluster
  
      ray.init(
          address,
          namespace="test",
          runtime_env=generate_runtime_env_dict(
              field, spec_format, tmp_path
          ),
      )
  
      @ray.remote
      class A:
          def test_import(self):
              import pip_install_test  # noqa: F401
  
              return True
  
      a = A.options(name="test", lifetime="detached").remote()
      ray.get(a.test_import.remote())
  
      assert not check_local_files_gced(cluster)
  
      ray.shutdown()
      ray.init(address, namespace="test")
  
      assert not check_local_files_gced(cluster)
  
      a = ray.get_actor("test")
      assert ray.get(a.test_import.remote())
  
      ray.kill(a)
  
      wait_for_condition(
          lambda: check_local_files_gced(cluster), timeout=30
      )
  
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 the TestGC obj's underlying member method code with example usage: obj.test_detached_actor_gc(runtime_env_disable_URI_cache, start_cluster, field, spec_format, tmp_path) and returns: True