ray.runtime_context.get_runtime_context#
- ray.runtime_context.get_runtime_context() RuntimeContext [source]#
Get the runtime context of the current driver/worker.
The obtained runtime context can be used to get the metadata of the current task and actor.
Note: For Ray Client, ray.get_runtime_context().get_node_id() should point to the head node. Also, keep in mind that ray._private.worker.global_worker will create a new worker object here if global_worker doesn’t point to one.
Example
import ray # Get the job id. ray.get_runtime_context().get_job_id() # Get the actor id. ray.get_runtime_context().get_actor_id() # Get the task id. ray.get_runtime_context().get_task_id()