Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix ray.timeline() #36676

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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