Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/actors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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_returns=2)
@ray.method(num_return_vals=2)
def bar(self):
return 1, 2

Expand Down
2 changes: 1 addition & 1 deletion doc/source/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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_returns=2).remote(2)
id1, id2 = f.options(num_return_vals=2).remote(2)
assert ray.get(id1) == 0
assert ray.get(id2) == 1

Expand Down
4 changes: 2 additions & 2 deletions doc/source/fault-tolerance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.WorkerCrashedError:
except ray.exceptions.RayWorkerError:
print('FAILURE')

.. _actor-fault-tolerance:
Expand Down Expand Up @@ -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 ``ObjectLostError`` will be raised.
other copies left, an ``UnreconstructableError`` 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
Expand Down
6 changes: 3 additions & 3 deletions doc/source/walkthrough.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Multiple returns

.. code-block:: python

@ray.remote(num_returns=3)
@ray.remote(num_return_vals=3)
def return_multiple():
return 1, 2, 3

Expand Down Expand Up @@ -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 GetTimeoutError
from ray.exceptions import RayTimeoutError

@ray.remote
def long_running_function()
Expand All @@ -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 GetTimeoutError:
except RayTimeoutError:
print("`get` timed out.")

.. group-tab:: Java
Expand Down
26 changes: 13 additions & 13 deletions python/ray/_raylet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ import ray.ray_constants as ray_constants
from ray import profiling
from ray.exceptions import (
RayError,
RaySystemError,
RayletError,
RayTaskError,
ObjectStoreFullError,
GetTimeoutError,
TaskCancelledError
RayTimeoutError,
RayCancellationError
)
from ray.utils import decode
import gc
Expand Down Expand Up @@ -143,11 +143,11 @@ cdef int check_status(const CRayStatus& status) nogil except -1:
elif status.IsInterrupted():
raise KeyboardInterrupt()
elif status.IsTimedOut():
raise GetTimeoutError(message)
raise RayTimeoutError(message)
elif status.IsNotFound():
raise ValueError(message)
else:
raise RaySystemError(message)
raise RayletError(message)

