async def test_submit_no_ray_address(call_ray_start): # noqa: F811 """Test that a job script with an unspecified Ray address works.""" ray.init(address=call_ray_start) job_manager = JobManager() init_ray_no_address_script = """ import ray ray.init() # Check that we connected to the running test Ray cluster and didn't create a new one. print(ray.cluster_resources()) assert ray.cluster_resources().get('TestResourceKey') == 123 """ # The job script should work even if RAY_ADDRESS is not set on the cluster. os.environ.pop(RAY_ADDRESS_ENVIRONMENT_VARIABLE, None) job_id = job_manager.submit_job( entrypoint=f"""python -c "{init_ray_no_address_script}" """) await async_wait_for_condition(check_job_succeeded, job_manager=job_manager, job_id=job_id)
async def test_list_jobs(job_manager: JobManager): job_manager.submit_job(entrypoint="echo hi", job_id="1") runtime_env = {"env_vars": {"TEST": "123"}} metadata = {"foo": "bar"} job_manager.submit_job(entrypoint="echo hello", job_id="2", runtime_env=runtime_env, metadata=metadata) await async_wait_for_condition(check_job_succeeded, job_manager=job_manager, job_id="1") await async_wait_for_condition(check_job_succeeded, job_manager=job_manager, job_id="2") jobs_info = job_manager.list_jobs() assert "1" in jobs_info assert jobs_info["1"].status == JobStatus.SUCCEEDED assert "2" in jobs_info assert jobs_info["2"].status == JobStatus.SUCCEEDED assert jobs_info["2"].message is not None assert jobs_info["2"].end_time >= jobs_info["2"].start_time assert jobs_info["2"].runtime_env == runtime_env assert jobs_info["2"].metadata == metadata
def job_manager(shared_ray_instance): yield JobManager()
def test_list_jobs_empty(job_manager: JobManager): assert job_manager.list_jobs() == dict()
async def run(self, server): if not self._job_manager: self._job_manager = JobManager()