API cleanups. Remove worker argument. Remove some deprecated arguments. (#4025)

* Remove worker argument from API methods.

* Remove deprecated arguments and deprecate redirect_output and redirect_worker_output.

* Fix
This commit is contained in:
Robert Nishihara
2019-02-15 10:49:16 -08:00
committed by Philipp Moritz
parent 042ad84573
commit 5f71751891
24 changed files with 171 additions and 217 deletions
+6 -14
View File
@@ -6,7 +6,7 @@ import ray
import numpy as np
def get(object_ids, worker=None):
def get(object_ids):
"""Get a single or a collection of remote objects from the object store.
This method is identical to `ray.get` except it adds support for tuples,
@@ -19,11 +19,8 @@ def get(object_ids, worker=None):
Returns:
A Python object, a list of Python objects or a dict of {key: object}.
"""
# There is a dependency on ray.worker which prevents importing
# global_worker at the top of this file
worker = ray.worker.global_worker if worker is None else worker
if isinstance(object_ids, (tuple, np.ndarray)):
return ray.get(list(object_ids), worker)
return ray.get(list(object_ids))
elif isinstance(object_ids, dict):
keys_to_get = [
k for k, v in object_ids.items() if isinstance(v, ray.ObjectID)
@@ -38,10 +35,10 @@ def get(object_ids, worker=None):
result[key] = value
return result
else:
return ray.get(object_ids, worker)
return ray.get(object_ids)
def wait(object_ids, num_returns=1, timeout=None, worker=None):
def wait(object_ids, num_returns=1, timeout=None):
"""Return a list of IDs that are ready and a list of IDs that are not.
This method is identical to `ray.wait` except it adds support for tuples
@@ -59,13 +56,8 @@ def wait(object_ids, num_returns=1, timeout=None, worker=None):
A list of object IDs that are ready and a list of the remaining object
IDs.
"""
worker = ray.worker.global_worker if worker is None else worker
if isinstance(object_ids, (tuple, np.ndarray)):
return ray.wait(
list(object_ids),
num_returns=num_returns,
timeout=timeout,
worker=worker)
list(object_ids), num_returns=num_returns, timeout=timeout)
return ray.wait(
object_ids, num_returns=num_returns, timeout=timeout, worker=worker)
return ray.wait(object_ids, num_returns=num_returns, timeout=timeout)