Ray timeline: no profiling events found

Hello,

Newbie question. I am trying to collect a chrome://tracing timeline from a very simple Ray application following the steps in the documentation. Consider this trivial code:

#!/usr/bin/env python3

import ray

ray.init()
ray.timeline(filename="/tmp/timeline.json")

@ray.remote
def f(x):
    return x * x

future = f.remote(2.0)
value = ray.get(future)
print(value)

I ran it using the following commands:

export RAY_PROFILING=1
./example.py

The output (given below) says that no profiling events were found even though a remote function was, in fact, executed and the environment variable was set. The file timeline.json is empty. I was expecting to see a timeline with a single task in it (or something along these lines).

2022-04-26 09:27:25,058 INFO services.py:1456 -- View the Ray dashboard at http://127.0.0.1:8265
2022-04-26 09:27:26,357 WARNING state.py:502 -- No profiling events found. Ray profiling must be enabled by setting RAY_PROFILING=1.
4.0

Am I doing something wrong? The documentation section about the timeline is very terse.

  • Ray version: 1.12.0
  • Python version: 3.9.0

Hey @leiteg, I moved the timeline call to after the task execution and added a sleep and it worked. Calling .timeline() immediately requests Ray generate the timeline from data collected so far. There is a little bit of propagation delay waiting for tasks to finish, which is why the small delay was needed (I’ll make a patch to fix this for future users):

import ray

ray.init()

@ray.remote
def f(x):
    return x * x

future = f.remote(2.0)
value = ray.get(future)
print(value)

import time
time.sleep(1)
ray.timeline(filename="/tmp/timeline.json")

Thanks @ericl, it works now! I thought that the call to ray.timeline would enable the collection of events, therefore had to be done at the beginning.