def ray_start_1_cpu(): address_info = ray.init(num_cpus=1) yield address_info # The code after the yield will run as teardown code. ray.shutdown() @pytest.fixture def ray_start_4_cpu(): address_info = ray.init(num_cpus=4) yield address_info # The code after the yield will run as teardown code. ray.shutdown() @pytest.mark.skipif(test_external_redis(), reason="The same Redis is used within the test.") def test_ray_init(shutdown_only): def getpid(args): return os.getpid() def check_pool_size(pool, size): args = [tuple() for _ in range(size)] assert len(set(pool.map(getpid, args))) == size # Check that starting a pool starts ray if not initialized. pool = Pool(processes=2) assert ray.is_initialized() assert int(ray.cluster_resources()["CPU"]) == 2 check_pool_size(pool, 2) pool.terminate()
def maybe_external_redis(request): if test_external_redis(): with _setup_redis(request): yield else: yield
runtime_env: "RuntimeEnv", ctx: RuntimeEnvContext # noqa: F821 ) -> float: sleep(3600) class DiasbleTimeoutPlugin(DummyPlugin): def create( uri: str, runtime_env: "RuntimeEnv", ctx: RuntimeEnvContext # noqa: F821 ) -> float: sleep(10) @pytest.mark.skipif(test_external_redis(), reason="Failing in redis mode.") def test_plugin_timeout(start_cluster): @ray.remote(num_cpus=0.1) def f(): return True refs = [ f.options( runtime_env={ "plugins": { HANG_PLUGIN_CLASS_PATH: { "name": "f1" }, }, "config": { "setup_timeout_seconds": 10