How to get the session id?

When I run ray.init(), a new session is created under _temp_dir/. that looks like:

session_2024-04-01_13-27-11_643213_12243

I’ve tried looking through the ray._private.worker.RayContext object returned by ray.init() but can’t seem to find this session id anywhere.

The motivation for this is that I need to clear the session temp files after a run to conserve storage space!

Ahh, according to this doc, its symlinked to session_latest, so you can just do:

os.readlink(f'/tmp/ray/session_latest')