mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 10:17:19 +08:00
62e4b591e3
* WIP WIP WIP Rename Driver -> Job Fix complition Fix Rename in Java In py WIP Fix WIP Fix Fix test Fix Fix C++ linting Fix * Update java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java Co-Authored-By: Stephanie Wang <swang@cs.berkeley.edu> * Update src/ray/core_worker/core_worker.cc Co-Authored-By: Stephanie Wang <swang@cs.berkeley.edu> * Address comments * Fix * Fix CI * Fix cpp linting * Fix py lint * FIx * Address comments and fix * Address comments * Address * Fix import_threading
35 lines
865 B
Python
35 lines
865 B
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
|
|
import ray.worker
|
|
|
|
|
|
class RuntimeContext(object):
|
|
"""A class used for getting runtime context."""
|
|
|
|
def __init__(self, worker=None):
|
|
self.worker = worker
|
|
|
|
@property
|
|
def current_driver_id(self):
|
|
"""Get current driver ID for this worker or driver.
|
|
|
|
Returns:
|
|
If called by a driver, this returns the driver ID. If called in
|
|
a task, return the driver ID of the associated driver.
|
|
"""
|
|
assert self.worker is not None
|
|
return self.worker.current_job_id
|
|
|
|
|
|
_runtime_context = None
|
|
|
|
|
|
def _get_runtime_context():
|
|
global _runtime_context
|
|
if _runtime_context is None:
|
|
_runtime_context = RuntimeContext(ray.worker.get_global_worker())
|
|
|
|
return _runtime_context
|