[tune] Fix registering trainable twice (#2293)

* register twice

* isolate

* Update registry.py

* Update registry.py
This commit is contained in:
Eric Liang
2018-06-27 16:29:39 -07:00
committed by GitHub
parent 965e182384
commit 737f3e3cf2
3 changed files with 26 additions and 3 deletions
+5 -2
View File
@@ -17,7 +17,7 @@ def _internal_kv_get(key):
return worker.redis_client.hget(key, "value")
def _internal_kv_put(key, value):
def _internal_kv_put(key, value, overwrite=False):
"""Globally associates a value with a given binary key.
This only has an effect if the key does not already have a value.
@@ -27,5 +27,8 @@ def _internal_kv_put(key, value):
"""
worker = ray.worker.get_global_worker()
updated = worker.redis_client.hsetnx(key, "value", value)
if overwrite:
updated = worker.redis_client.hset(key, "value", value)
else:
updated = worker.redis_client.hsetnx(key, "value", value)
return updated == 0 # already exists