[api] Second round of 1.0 API changes: exceptions, num_return_vals (#10377)

This commit is contained in:
Eric Liang
2020-08-28 19:57:02 -07:00
committed by GitHub
parent b1f3c9e10e
commit 2a204260a8
37 changed files with 180 additions and 204 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ Any method of the actor can return multiple object refs with the ``ray.method``
@ray.remote
class Foo(object):
@ray.method(num_return_vals=2)
@ray.method(num_returns=2)
def bar(self):
return 1, 2
+1 -1
View File
@@ -47,7 +47,7 @@ And vary the number of return values for tasks (and actor methods too):
def f(n):
return list(range(n))
id1, id2 = f.options(num_return_vals=2).remote(2)
id1, id2 = f.options(num_returns=2).remote(2)
assert ray.get(id1) == 0
assert ray.get(id2) == 1
+2 -2
View File
@@ -38,7 +38,7 @@ You can experiment with this behavior by running the following code.
# exception.
ray.get(potentially_fail.remote(0.5))
print('SUCCESS')
except ray.exceptions.RayWorkerError:
except ray.exceptions.WorkerCrashedError:
print('FAILURE')
.. _actor-fault-tolerance:
@@ -172,7 +172,7 @@ Task outputs over a configurable threshold (default 100KB) may be stored in
Ray's distributed object store. Thus, a node failure can cause the loss of a
task output. If this occurs, Ray will automatically attempt to recover the
value by looking for copies of the same object on other nodes. If there are no
other copies left, an ``UnreconstructableError`` will be raised.
other copies left, an ``ObjectLostError`` will be raised.
When there are no copies of an object left, Ray also provides an option to
automatically recover the value by re-executing the task that created the
+3 -3
View File
@@ -253,7 +253,7 @@ Multiple returns
.. code-block:: python
@ray.remote(num_return_vals=3)
@ray.remote(num_returns=3)
def return_multiple():
return 1, 2, 3
@@ -341,7 +341,7 @@ If the current node's object store does not contain the object, the object is do
assert ray.get([ray.put(i) for i in range(3)]) == [0, 1, 2]
# You can also set a timeout to return early from a ``get`` that's blocking for too long.
from ray.exceptions import RayTimeoutError
from ray.exceptions import GetTimeoutError
@ray.remote
def long_running_function()
@@ -350,7 +350,7 @@ If the current node's object store does not contain the object, the object is do
obj_ref = long_running_function.remote()
try:
ray.get(obj_ref, timeout=4)
except RayTimeoutError:
except GetTimeoutError:
print("`get` timed out.")
.. group-tab:: Java