mirror of
https://github.com/wassname/ray.git
synced 2026-08-02 13:01:01 +08:00
[rllib] support local mode (#2795)
This commit is contained in:
committed by
Robert Nishihara
parent
0ac855e061
commit
b37a283053
@@ -4,6 +4,8 @@ from __future__ import print_function
|
||||
|
||||
import ray
|
||||
|
||||
_local = {} # dict for local mode
|
||||
|
||||
|
||||
def _internal_kv_initialized():
|
||||
worker = ray.worker.get_global_worker()
|
||||
@@ -14,6 +16,9 @@ def _internal_kv_get(key):
|
||||
"""Fetch the value of a binary key."""
|
||||
|
||||
worker = ray.worker.get_global_worker()
|
||||
if worker.mode == ray.worker.LOCAL_MODE:
|
||||
return _local.get(key)
|
||||
|
||||
return worker.redis_client.hget(key, "value")
|
||||
|
||||
|
||||
@@ -27,6 +32,12 @@ def _internal_kv_put(key, value, overwrite=False):
|
||||
"""
|
||||
|
||||
worker = ray.worker.get_global_worker()
|
||||
if worker.mode == ray.worker.LOCAL_MODE:
|
||||
exists = key in _local
|
||||
if not exists or overwrite:
|
||||
_local[key] = value
|
||||
return exists
|
||||
|
||||
if overwrite:
|
||||
updated = worker.redis_client.hset(key, "value", value)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user