mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 03:50:55 +08:00
60d4d5e1aa
* Remove all __future__ imports from RLlib. * Remove (object) again from tf_run_builder.py::TFRunBuilder. * Fix 2xLINT warnings. * Fix broken appo_policy import (must be appo_tf_policy) * Remove future imports from all other ray files (not just RLlib). * Remove future imports from all other ray files (not just RLlib). * Remove future import blocks that contain `unicode_literals` as well. Revert appo_tf_policy.py to appo_policy.py (belongs to another PR). * Add two empty lines before Schedule class. * Put back __future__ imports into determine_tests_to_run.py. Fails otherwise on a py2/print related error.
31 lines
747 B
Python
31 lines
747 B
Python
import ray.worker
|
|
|
|
|
|
class RuntimeContext:
|
|
"""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
|