Skip to content

Commit

Permalink
[core] Fix ray.timeline() (ray-project#36676)
Browse files Browse the repository at this point in the history
Fix a typo bug in ray.timeline() and add a basic test.

---------

Signed-off-by: Stephanie Wang <swang@cs.berkeley.edu>
Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
  • Loading branch information
stephanie-wang authored and arvind-chandra committed Aug 31, 2023
1 parent 1e5013b commit 40a8648
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/ray/_private/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions python/ray/tests/test_state_api_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
pass

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

Expand Down

0 comments on commit 40a8648

Please sign in to comment.