From db5cc5c8da007f835d6970e47b24cad29aeffcbe Mon Sep 17 00:00:00 2001 From: Kai Yang Date: Tue, 9 Jun 2020 11:42:40 +0800 Subject: [PATCH] fix test_global_state_api due to the temporary object (#8800) * fix test_global_state_api due to the temporary object * update * Update python/ray/tests/test_advanced_3.py Co-authored-by: Robert Nishihara Co-authored-by: Robert Nishihara --- python/ray/tests/test_advanced_3.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/ray/tests/test_advanced_3.py b/python/ray/tests/test_advanced_3.py index 9658920fd..131ce14e6 100644 --- a/python/ray/tests/test_advanced_3.py +++ b/python/ray/tests/test_advanced_3.py @@ -126,7 +126,14 @@ def test_global_state_api(shutdown_only): assert ray.cluster_resources()["GPU"] == 3 assert ray.cluster_resources()["CustomResource"] == 1 - assert ray.objects() == {} + # A driver/worker creates a temporary object during startup. Although the + # temporary object is freed immediately, in a rare case, we can still find + # the object ID in GCS because Raylet removes the object ID from GCS + # asynchronously. + # Because we can't control when workers create the temporary objects, so + # We can't assert that `ray.objects()` returns an empty dict. Here we just + # make sure `ray.objects()` succeeds. + assert len(ray.objects()) >= 0 job_id = ray.utils.compute_job_id_from_driver( ray.WorkerID(ray.worker.global_worker.worker_id))