Re-raise actor initialization errors on method invocation (#2843)

If an actor constructor fails, save that error and re-raise it on any subsequent attempts to interact with the actor. Related to https://github.com/ray-project/ray/issues/282 and https://github.com/ray-project/ray/issues/1093.
This commit is contained in:
Eric Liang
2018-09-10 10:51:19 -07:00
committed by Robert Nishihara
parent 8414e413a2
commit 611259b2c7
4 changed files with 58 additions and 13 deletions
+2 -9
View File
@@ -57,7 +57,6 @@ class Trainable(object):
object. If unspecified, a default logger is created.
"""
self._initialize_ok = False
self._experiment_id = uuid.uuid4().hex
self.config = config or {}
@@ -80,7 +79,6 @@ class Trainable(object):
self._iterations_since_restore = 0
self._restored = False
self._setup()
self._initialize_ok = True
self._local_ip = ray.services.get_node_ip_address()
@classmethod
@@ -138,10 +136,6 @@ class Trainable(object):
A dict that describes training progress.
"""
if not self._initialize_ok:
raise ValueError(
"Trainable initialization failed, see previous errors")
start = time.time()
result = self._train()
result = result.copy()
@@ -282,9 +276,8 @@ class Trainable(object):
def stop(self):
"""Releases all resources used by this trainable."""
if self._initialize_ok:
self._result_logger.close()
self._stop()
self._result_logger.close()
self._stop()
def _train(self):
"""Subclasses should override this to implement train().