Get current job ID for this worker or driver. Job ID is the id of your Ray drivers that create tasks or actors. Returns: If called by a driver, this returns the job ID. If called in a task, return the job ID of the associated driver. The job ID w
(self)
| 60 | return job_id |
| 61 | |
| 62 | def get_job_id(self) -> str: |
| 63 | """Get current job ID for this worker or driver. |
| 64 | |
| 65 | Job ID is the id of your Ray drivers that create tasks or actors. |
| 66 | |
| 67 | Returns: |
| 68 | If called by a driver, this returns the job ID. If called in |
| 69 | a task, return the job ID of the associated driver. The |
| 70 | job ID will be hex format. |
| 71 | |
| 72 | Raises: |
| 73 | RuntimeError: If Ray has not been initialized. |
| 74 | """ |
| 75 | if not ray.is_initialized(): |
| 76 | raise RuntimeError( |
| 77 | "Job ID is not available because Ray has not been initialized." |
| 78 | ) |
| 79 | job_id = self.worker.current_job_id |
| 80 | return job_id.hex() |
| 81 | |
| 82 | @property |
| 83 | @Deprecated(message="Use get_node_id() instead", warning=True) |