From 8fca2a82a6965ee6624ecd6ba7e97e68e81019cd Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Wed, 21 Jun 2023 16:58:30 -0500 Subject: [PATCH 1/2] Fix ray.timeline Signed-off-by: Stephanie Wang --- python/ray/_private/state.py | 2 +- python/ray/tests/test_state_api_2.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/python/ray/_private/state.py b/python/ray/_private/state.py index 326f5b8e4e327..05234812c7b4c 100644 --- a/python/ray/_private/state.py +++ b/python/ray/_private/state.py @@ -215,7 +215,7 @@ def profile_events(self): result = defaultdict(list) task_events = self.global_state_accessor.get_task_events() for i in range(len(task_events)): - event = common_pb2.TaskEvents.FromString(task_events[i]) + event = gcs_pb2.TaskEvents.FromString(task_events[i]) profile = event.profile_events if not profile: continue diff --git a/python/ray/tests/test_state_api_2.py b/python/ray/tests/test_state_api_2.py index c5f3ce4276c56..680636da3dfa0 100644 --- a/python/ray/tests/test_state_api_2.py +++ b/python/ray/tests/test_state_api_2.py @@ -3,6 +3,7 @@ import os import sys from pathlib import Path +import tempfile from collections import defaultdict from ray._private.test_utils import check_call_subprocess @@ -355,6 +356,26 @@ def test_state_api_scale_smoke(shutdown_only): check_call_subprocess(["python", str(full_path), "--smoke-test"]) +def test_ray_timeline(shutdown_only): + ray.init(num_cpus=8) + + @ray.remote + def f(): + import time + + ray.get(f.remote()) + + with tempfile.TemporaryDirectory() as tmpdirname: + filename = os.path.join(tmpdirname, "timeline.json") + ray.timeline(filename) + + with open(filename, "r") as f: + dumped = json.load(f) + # TODO(swang): Check actual content. It doesn't seem to match the + # return value of chrome_tracing_dump in above tests? + assert len(dumped) > 0 + + if __name__ == "__main__": import sys From cd58b334c0b05dc422b780a6a52ad9748f5e44ea Mon Sep 17 00:00:00 2001 From: Stephanie Wang Date: Wed, 21 Jun 2023 16:58:41 -0500 Subject: [PATCH 2/2] Fix ray.timeline Signed-off-by: Stephanie Wang --- python/ray/tests/test_state_api_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ray/tests/test_state_api_2.py b/python/ray/tests/test_state_api_2.py index 680636da3dfa0..81d8d04f299b8 100644 --- a/python/ray/tests/test_state_api_2.py +++ b/python/ray/tests/test_state_api_2.py @@ -361,7 +361,7 @@ def test_ray_timeline(shutdown_only): @ray.remote def f(): - import time + pass ray.get(f.remote())