cdef RayObjectsToDataMetadataPairs(
const c_vector[shared_ptr[CRayObject]] objects):
Expand Down Expand Up @@ -481,15 +481,15 @@ cdef execute_task(
outputs = function_executor(*args, **kwargs)
task_exception = False
except KeyboardInterrupt as e:
raise TaskCancelledError(
raise RayCancellationError(
core_worker.get_current_task_id())
if c_return_ids.size() == 1:
outputs = (outputs,)
# Check for a cancellation that was called when the function
# was exiting and was raised after the except block.
if not check_signals().ok():
task_exception = True
raise TaskCancelledError(
raise RayCancellationError(
core_worker.get_current_task_id())
# Store the outputs in the object store.
with core_worker.profile_event(b"task:store_outputs"):
Expand Down Expand Up @@ -976,7 +976,7 @@ cdef class CoreWorker:
Language language,
FunctionDescriptor function_descriptor,
args,
int num_returns,
int num_return_vals,
resources,
int max_retries,
PlacementGroupID placement_group_id,
Expand All @@ -993,7 +993,7 @@ cdef class CoreWorker:
with self.profile_event(b"submit_task"):
prepare_resources(resources, &c_resources)
task_options = CTaskOptions(
num_returns, c_resources)
num_return_vals, c_resources)
ray_function = CRayFunction(
language.lang, function_descriptor.descriptor)
prepare_args(self, language, args, &args_vector)
Expand Down Expand Up @@ -1103,7 +1103,7 @@ cdef class CoreWorker:
ActorID actor_id,
FunctionDescriptor function_descriptor,
args,
int num_returns,
int num_return_vals,
double num_method_cpus):

cdef:
Expand All @@ -1117,7 +1117,7 @@ cdef class CoreWorker:
with self.profile_event(b"submit_task"):
if num_method_cpus > 0:
c_resources[b"CPU"] = num_method_cpus
task_options = CTaskOptions(num_returns, c_resources)
task_options = CTaskOptions(num_return_vals, c_resources)
ray_function = CRayFunction(
language.lang, function_descriptor.descriptor)
prepare_args(self, language, args, &args_vector)
Expand Down Expand Up @@ -1209,15 +1209,15 @@ cdef class CoreWorker:
return ray.actor.ActorHandle(language, actor_id,
method_meta.decorators,
method_meta.signatures,
method_meta.num_returns,
method_meta.num_return_vals,
actor_method_cpu,
actor_creation_function_descriptor,
worker.current_session_and_job)
else:
return ray.actor.ActorHandle(language, actor_id,
{}, # method decorators
{}, # method signatures
{}, # method num_returns
{}, # method num_return_vals
0, # actor method cpu
actor_creation_function_descriptor,
worker.current_session_and_job)
Expand Down
59 changes: 30 additions & 29 deletions python/ray/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def method(*args, **kwargs):

@ray.remote
class Foo:
@ray.method(num_returns=2)
@ray.method(num_return_vals=2)
def bar(self):
return 1, 2

Expand All @@ -32,16 +32,16 @@ def bar(self):
_, _ = f.bar.remote()

Args:
num_returns: The number of object refs that should be returned by
num_return_vals: The number of object refs that should be returned by
invocations of this actor method.
"""
assert len(args) == 0
assert len(kwargs) == 1
assert "num_returns" in kwargs
num_returns = kwargs["num_returns"]
assert "num_return_vals" in kwargs
num_return_vals = kwargs["num_return_vals"]

def annotate_method(method):
method.__ray_num_returns__ = num_returns
method.__ray_num_return_vals__ = num_return_vals
return method

return annotate_method
Expand All @@ -58,7 +58,7 @@ class ActorMethod:
Attributes:
_actor: A handle to the actor.
_method_name: The name of the actor method.
_num_returns: The default number of return values that the method
_num_return_vals: The default number of return values that the method
invocation should return.
_decorator: An optional decorator that should be applied to the actor
method invocation (as opposed to the actor method execution) before
Expand All @@ -72,12 +72,12 @@ class ActorMethod:
def __init__(self,
actor,
method_name,
num_returns,
num_return_vals,
decorator=None,
hardref=False):
self._actor_ref = weakref.ref(actor)
self._method_name = method_name
self._num_returns = num_returns
self._num_return_vals = num_return_vals
# This is a decorator that is used to wrap the function invocation (as
# opposed to the function execution). The decorator must return a
# function that takes in two arguments ("args" and "kwargs"). In most
Expand All @@ -100,9 +100,9 @@ def __call__(self, *args, **kwargs):
def remote(self, *args, **kwargs):
return self._remote(args, kwargs)

def _remote(self, args=None, kwargs=None, num_returns=None):
if num_returns is None:
num_returns = self._num_returns
def _remote(self, args=None, kwargs=None, num_return_vals=None):
if num_return_vals is None:
num_return_vals = self._num_return_vals

def invocation(args, kwargs):
actor = self._actor_hard_ref or self._actor_ref()
Expand All @@ -112,7 +112,7 @@ def invocation(args, kwargs):
self._method_name,
args=args,
kwargs=kwargs,
num_returns=num_returns)
num_return_vals=num_return_vals)

# Apply the decorator if there is one.
if self._decorator is not None:
Expand All @@ -124,15 +124,15 @@ def __getstate__(self):
return {
"actor": self._actor_ref(),
"method_name": self._method_name,
"num_returns": self._num_returns,
"num_return_vals": self._num_return_vals,
"decorator": self._decorator,
}

def __setstate__(self, state):
self.__init__(
state["actor"],
state["method_name"],
state["num_returns"],
state["num_return_vals"],
state["decorator"],
hardref=True)

Expand All @@ -147,7 +147,7 @@ class ActorClassMethodMetadata(object):
can be set by attaching the attribute
"__ray_invocation_decorator__" to the actor method.
signatures: The signatures of the methods.
num_returns: The default number of return values for
num_return_vals: The default number of return values for
each actor method.
"""

Expand Down Expand Up @@ -182,7 +182,7 @@ def create(cls, modified_class, actor_creation_function_descriptor):
# arguments.
self.decorators = {}
self.signatures = {}
self.num_returns = {}
self.num_return_vals = {}
for method_name, method in actor_methods:
# Whether or not this method requires binding of its first
# argument. For class and static methods, we do not want to bind
Expand All @@ -198,10 +198,11 @@ def create(cls, modified_class, actor_creation_function_descriptor):
self.signatures[method_name] = signature.extract_signature(
method, ignore_first=not is_bound)
# Set the default number of return values for this method.
if hasattr(method, "__ray_num_returns__"):
self.num_returns[method_name] = (method.__ray_num_returns__)
if hasattr(method, "__ray_num_return_vals__"):
self.num_return_vals[method_name] = (
method.__ray_num_return_vals__)
else:
self.num_returns[method_name] = (
self.num_return_vals[method_name] = (
ray_constants.DEFAULT_ACTOR_METHOD_NUM_RETURN_VALS)

if hasattr(method, "__ray_invocation_decorator__"):
Expand Down Expand Up @@ -588,7 +589,7 @@ def _remote(self,
actor_id,
meta.method_meta.decorators,
meta.method_meta.signatures,
meta.method_meta.num_returns,
meta.method_meta.num_return_vals,
actor_method_cpu,
meta.actor_creation_function_descriptor,
worker.current_session_and_job,
Expand Down Expand Up @@ -616,7 +617,7 @@ class ActorHandle:
invocation side, whereas a regular decorator can be used to change
the behavior on the execution side.
_ray_method_signatures: The signatures of the actor methods.
_ray_method_num_returns: The default number of return values for
_ray_method_num_return_vals: The default number of return values for
each method.
_ray_actor_method_cpus: The number of CPUs required by actor methods.
_ray_original_handle: True if this is the original actor handle for a
Expand All @@ -632,7 +633,7 @@ def __init__(self,
actor_id,
method_decorators,
method_signatures,
method_num_returns,
method_num_return_vals,
actor_method_cpus,
actor_creation_function_descriptor,
session_and_job,
Expand All @@ -642,7 +643,7 @@ def __init__(self,
self._ray_original_handle = original_handle
self._ray_method_decorators = method_decorators
self._ray_method_signatures = method_signatures
self._ray_method_num_returns = method_num_returns
self._ray_method_num_return_vals = method_num_return_vals
self._ray_actor_method_cpus = actor_method_cpus
self._ray_session_and_job = session_and_job
self._ray_is_cross_language = language != Language.PYTHON
Expand All @@ -663,7 +664,7 @@ def __init__(self,
method = ActorMethod(
self,
method_name,
self._ray_method_num_returns[method_name],
self._ray_method_num_return_vals[method_name],
decorator=self._ray_method_decorators.get(method_name))
setattr(self, method_name, method)

Expand All @@ -679,7 +680,7 @@ def _actor_method_call(self,
method_name,
args=None,
kwargs=None,
num_returns=None):
num_return_vals=None):
"""Method execution stub for an actor handle.

This is the function that executes when
Expand All @@ -691,7 +692,7 @@ def _actor_method_call(self,
method_name: The name of the actor method to execute.
args: A list of arguments for the actor method.
kwargs: A dictionary of keyword arguments for the actor method.
num_returns (int): The number of return values for the method.
num_return_vals (int): The number of return values for the method.

Returns:
object_refs: A list of object refs returned by the remote actor
Expand Down Expand Up @@ -724,7 +725,7 @@ def _actor_method_call(self,

object_refs = worker.core_worker.submit_actor_task(
self._ray_actor_language, self._ray_actor_id, function_descriptor,
list_args, num_returns, self._ray_actor_method_cpus)
list_args, num_return_vals, self._ray_actor_method_cpus)

if len(object_refs) == 1:
object_refs = object_refs[0]
Expand Down Expand Up @@ -794,7 +795,7 @@ def _serialization_helper(self):
"actor_id": self._ray_actor_id,
"method_decorators": self._ray_method_decorators,
"method_signatures": self._ray_method_signatures,
"method_num_returns": self._ray_method_num_returns,
"method_num_return_vals": self._ray_method_num_return_vals,
"actor_method_cpus": self._ray_actor_method_cpus,
"actor_creation_function_descriptor": self.
_ray_actor_creation_function_descriptor,
Expand Down Expand Up @@ -829,7 +830,7 @@ def _deserialization_helper(cls, state, outer_object_ref=None):
state["actor_id"],
state["method_decorators"],
state["method_signatures"],
state["method_num_returns"],
state["method_num_return_vals"],
state["actor_method_cpus"],
state["actor_creation_function_descriptor"],
worker.current_session_and_job)
Expand Down
2 changes: 1 addition & 1 deletion python/ray/cross_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def java_function(class_name, function_name):
None, # memory,
None, # object_store_memory,
None, # resources,
None, # num_returns,
None, # num_return_vals,
None, # max_calls,
None, # max_retries
placement_group=None,
Expand Down
Loading