Better checking that ray.init() has been called. (#10261)

This commit is contained in:
Robert Nishihara
2020-08-25 17:13:11 -07:00
committed by GitHub
parent d4537ac1ce
commit 79eefbf357
7 changed files with 92 additions and 60 deletions
+5 -11
View File
@@ -46,17 +46,11 @@ class GlobalState:
RuntimeError: An exception is raised if ray.init() has not been
called yet.
"""
if self.redis_client is None:
raise RuntimeError("The ray global state API cannot be used "
"before ray.init has been called.")
if self.redis_clients is None:
raise RuntimeError("The ray global state API cannot be used "
"before ray.init has been called.")
if self.global_state_accessor is None:
raise RuntimeError("The ray global state API cannot be used "
"before ray.init has been called.")
if (self.redis_client is None or self.redis_clients is None
or self.global_state_accessor is None):
raise ray.exceptions.RayConnectionError(
"Ray has not been started yet. You can start Ray with "
"'ray.init()'.")
def disconnect(self):
"""Disconnect global state from GCS."""