partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | shutdown | Disconnect the worker, and terminate processes started by ray.init().
This will automatically run at the end when a Python process that uses Ray
exits. It is ok to run this twice in a row. The primary use case for this
function is to cleanup state between tests.
Note that this will clear any remote fu... | python/ray/worker.py | def shutdown(exiting_interpreter=False):
"""Disconnect the worker, and terminate processes started by ray.init().
This will automatically run at the end when a Python process that uses Ray
exits. It is ok to run this twice in a row. The primary use case for this
function is to cleanup state between tes... | def shutdown(exiting_interpreter=False):
"""Disconnect the worker, and terminate processes started by ray.init().
This will automatically run at the end when a Python process that uses Ray
exits. It is ok to run this twice in a row. The primary use case for this
function is to cleanup state between tes... | [
"Disconnect",
"the",
"worker",
"and",
"terminate",
"processes",
"started",
"by",
"ray",
".",
"init",
"()",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1462-L1496 | [
"def",
"shutdown",
"(",
"exiting_interpreter",
"=",
"False",
")",
":",
"if",
"exiting_interpreter",
"and",
"global_worker",
".",
"mode",
"==",
"SCRIPT_MODE",
":",
"# This is a duration to sleep before shutting down everything in order",
"# to make sure that log messages finish pr... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | print_logs | Prints log messages from workers on all of the nodes.
Args:
redis_client: A client to the primary Redis shard.
threads_stopped (threading.Event): A threading event used to signal to
the thread that it should exit. | python/ray/worker.py | def print_logs(redis_client, threads_stopped):
"""Prints log messages from workers on all of the nodes.
Args:
redis_client: A client to the primary Redis shard.
threads_stopped (threading.Event): A threading event used to signal to
the thread that it should exit.
"""
pubsub_... | def print_logs(redis_client, threads_stopped):
"""Prints log messages from workers on all of the nodes.
Args:
redis_client: A client to the primary Redis shard.
threads_stopped (threading.Event): A threading event used to signal to
the thread that it should exit.
"""
pubsub_... | [
"Prints",
"log",
"messages",
"from",
"workers",
"on",
"all",
"of",
"the",
"nodes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1526-L1575 | [
"def",
"print_logs",
"(",
"redis_client",
",",
"threads_stopped",
")",
":",
"pubsub_client",
"=",
"redis_client",
".",
"pubsub",
"(",
"ignore_subscribe_messages",
"=",
"True",
")",
"pubsub_client",
".",
"subscribe",
"(",
"ray",
".",
"gcs_utils",
".",
"LOG_FILE_CHA... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | print_error_messages_raylet | Prints message received in the given output queue.
This checks periodically if any un-raised errors occured in the background.
Args:
task_error_queue (queue.Queue): A queue used to receive errors from the
thread that listens to Redis.
threads_stopped (threading.Event): A threading ... | python/ray/worker.py | def print_error_messages_raylet(task_error_queue, threads_stopped):
"""Prints message received in the given output queue.
This checks periodically if any un-raised errors occured in the background.
Args:
task_error_queue (queue.Queue): A queue used to receive errors from the
thread tha... | def print_error_messages_raylet(task_error_queue, threads_stopped):
"""Prints message received in the given output queue.
This checks periodically if any un-raised errors occured in the background.
Args:
task_error_queue (queue.Queue): A queue used to receive errors from the
thread tha... | [
"Prints",
"message",
"received",
"in",
"the",
"given",
"output",
"queue",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1578-L1610 | [
"def",
"print_error_messages_raylet",
"(",
"task_error_queue",
",",
"threads_stopped",
")",
":",
"while",
"True",
":",
"# Exit if we received a signal that we should stop.",
"if",
"threads_stopped",
".",
"is_set",
"(",
")",
":",
"return",
"try",
":",
"error",
",",
"t"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | listen_error_messages_raylet | Listen to error messages in the background on the driver.
This runs in a separate thread on the driver and pushes (error, time)
tuples to the output queue.
Args:
worker: The worker class that this thread belongs to.
task_error_queue (queue.Queue): A queue used to communicate with the
... | python/ray/worker.py | def listen_error_messages_raylet(worker, task_error_queue, threads_stopped):
"""Listen to error messages in the background on the driver.
This runs in a separate thread on the driver and pushes (error, time)
tuples to the output queue.
Args:
worker: The worker class that this thread belongs to... | def listen_error_messages_raylet(worker, task_error_queue, threads_stopped):
"""Listen to error messages in the background on the driver.
This runs in a separate thread on the driver and pushes (error, time)
tuples to the output queue.
Args:
worker: The worker class that this thread belongs to... | [
"Listen",
"to",
"error",
"messages",
"in",
"the",
"background",
"on",
"the",
"driver",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1613-L1675 | [
"def",
"listen_error_messages_raylet",
"(",
"worker",
",",
"task_error_queue",
",",
"threads_stopped",
")",
":",
"worker",
".",
"error_message_pubsub_client",
"=",
"worker",
".",
"redis_client",
".",
"pubsub",
"(",
"ignore_subscribe_messages",
"=",
"True",
")",
"# Exp... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | connect | Connect this worker to the raylet, to Plasma, and to Redis.
Args:
node (ray.node.Node): The node to connect.
mode: The mode of the worker. One of SCRIPT_MODE, WORKER_MODE, and
LOCAL_MODE.
log_to_driver (bool): If true, then output from all of the worker
processes on ... | python/ray/worker.py | def connect(node,
mode=WORKER_MODE,
log_to_driver=False,
worker=global_worker,
driver_id=None,
load_code_from_local=False):
"""Connect this worker to the raylet, to Plasma, and to Redis.
Args:
node (ray.node.Node): The node to connect.
... | def connect(node,
mode=WORKER_MODE,
log_to_driver=False,
worker=global_worker,
driver_id=None,
load_code_from_local=False):
"""Connect this worker to the raylet, to Plasma, and to Redis.
Args:
node (ray.node.Node): The node to connect.
... | [
"Connect",
"this",
"worker",
"to",
"the",
"raylet",
"to",
"Plasma",
"and",
"to",
"Redis",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1687-L1958 | [
"def",
"connect",
"(",
"node",
",",
"mode",
"=",
"WORKER_MODE",
",",
"log_to_driver",
"=",
"False",
",",
"worker",
"=",
"global_worker",
",",
"driver_id",
"=",
"None",
",",
"load_code_from_local",
"=",
"False",
")",
":",
"# Do some basic checking to make sure we d... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | disconnect | Disconnect this worker from the raylet and object store. | python/ray/worker.py | def disconnect():
"""Disconnect this worker from the raylet and object store."""
# Reset the list of cached remote functions and actors so that if more
# remote functions or actors are defined and then connect is called again,
# the remote functions will be exported. This is mostly relevant for the
... | def disconnect():
"""Disconnect this worker from the raylet and object store."""
# Reset the list of cached remote functions and actors so that if more
# remote functions or actors are defined and then connect is called again,
# the remote functions will be exported. This is mostly relevant for the
... | [
"Disconnect",
"this",
"worker",
"from",
"the",
"raylet",
"and",
"object",
"store",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1961-L1994 | [
"def",
"disconnect",
"(",
")",
":",
"# Reset the list of cached remote functions and actors so that if more",
"# remote functions or actors are defined and then connect is called again,",
"# the remote functions will be exported. This is mostly relevant for the",
"# tests.",
"worker",
"=",
"gl... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | _try_to_compute_deterministic_class_id | Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results than simply pickling. This is a bit crazy
and could cause proble... | python/ray/worker.py | def _try_to_compute_deterministic_class_id(cls, depth=5):
"""Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results tha... | def _try_to_compute_deterministic_class_id(cls, depth=5):
"""Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results tha... | [
"Attempt",
"to",
"produce",
"a",
"deterministic",
"class",
"ID",
"for",
"a",
"given",
"class",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2006-L2045 | [
"def",
"_try_to_compute_deterministic_class_id",
"(",
"cls",
",",
"depth",
"=",
"5",
")",
":",
"# Pickling, loading, and pickling again seems to produce more consistent",
"# results than simply pickling. This is a bit",
"class_id",
"=",
"pickle",
".",
"dumps",
"(",
"cls",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | register_custom_serializer | Enable serialization and deserialization for a particular class.
This method runs the register_class function defined below on every worker,
which will enable ray to properly serialize and deserialize objects of
this class.
Args:
cls (type): The class that ray should use this custom serializer... | python/ray/worker.py | def register_custom_serializer(cls,
use_pickle=False,
use_dict=False,
serializer=None,
deserializer=None,
local=False,
driver_id=None,... | def register_custom_serializer(cls,
use_pickle=False,
use_dict=False,
serializer=None,
deserializer=None,
local=False,
driver_id=None,... | [
"Enable",
"serialization",
"and",
"deserialization",
"for",
"a",
"particular",
"class",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2048-L2148 | [
"def",
"register_custom_serializer",
"(",
"cls",
",",
"use_pickle",
"=",
"False",
",",
"use_dict",
"=",
"False",
",",
"serializer",
"=",
"None",
",",
"deserializer",
"=",
"None",
",",
"local",
"=",
"False",
",",
"driver_id",
"=",
"None",
",",
"class_id",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get | Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ID is
available in the local object store. If this object is not in the local
object store, it will be shipped from an object store that has it (once the
object has bee... | python/ray/worker.py | def get(object_ids):
"""Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ID is
available in the local object store. If this object is not in the local
object store, it will be shipped from an object store that has it ... | def get(object_ids):
"""Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ID is
available in the local object store. If this object is not in the local
object store, it will be shipped from an object store that has it ... | [
"Get",
"a",
"remote",
"object",
"or",
"a",
"list",
"of",
"remote",
"objects",
"from",
"the",
"object",
"store",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2151-L2194 | [
"def",
"get",
"(",
"object_ids",
")",
":",
"worker",
"=",
"global_worker",
"worker",
".",
"check_connected",
"(",
")",
"with",
"profiling",
".",
"profile",
"(",
"\"ray.get\"",
")",
":",
"if",
"worker",
".",
"mode",
"==",
"LOCAL_MODE",
":",
"# In LOCAL_MODE, ... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | put | Store an object in the object store.
Args:
value: The Python object to be stored.
Returns:
The object ID assigned to this value. | python/ray/worker.py | def put(value):
"""Store an object in the object store.
Args:
value: The Python object to be stored.
Returns:
The object ID assigned to this value.
"""
worker = global_worker
worker.check_connected()
with profiling.profile("ray.put"):
if worker.mode == LOCAL_MODE:
... | def put(value):
"""Store an object in the object store.
Args:
value: The Python object to be stored.
Returns:
The object ID assigned to this value.
"""
worker = global_worker
worker.check_connected()
with profiling.profile("ray.put"):
if worker.mode == LOCAL_MODE:
... | [
"Store",
"an",
"object",
"in",
"the",
"object",
"store",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2197-L2218 | [
"def",
"put",
"(",
"value",
")",
":",
"worker",
"=",
"global_worker",
"worker",
".",
"check_connected",
"(",
")",
"with",
"profiling",
".",
"profile",
"(",
"\"ray.put\"",
")",
":",
"if",
"worker",
".",
"mode",
"==",
"LOCAL_MODE",
":",
"# In LOCAL_MODE, ray.p... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | wait | Return a list of IDs that are ready and a list of IDs that are not.
.. warning::
The **timeout** argument used to be in **milliseconds** (up through
``ray==0.6.1``) and now it is in **seconds**.
If timeout is set, the function returns either when the requested number of
IDs are ready or w... | python/ray/worker.py | 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.
.. warning::
The **timeout** argument used to be in **milliseconds** (up through
``ray==0.6.1``) and now it is in **seconds**.
If timeout is set, the function returns ... | 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.
.. warning::
The **timeout** argument used to be in **milliseconds** (up through
``ray==0.6.1``) and now it is in **seconds**.
If timeout is set, the function returns ... | [
"Return",
"a",
"list",
"of",
"IDs",
"that",
"are",
"ready",
"and",
"a",
"list",
"of",
"IDs",
"that",
"are",
"not",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2221-L2315 | [
"def",
"wait",
"(",
"object_ids",
",",
"num_returns",
"=",
"1",
",",
"timeout",
"=",
"None",
")",
":",
"worker",
"=",
"global_worker",
"if",
"isinstance",
"(",
"object_ids",
",",
"ObjectID",
")",
":",
"raise",
"TypeError",
"(",
"\"wait() expected a list of ray... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | remote | Define a remote function or an actor class.
This can be used with no arguments to define a remote function or actor as
follows:
.. code-block:: python
@ray.remote
def f():
return 1
@ray.remote
class Foo(object):
def method(self):
re... | python/ray/worker.py | def remote(*args, **kwargs):
"""Define a remote function or an actor class.
This can be used with no arguments to define a remote function or actor as
follows:
.. code-block:: python
@ray.remote
def f():
return 1
@ray.remote
class Foo(object):
... | def remote(*args, **kwargs):
"""Define a remote function or an actor class.
This can be used with no arguments to define a remote function or actor as
follows:
.. code-block:: python
@ray.remote
def f():
return 1
@ray.remote
class Foo(object):
... | [
"Define",
"a",
"remote",
"function",
"or",
"an",
"actor",
"class",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2369-L2467 | [
"def",
"remote",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"worker",
"=",
"get_global_worker",
"(",
")",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"len",
"(",
"kwargs",
")",
"==",
"0",
"and",
"callable",
"(",
"args",
"[",
"0",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.task_context | A thread-local that contains the following attributes.
current_task_id: For the main thread, this field is the ID of this
worker's current running task; for other threads, this field is a
fake random ID.
task_index: The number of tasks that have been submitted from the
... | python/ray/worker.py | def task_context(self):
"""A thread-local that contains the following attributes.
current_task_id: For the main thread, this field is the ID of this
worker's current running task; for other threads, this field is a
fake random ID.
task_index: The number of tasks that hav... | def task_context(self):
"""A thread-local that contains the following attributes.
current_task_id: For the main thread, this field is the ID of this
worker's current running task; for other threads, this field is a
fake random ID.
task_index: The number of tasks that hav... | [
"A",
"thread",
"-",
"local",
"that",
"contains",
"the",
"following",
"attributes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L175-L210 | [
"def",
"task_context",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"_task_context",
",",
"\"initialized\"",
")",
":",
"# Initialize task_context for the current thread.",
"if",
"ray",
".",
"utils",
".",
"is_main_thread",
"(",
")",
":",
"# If... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.get_serialization_context | Get the SerializationContext of the driver that this worker is processing.
Args:
driver_id: The ID of the driver that indicates which driver to get
the serialization context for.
Returns:
The serialization context of the given driver. | python/ray/worker.py | def get_serialization_context(self, driver_id):
"""Get the SerializationContext of the driver that this worker is processing.
Args:
driver_id: The ID of the driver that indicates which driver to get
the serialization context for.
Returns:
The serializati... | def get_serialization_context(self, driver_id):
"""Get the SerializationContext of the driver that this worker is processing.
Args:
driver_id: The ID of the driver that indicates which driver to get
the serialization context for.
Returns:
The serializati... | [
"Get",
"the",
"SerializationContext",
"of",
"the",
"driver",
"that",
"this",
"worker",
"is",
"processing",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L227-L244 | [
"def",
"get_serialization_context",
"(",
"self",
",",
"driver_id",
")",
":",
"# This function needs to be proctected by a lock, because it will be",
"# called by`register_class_for_serialization`, as well as the import",
"# thread, from different threads. Also, this function will recursively",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.store_and_register | Store an object and attempt to register its class if needed.
Args:
object_id: The ID of the object to store.
value: The value to put in the object store.
depth: The maximum number of classes to recursively register.
Raises:
Exception: An exception is rai... | python/ray/worker.py | def store_and_register(self, object_id, value, depth=100):
"""Store an object and attempt to register its class if needed.
Args:
object_id: The ID of the object to store.
value: The value to put in the object store.
depth: The maximum number of classes to recursively... | def store_and_register(self, object_id, value, depth=100):
"""Store an object and attempt to register its class if needed.
Args:
object_id: The ID of the object to store.
value: The value to put in the object store.
depth: The maximum number of classes to recursively... | [
"Store",
"an",
"object",
"and",
"attempt",
"to",
"register",
"its",
"class",
"if",
"needed",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L276-L350 | [
"def",
"store_and_register",
"(",
"self",
",",
"object_id",
",",
"value",
",",
"depth",
"=",
"100",
")",
":",
"counter",
"=",
"0",
"while",
"True",
":",
"if",
"counter",
"==",
"depth",
":",
"raise",
"Exception",
"(",
"\"Ray exceeded the maximum number of class... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.put_object | Put value in the local object store with object id objectid.
This assumes that the value for objectid has not yet been placed in the
local object store.
Args:
object_id (object_id.ObjectID): The object ID of the value to be
put.
value: The value to put i... | python/ray/worker.py | def put_object(self, object_id, value):
"""Put value in the local object store with object id objectid.
This assumes that the value for objectid has not yet been placed in the
local object store.
Args:
object_id (object_id.ObjectID): The object ID of the value to be
... | def put_object(self, object_id, value):
"""Put value in the local object store with object id objectid.
This assumes that the value for objectid has not yet been placed in the
local object store.
Args:
object_id (object_id.ObjectID): The object ID of the value to be
... | [
"Put",
"value",
"in",
"the",
"local",
"object",
"store",
"with",
"object",
"id",
"objectid",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L352-L400 | [
"def",
"put_object",
"(",
"self",
",",
"object_id",
",",
"value",
")",
":",
"# Make sure that the value is not an object ID.",
"if",
"isinstance",
"(",
"value",
",",
"ObjectID",
")",
":",
"raise",
"TypeError",
"(",
"\"Calling 'put' on an ray.ObjectID is not allowed \"",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.get_object | Get the value or values in the object store associated with the IDs.
Return the values from the local object store for object_ids. This will
block until all the values for object_ids have been written to the
local object store.
Args:
object_ids (List[object_id.ObjectID]): A... | python/ray/worker.py | def get_object(self, object_ids):
"""Get the value or values in the object store associated with the IDs.
Return the values from the local object store for object_ids. This will
block until all the values for object_ids have been written to the
local object store.
Args:
... | def get_object(self, object_ids):
"""Get the value or values in the object store associated with the IDs.
Return the values from the local object store for object_ids. This will
block until all the values for object_ids have been written to the
local object store.
Args:
... | [
"Get",
"the",
"value",
"or",
"values",
"in",
"the",
"object",
"store",
"associated",
"with",
"the",
"IDs",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L479-L559 | [
"def",
"get_object",
"(",
"self",
",",
"object_ids",
")",
":",
"# Make sure that the values are object IDs.",
"for",
"object_id",
"in",
"object_ids",
":",
"if",
"not",
"isinstance",
"(",
"object_id",
",",
"ObjectID",
")",
":",
"raise",
"TypeError",
"(",
"\"Attempt... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.submit_task | Submit a remote task to the scheduler.
Tell the scheduler to schedule the execution of the function with
function_descriptor with arguments args. Retrieve object IDs for the
outputs of the function from the scheduler and immediately return them.
Args:
function_descriptor: T... | python/ray/worker.py | def submit_task(self,
function_descriptor,
args,
actor_id=None,
actor_handle_id=None,
actor_counter=0,
actor_creation_id=None,
actor_creation_dummy_object_id=None,
... | def submit_task(self,
function_descriptor,
args,
actor_id=None,
actor_handle_id=None,
actor_counter=0,
actor_creation_id=None,
actor_creation_dummy_object_id=None,
... | [
"Submit",
"a",
"remote",
"task",
"to",
"the",
"scheduler",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L561-L699 | [
"def",
"submit_task",
"(",
"self",
",",
"function_descriptor",
",",
"args",
",",
"actor_id",
"=",
"None",
",",
"actor_handle_id",
"=",
"None",
",",
"actor_counter",
"=",
"0",
",",
"actor_creation_id",
"=",
"None",
",",
"actor_creation_dummy_object_id",
"=",
"Non... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.run_function_on_all_workers | Run arbitrary code on all of the workers.
This function will first be run on the driver, and then it will be
exported to all of the workers to be run. It will also be run on any
new workers that register later. If ray.init has not been called yet,
then cache the function and export it l... | python/ray/worker.py | def run_function_on_all_workers(self, function,
run_on_other_drivers=False):
"""Run arbitrary code on all of the workers.
This function will first be run on the driver, and then it will be
exported to all of the workers to be run. It will also be run on any
... | def run_function_on_all_workers(self, function,
run_on_other_drivers=False):
"""Run arbitrary code on all of the workers.
This function will first be run on the driver, and then it will be
exported to all of the workers to be run. It will also be run on any
... | [
"Run",
"arbitrary",
"code",
"on",
"all",
"of",
"the",
"workers",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L701-L752 | [
"def",
"run_function_on_all_workers",
"(",
"self",
",",
"function",
",",
"run_on_other_drivers",
"=",
"False",
")",
":",
"# If ray.init has not been called yet, then cache the function and",
"# export it when connect is called. Otherwise, run the function on all",
"# workers.",
"if",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker._get_arguments_for_execution | Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is called by the worker that is executing the remote
function.
Args:
... | python/ray/worker.py | def _get_arguments_for_execution(self, function_name, serialized_args):
"""Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is c... | def _get_arguments_for_execution(self, function_name, serialized_args):
"""Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is c... | [
"Retrieve",
"the",
"arguments",
"for",
"the",
"remote",
"function",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L759-L794 | [
"def",
"_get_arguments_for_execution",
"(",
"self",
",",
"function_name",
",",
"serialized_args",
")",
":",
"arguments",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"arg",
")",
"in",
"enumerate",
"(",
"serialized_args",
")",
":",
"if",
"isinstance",
"(",
"arg",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker._store_outputs_in_object_store | Store the outputs of a remote function in the local object store.
This stores the values that were returned by a remote function in the
local object store. If any of the return values are object IDs, then
these object IDs are aliased with the object IDs that the scheduler
assigned for t... | python/ray/worker.py | def _store_outputs_in_object_store(self, object_ids, outputs):
"""Store the outputs of a remote function in the local object store.
This stores the values that were returned by a remote function in the
local object store. If any of the return values are object IDs, then
these object IDs... | def _store_outputs_in_object_store(self, object_ids, outputs):
"""Store the outputs of a remote function in the local object store.
This stores the values that were returned by a remote function in the
local object store. If any of the return values are object IDs, then
these object IDs... | [
"Store",
"the",
"outputs",
"of",
"a",
"remote",
"function",
"in",
"the",
"local",
"object",
"store",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L796-L828 | [
"def",
"_store_outputs_in_object_store",
"(",
"self",
",",
"object_ids",
",",
"outputs",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"object_ids",
")",
")",
":",
"if",
"isinstance",
"(",
"outputs",
"[",
"i",
"]",
",",
"ray",
".",
"actor",
"."... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker._process_task | Execute a task assigned to this worker.
This method deserializes a task from the scheduler, and attempts to
execute the task. If the task succeeds, the outputs are stored in the
local object store. If the task throws an exception, RayTaskError
objects are stored in the object store to r... | python/ray/worker.py | def _process_task(self, task, function_execution_info):
"""Execute a task assigned to this worker.
This method deserializes a task from the scheduler, and attempts to
execute the task. If the task succeeds, the outputs are stored in the
local object store. If the task throws an exceptio... | def _process_task(self, task, function_execution_info):
"""Execute a task assigned to this worker.
This method deserializes a task from the scheduler, and attempts to
execute the task. If the task succeeds, the outputs are stored in the
local object store. If the task throws an exceptio... | [
"Execute",
"a",
"task",
"assigned",
"to",
"this",
"worker",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L830-L921 | [
"def",
"_process_task",
"(",
"self",
",",
"task",
",",
"function_execution_info",
")",
":",
"assert",
"self",
".",
"current_task_id",
".",
"is_nil",
"(",
")",
"assert",
"self",
".",
"task_context",
".",
"task_index",
"==",
"0",
"assert",
"self",
".",
"task_c... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker._wait_for_and_process_task | Wait for a task to be ready and process the task.
Args:
task: The task to execute. | python/ray/worker.py | def _wait_for_and_process_task(self, task):
"""Wait for a task to be ready and process the task.
Args:
task: The task to execute.
"""
function_descriptor = FunctionDescriptor.from_bytes_list(
task.function_descriptor_list())
driver_id = task.driver_id()
... | def _wait_for_and_process_task(self, task):
"""Wait for a task to be ready and process the task.
Args:
task: The task to execute.
"""
function_descriptor = FunctionDescriptor.from_bytes_list(
task.function_descriptor_list())
driver_id = task.driver_id()
... | [
"Wait",
"for",
"a",
"task",
"to",
"be",
"ready",
"and",
"process",
"the",
"task",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L943-L1012 | [
"def",
"_wait_for_and_process_task",
"(",
"self",
",",
"task",
")",
":",
"function_descriptor",
"=",
"FunctionDescriptor",
".",
"from_bytes_list",
"(",
"task",
".",
"function_descriptor_list",
"(",
")",
")",
"driver_id",
"=",
"task",
".",
"driver_id",
"(",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker._get_next_task_from_raylet | Get the next task from the raylet.
Returns:
A task from the raylet. | python/ray/worker.py | def _get_next_task_from_raylet(self):
"""Get the next task from the raylet.
Returns:
A task from the raylet.
"""
with profiling.profile("worker_idle"):
task = self.raylet_client.get_task()
# Automatically restrict the GPUs available to this task.
... | def _get_next_task_from_raylet(self):
"""Get the next task from the raylet.
Returns:
A task from the raylet.
"""
with profiling.profile("worker_idle"):
task = self.raylet_client.get_task()
# Automatically restrict the GPUs available to this task.
... | [
"Get",
"the",
"next",
"task",
"from",
"the",
"raylet",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1014-L1026 | [
"def",
"_get_next_task_from_raylet",
"(",
"self",
")",
":",
"with",
"profiling",
".",
"profile",
"(",
"\"worker_idle\"",
")",
":",
"task",
"=",
"self",
".",
"raylet_client",
".",
"get_task",
"(",
")",
"# Automatically restrict the GPUs available to this task.",
"ray",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Worker.main_loop | The main loop a worker runs to receive and execute tasks. | python/ray/worker.py | def main_loop(self):
"""The main loop a worker runs to receive and execute tasks."""
def exit(signum, frame):
shutdown()
sys.exit(0)
signal.signal(signal.SIGTERM, exit)
while True:
task = self._get_next_task_from_raylet()
self._wait_for_... | def main_loop(self):
"""The main loop a worker runs to receive and execute tasks."""
def exit(signum, frame):
shutdown()
sys.exit(0)
signal.signal(signal.SIGTERM, exit)
while True:
task = self._get_next_task_from_raylet()
self._wait_for_... | [
"The",
"main",
"loop",
"a",
"worker",
"runs",
"to",
"receive",
"and",
"execute",
"tasks",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1028-L1039 | [
"def",
"main_loop",
"(",
"self",
")",
":",
"def",
"exit",
"(",
"signum",
",",
"frame",
")",
":",
"shutdown",
"(",
")",
"sys",
".",
"exit",
"(",
"0",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"exit",
")",
"while",
"True",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | flatten | This methods reshapes all values in a dictionary.
The indices from start to stop will be flattened into a single index.
Args:
weights: A dictionary mapping keys to numpy arrays.
start: The starting index.
stop: The ending index. | python/ray/rllib/agents/ppo/utils.py | def flatten(weights, start=0, stop=2):
"""This methods reshapes all values in a dictionary.
The indices from start to stop will be flattened into a single index.
Args:
weights: A dictionary mapping keys to numpy arrays.
start: The starting index.
stop: The ending index.
"""
... | def flatten(weights, start=0, stop=2):
"""This methods reshapes all values in a dictionary.
The indices from start to stop will be flattened into a single index.
Args:
weights: A dictionary mapping keys to numpy arrays.
start: The starting index.
stop: The ending index.
"""
... | [
"This",
"methods",
"reshapes",
"all",
"values",
"in",
"a",
"dictionary",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ppo/utils.py#L8-L21 | [
"def",
"flatten",
"(",
"weights",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"2",
")",
":",
"for",
"key",
",",
"val",
"in",
"weights",
".",
"items",
"(",
")",
":",
"new_shape",
"=",
"val",
".",
"shape",
"[",
"0",
":",
"start",
"]",
"+",
"(",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.address_info | Get a dictionary of addresses. | python/ray/node.py | def address_info(self):
"""Get a dictionary of addresses."""
return {
"node_ip_address": self._node_ip_address,
"redis_address": self._redis_address,
"object_store_address": self._plasma_store_socket_name,
"raylet_socket_name": self._raylet_socket_name,
... | def address_info(self):
"""Get a dictionary of addresses."""
return {
"node_ip_address": self._node_ip_address,
"redis_address": self._redis_address,
"object_store_address": self._plasma_store_socket_name,
"raylet_socket_name": self._raylet_socket_name,
... | [
"Get",
"a",
"dictionary",
"of",
"addresses",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L199-L207 | [
"def",
"address_info",
"(",
"self",
")",
":",
"return",
"{",
"\"node_ip_address\"",
":",
"self",
".",
"_node_ip_address",
",",
"\"redis_address\"",
":",
"self",
".",
"_redis_address",
",",
"\"object_store_address\"",
":",
"self",
".",
"_plasma_store_socket_name",
",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.create_redis_client | Create a redis client. | python/ray/node.py | def create_redis_client(self):
"""Create a redis client."""
return ray.services.create_redis_client(
self._redis_address, self._ray_params.redis_password) | def create_redis_client(self):
"""Create a redis client."""
return ray.services.create_redis_client(
self._redis_address, self._ray_params.redis_password) | [
"Create",
"a",
"redis",
"client",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L209-L212 | [
"def",
"create_redis_client",
"(",
"self",
")",
":",
"return",
"ray",
".",
"services",
".",
"create_redis_client",
"(",
"self",
".",
"_redis_address",
",",
"self",
".",
"_ray_params",
".",
"redis_password",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node._make_inc_temp | Return a incremental temporary file name. The file is not created.
Args:
suffix (str): The suffix of the temp file.
prefix (str): The prefix of the temp file.
directory_name (str) : The base directory of the temp file.
Returns:
A string of file name. If ... | python/ray/node.py | def _make_inc_temp(self, suffix="", prefix="", directory_name="/tmp/ray"):
"""Return a incremental temporary file name. The file is not created.
Args:
suffix (str): The suffix of the temp file.
prefix (str): The prefix of the temp file.
directory_name (str) : The bas... | def _make_inc_temp(self, suffix="", prefix="", directory_name="/tmp/ray"):
"""Return a incremental temporary file name. The file is not created.
Args:
suffix (str): The suffix of the temp file.
prefix (str): The prefix of the temp file.
directory_name (str) : The bas... | [
"Return",
"a",
"incremental",
"temporary",
"file",
"name",
".",
"The",
"file",
"is",
"not",
"created",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L226-L256 | [
"def",
"_make_inc_temp",
"(",
"self",
",",
"suffix",
"=",
"\"\"",
",",
"prefix",
"=",
"\"\"",
",",
"directory_name",
"=",
"\"/tmp/ray\"",
")",
":",
"directory_name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory_name",
")",
"index",
"=",
"self... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.new_log_files | Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and false if stdout and stderr
should not be redirected.... | python/ray/node.py | def new_log_files(self, name, redirect_output=True):
"""Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and fals... | def new_log_files(self, name, redirect_output=True):
"""Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and fals... | [
"Generate",
"partially",
"randomized",
"filenames",
"for",
"log",
"files",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L258-L287 | [
"def",
"new_log_files",
"(",
"self",
",",
"name",
",",
"redirect_output",
"=",
"True",
")",
":",
"if",
"redirect_output",
"is",
"None",
":",
"redirect_output",
"=",
"self",
".",
"_ray_params",
".",
"redirect_output",
"if",
"not",
"redirect_output",
":",
"retur... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node._prepare_socket_file | Prepare the socket file for raylet and plasma.
This method helps to prepare a socket file.
1. Make the directory if the directory does not exist.
2. If the socket file exists, raise exception.
Args:
socket_path (string): the socket file to prepare. | python/ray/node.py | def _prepare_socket_file(self, socket_path, default_prefix):
"""Prepare the socket file for raylet and plasma.
This method helps to prepare a socket file.
1. Make the directory if the directory does not exist.
2. If the socket file exists, raise exception.
Args:
soc... | def _prepare_socket_file(self, socket_path, default_prefix):
"""Prepare the socket file for raylet and plasma.
This method helps to prepare a socket file.
1. Make the directory if the directory does not exist.
2. If the socket file exists, raise exception.
Args:
soc... | [
"Prepare",
"the",
"socket",
"file",
"for",
"raylet",
"and",
"plasma",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L289-L306 | [
"def",
"_prepare_socket_file",
"(",
"self",
",",
"socket_path",
",",
"default_prefix",
")",
":",
"if",
"socket_path",
"is",
"not",
"None",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"socket_path",
")",
":",
"raise",
"Exception",
"(",
"\"Socket file {}... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_redis | Start the Redis servers. | python/ray/node.py | def start_redis(self):
"""Start the Redis servers."""
assert self._redis_address is None
redis_log_files = [self.new_log_files("redis")]
for i in range(self._ray_params.num_redis_shards):
redis_log_files.append(self.new_log_files("redis-shard_" + str(i)))
(self._redi... | def start_redis(self):
"""Start the Redis servers."""
assert self._redis_address is None
redis_log_files = [self.new_log_files("redis")]
for i in range(self._ray_params.num_redis_shards):
redis_log_files.append(self.new_log_files("redis-shard_" + str(i)))
(self._redi... | [
"Start",
"the",
"Redis",
"servers",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L308-L330 | [
"def",
"start_redis",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_redis_address",
"is",
"None",
"redis_log_files",
"=",
"[",
"self",
".",
"new_log_files",
"(",
"\"redis\"",
")",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_ray_params",
".",
"n... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_log_monitor | Start the log monitor. | python/ray/node.py | def start_log_monitor(self):
"""Start the log monitor."""
stdout_file, stderr_file = self.new_log_files("log_monitor")
process_info = ray.services.start_log_monitor(
self.redis_address,
self._logs_dir,
stdout_file=stdout_file,
stderr_file=stderr_fi... | def start_log_monitor(self):
"""Start the log monitor."""
stdout_file, stderr_file = self.new_log_files("log_monitor")
process_info = ray.services.start_log_monitor(
self.redis_address,
self._logs_dir,
stdout_file=stdout_file,
stderr_file=stderr_fi... | [
"Start",
"the",
"log",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L332-L344 | [
"def",
"start_log_monitor",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"log_monitor\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_log_monitor",
"(",
"self",
".",
"redis_address",
",",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_reporter | Start the reporter. | python/ray/node.py | def start_reporter(self):
"""Start the reporter."""
stdout_file, stderr_file = self.new_log_files("reporter", True)
process_info = ray.services.start_reporter(
self.redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
redis_password=sel... | def start_reporter(self):
"""Start the reporter."""
stdout_file, stderr_file = self.new_log_files("reporter", True)
process_info = ray.services.start_reporter(
self.redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
redis_password=sel... | [
"Start",
"the",
"reporter",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L346-L358 | [
"def",
"start_reporter",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"reporter\"",
",",
"True",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_reporter",
"(",
"self",
".",
"redis_address",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_dashboard | Start the dashboard. | python/ray/node.py | def start_dashboard(self):
"""Start the dashboard."""
stdout_file, stderr_file = self.new_log_files("dashboard", True)
self._webui_url, process_info = ray.services.start_dashboard(
self.redis_address,
self._temp_dir,
stdout_file=stdout_file,
stderr... | def start_dashboard(self):
"""Start the dashboard."""
stdout_file, stderr_file = self.new_log_files("dashboard", True)
self._webui_url, process_info = ray.services.start_dashboard(
self.redis_address,
self._temp_dir,
stdout_file=stdout_file,
stderr... | [
"Start",
"the",
"dashboard",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L360-L375 | [
"def",
"start_dashboard",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"dashboard\"",
",",
"True",
")",
"self",
".",
"_webui_url",
",",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_dashboard",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_plasma_store | Start the plasma store. | python/ray/node.py | def start_plasma_store(self):
"""Start the plasma store."""
stdout_file, stderr_file = self.new_log_files("plasma_store")
process_info = ray.services.start_plasma_store(
stdout_file=stdout_file,
stderr_file=stderr_file,
object_store_memory=self._ray_params.obj... | def start_plasma_store(self):
"""Start the plasma store."""
stdout_file, stderr_file = self.new_log_files("plasma_store")
process_info = ray.services.start_plasma_store(
stdout_file=stdout_file,
stderr_file=stderr_file,
object_store_memory=self._ray_params.obj... | [
"Start",
"the",
"plasma",
"store",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L377-L391 | [
"def",
"start_plasma_store",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"plasma_store\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_plasma_store",
"(",
"stdout_file",
"=",
"stdout_file",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_raylet | Start the raylet.
Args:
use_valgrind (bool): True if we should start the process in
valgrind.
use_profiler (bool): True if we should start the process in the
valgrind profiler. | python/ray/node.py | def start_raylet(self, use_valgrind=False, use_profiler=False):
"""Start the raylet.
Args:
use_valgrind (bool): True if we should start the process in
valgrind.
use_profiler (bool): True if we should start the process in the
valgrind profiler.
... | def start_raylet(self, use_valgrind=False, use_profiler=False):
"""Start the raylet.
Args:
use_valgrind (bool): True if we should start the process in
valgrind.
use_profiler (bool): True if we should start the process in the
valgrind profiler.
... | [
"Start",
"the",
"raylet",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L393-L426 | [
"def",
"start_raylet",
"(",
"self",
",",
"use_valgrind",
"=",
"False",
",",
"use_profiler",
"=",
"False",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"raylet\"",
")",
"process_info",
"=",
"ray",
".",
"services",
"."... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.new_worker_redirected_log_file | Create new logging files for workers to redirect its output. | python/ray/node.py | def new_worker_redirected_log_file(self, worker_id):
"""Create new logging files for workers to redirect its output."""
worker_stdout_file, worker_stderr_file = (self.new_log_files(
"worker-" + ray.utils.binary_to_hex(worker_id), True))
return worker_stdout_file, worker_stderr_file | def new_worker_redirected_log_file(self, worker_id):
"""Create new logging files for workers to redirect its output."""
worker_stdout_file, worker_stderr_file = (self.new_log_files(
"worker-" + ray.utils.binary_to_hex(worker_id), True))
return worker_stdout_file, worker_stderr_file | [
"Create",
"new",
"logging",
"files",
"for",
"workers",
"to",
"redirect",
"its",
"output",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L428-L432 | [
"def",
"new_worker_redirected_log_file",
"(",
"self",
",",
"worker_id",
")",
":",
"worker_stdout_file",
",",
"worker_stderr_file",
"=",
"(",
"self",
".",
"new_log_files",
"(",
"\"worker-\"",
"+",
"ray",
".",
"utils",
".",
"binary_to_hex",
"(",
"worker_id",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_monitor | Start the monitor. | python/ray/node.py | def start_monitor(self):
"""Start the monitor."""
stdout_file, stderr_file = self.new_log_files("monitor")
process_info = ray.services.start_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
autoscaling_config=self._ra... | def start_monitor(self):
"""Start the monitor."""
stdout_file, stderr_file = self.new_log_files("monitor")
process_info = ray.services.start_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
autoscaling_config=self._ra... | [
"Start",
"the",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L438-L448 | [
"def",
"start_monitor",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"monitor\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_monitor",
"(",
"self",
".",
"_redis_address",
",",
"stdout_fi... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_raylet_monitor | Start the raylet monitor. | python/ray/node.py | def start_raylet_monitor(self):
"""Start the raylet monitor."""
stdout_file, stderr_file = self.new_log_files("raylet_monitor")
process_info = ray.services.start_raylet_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
... | def start_raylet_monitor(self):
"""Start the raylet monitor."""
stdout_file, stderr_file = self.new_log_files("raylet_monitor")
process_info = ray.services.start_raylet_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
... | [
"Start",
"the",
"raylet",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L450-L463 | [
"def",
"start_raylet_monitor",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"raylet_monitor\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_raylet_monitor",
"(",
"self",
".",
"_redis_address"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_head_processes | Start head processes on the node. | python/ray/node.py | def start_head_processes(self):
"""Start head processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
assert self._redis_address is None
# If this is the head node, start the relevant head node pro... | def start_head_processes(self):
"""Start head processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
assert self._redis_address is None
# If this is the head node, start the relevant head node pro... | [
"Start",
"head",
"processes",
"on",
"the",
"node",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L465-L477 | [
"def",
"start_head_processes",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Process STDOUT and STDERR is being redirected to {}.\"",
".",
"format",
"(",
"self",
".",
"_logs_dir",
")",
")",
"assert",
"self",
".",
"_redis_address",
"is",
"None",
"# If this is... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.start_ray_processes | Start all of the processes on the node. | python/ray/node.py | def start_ray_processes(self):
"""Start all of the processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
self.start_plasma_store()
self.start_raylet()
if PY3:
self.start_repo... | def start_ray_processes(self):
"""Start all of the processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
self.start_plasma_store()
self.start_raylet()
if PY3:
self.start_repo... | [
"Start",
"all",
"of",
"the",
"processes",
"on",
"the",
"node",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L479-L491 | [
"def",
"start_ray_processes",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Process STDOUT and STDERR is being redirected to {}.\"",
".",
"format",
"(",
"self",
".",
"_logs_dir",
")",
")",
"self",
".",
"start_plasma_store",
"(",
")",
"self",
".",
"start_ra... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node._kill_process_type | Kill a process of a given type.
If the process type is PROCESS_TYPE_REDIS_SERVER, then we will kill all
of the Redis servers.
If the process was started in valgrind, then we will raise an exception
if the process has a non-zero exit code.
Args:
process_type: The ty... | python/ray/node.py | def _kill_process_type(self,
process_type,
allow_graceful=False,
check_alive=True,
wait=False):
"""Kill a process of a given type.
If the process type is PROCESS_TYPE_REDIS_SERVER, then we will k... | def _kill_process_type(self,
process_type,
allow_graceful=False,
check_alive=True,
wait=False):
"""Kill a process of a given type.
If the process type is PROCESS_TYPE_REDIS_SERVER, then we will k... | [
"Kill",
"a",
"process",
"of",
"a",
"given",
"type",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L493-L579 | [
"def",
"_kill_process_type",
"(",
"self",
",",
"process_type",
",",
"allow_graceful",
"=",
"False",
",",
"check_alive",
"=",
"True",
",",
"wait",
"=",
"False",
")",
":",
"process_infos",
"=",
"self",
".",
"all_processes",
"[",
"process_type",
"]",
"if",
"pro... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_redis | Kill the Redis servers.
Args:
check_alive (bool): Raise an exception if any of the processes
were already dead. | python/ray/node.py | def kill_redis(self, check_alive=True):
"""Kill the Redis servers.
Args:
check_alive (bool): Raise an exception if any of the processes
were already dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_REDIS_SERVER, check_alive=check_aliv... | def kill_redis(self, check_alive=True):
"""Kill the Redis servers.
Args:
check_alive (bool): Raise an exception if any of the processes
were already dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_REDIS_SERVER, check_alive=check_aliv... | [
"Kill",
"the",
"Redis",
"servers",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L581-L589 | [
"def",
"kill_redis",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_REDIS_SERVER",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_plasma_store | Kill the plasma store.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_plasma_store(self, check_alive=True):
"""Kill the plasma store.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_PLASMA_STORE, check_alive=check_alive) | def kill_plasma_store(self, check_alive=True):
"""Kill the plasma store.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_PLASMA_STORE, check_alive=check_alive) | [
"Kill",
"the",
"plasma",
"store",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L591-L599 | [
"def",
"kill_plasma_store",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_PLASMA_STORE",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_raylet | Kill the raylet.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_raylet(self, check_alive=True):
"""Kill the raylet.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET, check_alive=check_alive) | def kill_raylet(self, check_alive=True):
"""Kill the raylet.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET, check_alive=check_alive) | [
"Kill",
"the",
"raylet",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L601-L609 | [
"def",
"kill_raylet",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_RAYLET",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_log_monitor | Kill the log monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_log_monitor(self, check_alive=True):
"""Kill the log monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_LOG_MONITOR, check_alive=check_alive) | def kill_log_monitor(self, check_alive=True):
"""Kill the log monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_LOG_MONITOR, check_alive=check_alive) | [
"Kill",
"the",
"log",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L611-L619 | [
"def",
"kill_log_monitor",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_LOG_MONITOR",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_reporter | Kill the reporter.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_reporter(self, check_alive=True):
"""Kill the reporter.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
# reporter is started only in PY3.
if PY3:
self._kill_process_type(
ray_cons... | def kill_reporter(self, check_alive=True):
"""Kill the reporter.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
# reporter is started only in PY3.
if PY3:
self._kill_process_type(
ray_cons... | [
"Kill",
"the",
"reporter",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L621-L631 | [
"def",
"kill_reporter",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"# reporter is started only in PY3.",
"if",
"PY3",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_REPORTER",
",",
"check_alive",
"=",
"check_alive",
")"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_dashboard | Kill the dashboard.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_dashboard(self, check_alive=True):
"""Kill the dashboard.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_DASHBOARD, check_alive=check_alive) | def kill_dashboard(self, check_alive=True):
"""Kill the dashboard.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_DASHBOARD, check_alive=check_alive) | [
"Kill",
"the",
"dashboard",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L633-L641 | [
"def",
"kill_dashboard",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_DASHBOARD",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_monitor | Kill the monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_monitor(self, check_alive=True):
"""Kill the monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_MONITOR, check_alive=check_alive) | def kill_monitor(self, check_alive=True):
"""Kill the monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_MONITOR, check_alive=check_alive) | [
"Kill",
"the",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L643-L651 | [
"def",
"kill_monitor",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_MONITOR",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_raylet_monitor | Kill the raylet monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | python/ray/node.py | def kill_raylet_monitor(self, check_alive=True):
"""Kill the raylet monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET_MONITOR, check_alive=check_al... | def kill_raylet_monitor(self, check_alive=True):
"""Kill the raylet monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET_MONITOR, check_alive=check_al... | [
"Kill",
"the",
"raylet",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L653-L661 | [
"def",
"kill_raylet_monitor",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_RAYLET_MONITOR",
",",
"check_alive",
"=",
"check_alive",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.kill_all_processes | Kill all of the processes.
Note that This is slower than necessary because it calls kill, wait,
kill, wait, ... instead of kill, kill, ..., wait, wait, ...
Args:
check_alive (bool): Raise an exception if any of the processes were
already dead. | python/ray/node.py | def kill_all_processes(self, check_alive=True, allow_graceful=False):
"""Kill all of the processes.
Note that This is slower than necessary because it calls kill, wait,
kill, wait, ... instead of kill, kill, ..., wait, wait, ...
Args:
check_alive (bool): Raise an exception ... | def kill_all_processes(self, check_alive=True, allow_graceful=False):
"""Kill all of the processes.
Note that This is slower than necessary because it calls kill, wait,
kill, wait, ... instead of kill, kill, ..., wait, wait, ...
Args:
check_alive (bool): Raise an exception ... | [
"Kill",
"all",
"of",
"the",
"processes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L663-L690 | [
"def",
"kill_all_processes",
"(",
"self",
",",
"check_alive",
"=",
"True",
",",
"allow_graceful",
"=",
"False",
")",
":",
"# Kill the raylet first. This is important for suppressing errors at",
"# shutdown because we give the raylet a chance to exit gracefully and",
"# clean up its c... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Node.live_processes | Return a list of the live processes.
Returns:
A list of the live processes. | python/ray/node.py | def live_processes(self):
"""Return a list of the live processes.
Returns:
A list of the live processes.
"""
result = []
for process_type, process_infos in self.all_processes.items():
for process_info in process_infos:
if process_info.proc... | def live_processes(self):
"""Return a list of the live processes.
Returns:
A list of the live processes.
"""
result = []
for process_type, process_infos in self.all_processes.items():
for process_info in process_infos:
if process_info.proc... | [
"Return",
"a",
"list",
"of",
"the",
"live",
"processes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L692-L703 | [
"def",
"live_processes",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"process_type",
",",
"process_infos",
"in",
"self",
".",
"all_processes",
".",
"items",
"(",
")",
":",
"for",
"process_info",
"in",
"process_infos",
":",
"if",
"process_info",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | create_shared_noise | Create a large array of noise to be shared by all workers. | python/ray/rllib/agents/es/es.py | def create_shared_noise(count):
"""Create a large array of noise to be shared by all workers."""
seed = 123
noise = np.random.RandomState(seed).randn(count).astype(np.float32)
return noise | def create_shared_noise(count):
"""Create a large array of noise to be shared by all workers."""
seed = 123
noise = np.random.RandomState(seed).randn(count).astype(np.float32)
return noise | [
"Create",
"a",
"large",
"array",
"of",
"noise",
"to",
"be",
"shared",
"by",
"all",
"workers",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/es/es.py#L51-L55 | [
"def",
"create_shared_noise",
"(",
"count",
")",
":",
"seed",
"=",
"123",
"noise",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"seed",
")",
".",
"randn",
"(",
"count",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"return",
"noise"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_model_config | Map model name to model network configuration. | python/ray/experimental/sgd/tfbench/model_config.py | def get_model_config(model_name, dataset):
"""Map model name to model network configuration."""
model_map = _get_model_map(dataset.name)
if model_name not in model_map:
raise ValueError("Invalid model name \"%s\" for dataset \"%s\"" %
(model_name, dataset.name))
else:
... | def get_model_config(model_name, dataset):
"""Map model name to model network configuration."""
model_map = _get_model_map(dataset.name)
if model_name not in model_map:
raise ValueError("Invalid model name \"%s\" for dataset \"%s\"" %
(model_name, dataset.name))
else:
... | [
"Map",
"model",
"name",
"to",
"model",
"network",
"configuration",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model_config.py#L41-L48 | [
"def",
"get_model_config",
"(",
"model_name",
",",
"dataset",
")",
":",
"model_map",
"=",
"_get_model_map",
"(",
"dataset",
".",
"name",
")",
"if",
"model_name",
"not",
"in",
"model_map",
":",
"raise",
"ValueError",
"(",
"\"Invalid model name \\\"%s\\\" for dataset ... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | register_model | Register a new model that can be obtained with `get_model_config`. | python/ray/experimental/sgd/tfbench/model_config.py | def register_model(model_name, dataset_name, model_func):
"""Register a new model that can be obtained with `get_model_config`."""
model_map = _get_model_map(dataset_name)
if model_name in model_map:
raise ValueError("Model \"%s\" is already registered for dataset"
"\"%s\"" ... | def register_model(model_name, dataset_name, model_func):
"""Register a new model that can be obtained with `get_model_config`."""
model_map = _get_model_map(dataset_name)
if model_name in model_map:
raise ValueError("Model \"%s\" is already registered for dataset"
"\"%s\"" ... | [
"Register",
"a",
"new",
"model",
"that",
"can",
"be",
"obtained",
"with",
"get_model_config",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model_config.py#L51-L57 | [
"def",
"register_model",
"(",
"model_name",
",",
"dataset_name",
",",
"model_func",
")",
":",
"model_map",
"=",
"_get_model_map",
"(",
"dataset_name",
")",
"if",
"model_name",
"in",
"model_map",
":",
"raise",
"ValueError",
"(",
"\"Model \\\"%s\\\" is already registere... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | rollout | Do a rollout.
If add_noise is True, the rollout will take noisy actions with
noise drawn from that stream. Otherwise, no action noise will be added.
Parameters
----------
policy: tf object
policy from which to draw actions
env: GymEnv
environment from which to draw rewards, don... | python/ray/rllib/agents/ars/policies.py | def rollout(policy, env, timestep_limit=None, add_noise=False, offset=0):
"""Do a rollout.
If add_noise is True, the rollout will take noisy actions with
noise drawn from that stream. Otherwise, no action noise will be added.
Parameters
----------
policy: tf object
policy from which to... | def rollout(policy, env, timestep_limit=None, add_noise=False, offset=0):
"""Do a rollout.
If add_noise is True, the rollout will take noisy actions with
noise drawn from that stream. Otherwise, no action noise will be added.
Parameters
----------
policy: tf object
policy from which to... | [
"Do",
"a",
"rollout",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ars/policies.py#L19-L54 | [
"def",
"rollout",
"(",
"policy",
",",
"env",
",",
"timestep_limit",
"=",
"None",
",",
"add_noise",
"=",
"False",
",",
"offset",
"=",
"0",
")",
":",
"env_timestep_limit",
"=",
"env",
".",
"spec",
".",
"max_episode_steps",
"timestep_limit",
"=",
"(",
"env_ti... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | BasicVariantGenerator.next_trials | Provides Trial objects to be queued into the TrialRunner.
Returns:
trials (list): Returns a list of trials. | python/ray/tune/suggest/basic_variant.py | def next_trials(self):
"""Provides Trial objects to be queued into the TrialRunner.
Returns:
trials (list): Returns a list of trials.
"""
trials = list(self._trial_generator)
if self._shuffle:
random.shuffle(trials)
self._finished = True
r... | def next_trials(self):
"""Provides Trial objects to be queued into the TrialRunner.
Returns:
trials (list): Returns a list of trials.
"""
trials = list(self._trial_generator)
if self._shuffle:
random.shuffle(trials)
self._finished = True
r... | [
"Provides",
"Trial",
"objects",
"to",
"be",
"queued",
"into",
"the",
"TrialRunner",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/basic_variant.py#L51-L61 | [
"def",
"next_trials",
"(",
"self",
")",
":",
"trials",
"=",
"list",
"(",
"self",
".",
"_trial_generator",
")",
"if",
"self",
".",
"_shuffle",
":",
"random",
".",
"shuffle",
"(",
"trials",
")",
"self",
".",
"_finished",
"=",
"True",
"return",
"trials"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | BasicVariantGenerator._generate_trials | Generates Trial objects with the variant generation process.
Uses a fixed point iteration to resolve variants. All trials
should be able to be generated at once.
See also: `ray.tune.suggest.variant_generator`.
Yields:
Trial object | python/ray/tune/suggest/basic_variant.py | def _generate_trials(self, unresolved_spec, output_path=""):
"""Generates Trial objects with the variant generation process.
Uses a fixed point iteration to resolve variants. All trials
should be able to be generated at once.
See also: `ray.tune.suggest.variant_generator`.
Yie... | def _generate_trials(self, unresolved_spec, output_path=""):
"""Generates Trial objects with the variant generation process.
Uses a fixed point iteration to resolve variants. All trials
should be able to be generated at once.
See also: `ray.tune.suggest.variant_generator`.
Yie... | [
"Generates",
"Trial",
"objects",
"with",
"the",
"variant",
"generation",
"process",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/basic_variant.py#L63-L87 | [
"def",
"_generate_trials",
"(",
"self",
",",
"unresolved_spec",
",",
"output_path",
"=",
"\"\"",
")",
":",
"if",
"\"run\"",
"not",
"in",
"unresolved_spec",
":",
"raise",
"TuneError",
"(",
"\"Must specify `run` in {}\"",
".",
"format",
"(",
"unresolved_spec",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | SegmentTree.reduce | Returns result of applying `self.operation`
to a contiguous subsequence of the array.
self.operation(
arr[start], operation(arr[start+1], operation(... arr[end])))
Parameters
----------
start: int
beginning of the subsequence
end: int
... | python/ray/rllib/optimizers/segment_tree.py | def reduce(self, start=0, end=None):
"""Returns result of applying `self.operation`
to a contiguous subsequence of the array.
self.operation(
arr[start], operation(arr[start+1], operation(... arr[end])))
Parameters
----------
start: int
beginni... | def reduce(self, start=0, end=None):
"""Returns result of applying `self.operation`
to a contiguous subsequence of the array.
self.operation(
arr[start], operation(arr[start+1], operation(... arr[end])))
Parameters
----------
start: int
beginni... | [
"Returns",
"result",
"of",
"applying",
"self",
".",
"operation",
"to",
"a",
"contiguous",
"subsequence",
"of",
"the",
"array",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/segment_tree.py#L59-L83 | [
"def",
"reduce",
"(",
"self",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"self",
".",
"_capacity",
"-",
"1",
"if",
"end",
"<",
"0",
":",
"end",
"+=",
"self",
".",
"_capacity",
"return"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | set_flushing_policy | Serialize this policy for Monitor to pick up. | python/ray/experimental/gcs_flush_policy.py | def set_flushing_policy(flushing_policy):
"""Serialize this policy for Monitor to pick up."""
if "RAY_USE_NEW_GCS" not in os.environ:
raise Exception(
"set_flushing_policy() is only available when environment "
"variable RAY_USE_NEW_GCS is present at both compile and run time."
... | def set_flushing_policy(flushing_policy):
"""Serialize this policy for Monitor to pick up."""
if "RAY_USE_NEW_GCS" not in os.environ:
raise Exception(
"set_flushing_policy() is only available when environment "
"variable RAY_USE_NEW_GCS is present at both compile and run time."
... | [
"Serialize",
"this",
"policy",
"for",
"Monitor",
"to",
"pick",
"up",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/gcs_flush_policy.py#L80-L91 | [
"def",
"set_flushing_policy",
"(",
"flushing_policy",
")",
":",
"if",
"\"RAY_USE_NEW_GCS\"",
"not",
"in",
"os",
".",
"environ",
":",
"raise",
"Exception",
"(",
"\"set_flushing_policy() is only available when environment \"",
"\"variable RAY_USE_NEW_GCS is present at both compile ... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_ssh_key | Returns ssh key to connecting to cluster workers.
If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key
will be used for syncing across different nodes. | python/ray/tune/cluster_info.py | def get_ssh_key():
"""Returns ssh key to connecting to cluster workers.
If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key
will be used for syncing across different nodes.
"""
path = os.environ.get("TUNE_CLUSTER_SSH_KEY",
os.path.expanduser("~/ray_bootstrap_key... | def get_ssh_key():
"""Returns ssh key to connecting to cluster workers.
If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key
will be used for syncing across different nodes.
"""
path = os.environ.get("TUNE_CLUSTER_SSH_KEY",
os.path.expanduser("~/ray_bootstrap_key... | [
"Returns",
"ssh",
"key",
"to",
"connecting",
"to",
"cluster",
"workers",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/cluster_info.py#L15-L25 | [
"def",
"get_ssh_key",
"(",
")",
":",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"TUNE_CLUSTER_SSH_KEY\"",
",",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/ray_bootstrap_key.pem\"",
")",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"pa... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | HyperOptSearch.on_trial_complete | Passes the result to HyperOpt unless early terminated or errored.
The result is internally negated when interacting with HyperOpt
so that HyperOpt can "maximize" this value, as it minimizes on default. | python/ray/tune/suggest/hyperopt.py | def on_trial_complete(self,
trial_id,
result=None,
error=False,
early_terminated=False):
"""Passes the result to HyperOpt unless early terminated or errored.
The result is internally negated when int... | def on_trial_complete(self,
trial_id,
result=None,
error=False,
early_terminated=False):
"""Passes the result to HyperOpt unless early terminated or errored.
The result is internally negated when int... | [
"Passes",
"the",
"result",
"to",
"HyperOpt",
"unless",
"early",
"terminated",
"or",
"errored",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/hyperopt.py#L126-L151 | [
"def",
"on_trial_complete",
"(",
"self",
",",
"trial_id",
",",
"result",
"=",
"None",
",",
"error",
"=",
"False",
",",
"early_terminated",
"=",
"False",
")",
":",
"ho_trial",
"=",
"self",
".",
"_get_hyperopt_trial",
"(",
"trial_id",
")",
"if",
"ho_trial",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | plasma_prefetch | Tells plasma to prefetch the given object_id. | python/ray/experimental/streaming/batched_queue.py | def plasma_prefetch(object_id):
"""Tells plasma to prefetch the given object_id."""
local_sched_client = ray.worker.global_worker.raylet_client
ray_obj_id = ray.ObjectID(object_id)
local_sched_client.fetch_or_reconstruct([ray_obj_id], True) | def plasma_prefetch(object_id):
"""Tells plasma to prefetch the given object_id."""
local_sched_client = ray.worker.global_worker.raylet_client
ray_obj_id = ray.ObjectID(object_id)
local_sched_client.fetch_or_reconstruct([ray_obj_id], True) | [
"Tells",
"plasma",
"to",
"prefetch",
"the",
"given",
"object_id",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L17-L21 | [
"def",
"plasma_prefetch",
"(",
"object_id",
")",
":",
"local_sched_client",
"=",
"ray",
".",
"worker",
".",
"global_worker",
".",
"raylet_client",
"ray_obj_id",
"=",
"ray",
".",
"ObjectID",
"(",
"object_id",
")",
"local_sched_client",
".",
"fetch_or_reconstruct",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | plasma_get | Get an object directly from plasma without going through object table.
Precondition: plasma_prefetch(object_id) has been called before. | python/ray/experimental/streaming/batched_queue.py | def plasma_get(object_id):
"""Get an object directly from plasma without going through object table.
Precondition: plasma_prefetch(object_id) has been called before.
"""
client = ray.worker.global_worker.plasma_client
plasma_id = ray.pyarrow.plasma.ObjectID(object_id)
while not client.contains(... | def plasma_get(object_id):
"""Get an object directly from plasma without going through object table.
Precondition: plasma_prefetch(object_id) has been called before.
"""
client = ray.worker.global_worker.plasma_client
plasma_id = ray.pyarrow.plasma.ObjectID(object_id)
while not client.contains(... | [
"Get",
"an",
"object",
"directly",
"from",
"plasma",
"without",
"going",
"through",
"object",
"table",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L24-L33 | [
"def",
"plasma_get",
"(",
"object_id",
")",
":",
"client",
"=",
"ray",
".",
"worker",
".",
"global_worker",
".",
"plasma_client",
"plasma_id",
"=",
"ray",
".",
"pyarrow",
".",
"plasma",
".",
"ObjectID",
"(",
"object_id",
")",
"while",
"not",
"client",
".",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | BatchedQueue.enable_writes | Restores the state of the batched queue for writing. | python/ray/experimental/streaming/batched_queue.py | def enable_writes(self):
"""Restores the state of the batched queue for writing."""
self.write_buffer = []
self.flush_lock = threading.RLock()
self.flush_thread = FlushThread(self.max_batch_time,
self._flush_writes) | def enable_writes(self):
"""Restores the state of the batched queue for writing."""
self.write_buffer = []
self.flush_lock = threading.RLock()
self.flush_thread = FlushThread(self.max_batch_time,
self._flush_writes) | [
"Restores",
"the",
"state",
"of",
"the",
"batched",
"queue",
"for",
"writing",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L136-L141 | [
"def",
"enable_writes",
"(",
"self",
")",
":",
"self",
".",
"write_buffer",
"=",
"[",
"]",
"self",
".",
"flush_lock",
"=",
"threading",
".",
"RLock",
"(",
")",
"self",
".",
"flush_thread",
"=",
"FlushThread",
"(",
"self",
".",
"max_batch_time",
",",
"sel... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | BatchedQueue._wait_for_reader | Checks for backpressure by the downstream reader. | python/ray/experimental/streaming/batched_queue.py | def _wait_for_reader(self):
"""Checks for backpressure by the downstream reader."""
if self.max_size <= 0: # Unlimited queue
return
if self.write_item_offset - self.cached_remote_offset <= self.max_size:
return # Hasn't reached max size
remote_offset = internal_... | def _wait_for_reader(self):
"""Checks for backpressure by the downstream reader."""
if self.max_size <= 0: # Unlimited queue
return
if self.write_item_offset - self.cached_remote_offset <= self.max_size:
return # Hasn't reached max size
remote_offset = internal_... | [
"Checks",
"for",
"backpressure",
"by",
"the",
"downstream",
"reader",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L166-L187 | [
"def",
"_wait_for_reader",
"(",
"self",
")",
":",
"if",
"self",
".",
"max_size",
"<=",
"0",
":",
"# Unlimited queue",
"return",
"if",
"self",
".",
"write_item_offset",
"-",
"self",
".",
"cached_remote_offset",
"<=",
"self",
".",
"max_size",
":",
"return",
"#... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | collect_samples | Collects at least train_batch_size samples, never discarding any. | python/ray/rllib/optimizers/rollout.py | def collect_samples(agents, sample_batch_size, num_envs_per_worker,
train_batch_size):
"""Collects at least train_batch_size samples, never discarding any."""
num_timesteps_so_far = 0
trajectories = []
agent_dict = {}
for agent in agents:
fut_sample = agent.sample.remot... | def collect_samples(agents, sample_batch_size, num_envs_per_worker,
train_batch_size):
"""Collects at least train_batch_size samples, never discarding any."""
num_timesteps_so_far = 0
trajectories = []
agent_dict = {}
for agent in agents:
fut_sample = agent.sample.remot... | [
"Collects",
"at",
"least",
"train_batch_size",
"samples",
"never",
"discarding",
"any",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/rollout.py#L14-L40 | [
"def",
"collect_samples",
"(",
"agents",
",",
"sample_batch_size",
",",
"num_envs_per_worker",
",",
"train_batch_size",
")",
":",
"num_timesteps_so_far",
"=",
"0",
"trajectories",
"=",
"[",
"]",
"agent_dict",
"=",
"{",
"}",
"for",
"agent",
"in",
"agents",
":",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | collect_samples_straggler_mitigation | Collects at least train_batch_size samples.
This is the legacy behavior as of 0.6, and launches extra sample tasks to
potentially improve performance but can result in many wasted samples. | python/ray/rllib/optimizers/rollout.py | def collect_samples_straggler_mitigation(agents, train_batch_size):
"""Collects at least train_batch_size samples.
This is the legacy behavior as of 0.6, and launches extra sample tasks to
potentially improve performance but can result in many wasted samples.
"""
num_timesteps_so_far = 0
traje... | def collect_samples_straggler_mitigation(agents, train_batch_size):
"""Collects at least train_batch_size samples.
This is the legacy behavior as of 0.6, and launches extra sample tasks to
potentially improve performance but can result in many wasted samples.
"""
num_timesteps_so_far = 0
traje... | [
"Collects",
"at",
"least",
"train_batch_size",
"samples",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/rollout.py#L43-L72 | [
"def",
"collect_samples_straggler_mitigation",
"(",
"agents",
",",
"train_batch_size",
")",
":",
"num_timesteps_so_far",
"=",
"0",
"trajectories",
"=",
"[",
"]",
"agent_dict",
"=",
"{",
"}",
"for",
"agent",
"in",
"agents",
":",
"fut_sample",
"=",
"agent",
".",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | format_error_message | Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
Args:
exception_message (str): A message generated by traceba... | python/ray/utils.py | def format_error_message(exception_message, task_exception=False):
"""Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
... | def format_error_message(exception_message, task_exception=False):
"""Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
... | [
"Improve",
"the",
"formatting",
"of",
"an",
"exception",
"thrown",
"by",
"a",
"remote",
"function",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L32-L51 | [
"def",
"format_error_message",
"(",
"exception_message",
",",
"task_exception",
"=",
"False",
")",
":",
"lines",
"=",
"exception_message",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"task_exception",
":",
"# For errors that occur inside of tasks, remove lines 1 and 2 which ar... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | push_error_to_driver | Push an error message to the driver to be printed in the background.
Args:
worker: The worker to use.
error_type (str): The type of the error.
message (str): The message that will be printed in the background
on the driver.
driver_id: The ID of the driver to push the err... | python/ray/utils.py | def push_error_to_driver(worker, error_type, message, driver_id=None):
"""Push an error message to the driver to be printed in the background.
Args:
worker: The worker to use.
error_type (str): The type of the error.
message (str): The message that will be printed in the background
... | def push_error_to_driver(worker, error_type, message, driver_id=None):
"""Push an error message to the driver to be printed in the background.
Args:
worker: The worker to use.
error_type (str): The type of the error.
message (str): The message that will be printed in the background
... | [
"Push",
"an",
"error",
"message",
"to",
"the",
"driver",
"to",
"be",
"printed",
"in",
"the",
"background",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L54-L68 | [
"def",
"push_error_to_driver",
"(",
"worker",
",",
"error_type",
",",
"message",
",",
"driver_id",
"=",
"None",
")",
":",
"if",
"driver_id",
"is",
"None",
":",
"driver_id",
"=",
"ray",
".",
"DriverID",
".",
"nil",
"(",
")",
"worker",
".",
"raylet_client",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | push_error_to_driver_through_redis | Push an error message to the driver to be printed in the background.
Normally the push_error_to_driver function should be used. However, in some
instances, the raylet client is not available, e.g., because the
error happens in Python before the driver or worker has connected to the
backend processes.
... | python/ray/utils.py | def push_error_to_driver_through_redis(redis_client,
error_type,
message,
driver_id=None):
"""Push an error message to the driver to be printed in the background.
Normally the push_error_to_driv... | def push_error_to_driver_through_redis(redis_client,
error_type,
message,
driver_id=None):
"""Push an error message to the driver to be printed in the background.
Normally the push_error_to_driv... | [
"Push",
"an",
"error",
"message",
"to",
"the",
"driver",
"to",
"be",
"printed",
"in",
"the",
"background",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L71-L99 | [
"def",
"push_error_to_driver_through_redis",
"(",
"redis_client",
",",
"error_type",
",",
"message",
",",
"driver_id",
"=",
"None",
")",
":",
"if",
"driver_id",
"is",
"None",
":",
"driver_id",
"=",
"ray",
".",
"DriverID",
".",
"nil",
"(",
")",
"# Do everything... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | is_cython | Check if an object is a Cython function or method | python/ray/utils.py | def is_cython(obj):
"""Check if an object is a Cython function or method"""
# TODO(suo): We could split these into two functions, one for Cython
# functions and another for Cython methods.
# TODO(suo): There doesn't appear to be a Cython function 'type' we can
# check against via isinstance. Please... | def is_cython(obj):
"""Check if an object is a Cython function or method"""
# TODO(suo): We could split these into two functions, one for Cython
# functions and another for Cython methods.
# TODO(suo): There doesn't appear to be a Cython function 'type' we can
# check against via isinstance. Please... | [
"Check",
"if",
"an",
"object",
"is",
"a",
"Cython",
"function",
"or",
"method"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L102-L114 | [
"def",
"is_cython",
"(",
"obj",
")",
":",
"# TODO(suo): We could split these into two functions, one for Cython",
"# functions and another for Cython methods.",
"# TODO(suo): There doesn't appear to be a Cython function 'type' we can",
"# check against via isinstance. Please correct me if I'm wron... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | is_function_or_method | Check if an object is a function or method.
Args:
obj: The Python object in question.
Returns:
True if the object is an function or method. | python/ray/utils.py | def is_function_or_method(obj):
"""Check if an object is a function or method.
Args:
obj: The Python object in question.
Returns:
True if the object is an function or method.
"""
return inspect.isfunction(obj) or inspect.ismethod(obj) or is_cython(obj) | def is_function_or_method(obj):
"""Check if an object is a function or method.
Args:
obj: The Python object in question.
Returns:
True if the object is an function or method.
"""
return inspect.isfunction(obj) or inspect.ismethod(obj) or is_cython(obj) | [
"Check",
"if",
"an",
"object",
"is",
"a",
"function",
"or",
"method",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L117-L126 | [
"def",
"is_function_or_method",
"(",
"obj",
")",
":",
"return",
"inspect",
".",
"isfunction",
"(",
"obj",
")",
"or",
"inspect",
".",
"ismethod",
"(",
"obj",
")",
"or",
"is_cython",
"(",
"obj",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | random_string | Generate a random string to use as an ID.
Note that users may seed numpy, which could cause this function to generate
duplicate IDs. Therefore, we need to seed numpy ourselves, but we can't
interfere with the state of the user's random number generator, so we
extract the state of the random number gene... | python/ray/utils.py | def random_string():
"""Generate a random string to use as an ID.
Note that users may seed numpy, which could cause this function to generate
duplicate IDs. Therefore, we need to seed numpy ourselves, but we can't
interfere with the state of the user's random number generator, so we
extract the sta... | def random_string():
"""Generate a random string to use as an ID.
Note that users may seed numpy, which could cause this function to generate
duplicate IDs. Therefore, we need to seed numpy ourselves, but we can't
interfere with the state of the user's random number generator, so we
extract the sta... | [
"Generate",
"a",
"random",
"string",
"to",
"use",
"as",
"an",
"ID",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L134-L157 | [
"def",
"random_string",
"(",
")",
":",
"# Get the state of the numpy random number generator.",
"numpy_state",
"=",
"np",
".",
"random",
".",
"get_state",
"(",
")",
"# Try to use true randomness.",
"np",
".",
"random",
".",
"seed",
"(",
"None",
")",
"# Generate the ra... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | decode | Make this unicode in Python 3, otherwise leave it as bytes.
Args:
byte_str: The byte string to decode.
allow_none: If true, then we will allow byte_str to be None in which
case we will return an empty string. TODO(rkn): Remove this flag.
This is only here to simplify upgradi... | python/ray/utils.py | def decode(byte_str, allow_none=False):
"""Make this unicode in Python 3, otherwise leave it as bytes.
Args:
byte_str: The byte string to decode.
allow_none: If true, then we will allow byte_str to be None in which
case we will return an empty string. TODO(rkn): Remove this flag.
... | def decode(byte_str, allow_none=False):
"""Make this unicode in Python 3, otherwise leave it as bytes.
Args:
byte_str: The byte string to decode.
allow_none: If true, then we will allow byte_str to be None in which
case we will return an empty string. TODO(rkn): Remove this flag.
... | [
"Make",
"this",
"unicode",
"in",
"Python",
"3",
"otherwise",
"leave",
"it",
"as",
"bytes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L160-L181 | [
"def",
"decode",
"(",
"byte_str",
",",
"allow_none",
"=",
"False",
")",
":",
"if",
"byte_str",
"is",
"None",
"and",
"allow_none",
":",
"return",
"\"\"",
"if",
"not",
"isinstance",
"(",
"byte_str",
",",
"bytes",
")",
":",
"raise",
"ValueError",
"(",
"\"Th... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ensure_str | Coerce *s* to `str`.
To keep six with lower version, see Issue 4169, we copy this function
from six == 1.12.0.
TODO(yuhguo): remove this function when six >= 1.12.0.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` ->... | python/ray/utils.py | def ensure_str(s, encoding="utf-8", errors="strict"):
"""Coerce *s* to `str`.
To keep six with lower version, see Issue 4169, we copy this function
from six == 1.12.0.
TODO(yuhguo): remove this function when six >= 1.12.0.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`... | def ensure_str(s, encoding="utf-8", errors="strict"):
"""Coerce *s* to `str`.
To keep six with lower version, see Issue 4169, we copy this function
from six == 1.12.0.
TODO(yuhguo): remove this function when six >= 1.12.0.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`... | [
"Coerce",
"*",
"s",
"*",
"to",
"str",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L184-L212 | [
"def",
"ensure_str",
"(",
"s",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"errors",
"=",
"\"strict\"",
")",
":",
"if",
"six",
".",
"PY3",
":",
"text_type",
"=",
"str",
"binary_type",
"=",
"bytes",
"else",
":",
"text_type",
"=",
"unicode",
"# noqa: F821",
"b... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_cuda_visible_devices | Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable.
Returns:
if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with
the IDs of the GPUs. If it is not set, this returns None. | python/ray/utils.py | def get_cuda_visible_devices():
"""Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable.
Returns:
if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with
the IDs of the GPUs. If it is not set, this returns None.
"""
gpu_ids_str = os.environ.get("CUDA_VISI... | def get_cuda_visible_devices():
"""Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable.
Returns:
if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with
the IDs of the GPUs. If it is not set, this returns None.
"""
gpu_ids_str = os.environ.get("CUDA_VISI... | [
"Get",
"the",
"device",
"IDs",
"in",
"the",
"CUDA_VISIBLE_DEVICES",
"environment",
"variable",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L230-L245 | [
"def",
"get_cuda_visible_devices",
"(",
")",
":",
"gpu_ids_str",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"CUDA_VISIBLE_DEVICES\"",
",",
"None",
")",
"if",
"gpu_ids_str",
"is",
"None",
":",
"return",
"None",
"if",
"gpu_ids_str",
"==",
"\"\"",
":",
"retu... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | resources_from_resource_arguments | Determine a task's resource requirements.
Args:
default_num_cpus: The default number of CPUs required by this function
or actor method.
default_num_gpus: The default number of GPUs required by this function
or actor method.
default_resources: The default custom resou... | python/ray/utils.py | def resources_from_resource_arguments(default_num_cpus, default_num_gpus,
default_resources, runtime_num_cpus,
runtime_num_gpus, runtime_resources):
"""Determine a task's resource requirements.
Args:
default_num_cpus: The defau... | def resources_from_resource_arguments(default_num_cpus, default_num_gpus,
default_resources, runtime_num_cpus,
runtime_num_gpus, runtime_resources):
"""Determine a task's resource requirements.
Args:
default_num_cpus: The defau... | [
"Determine",
"a",
"task",
"s",
"resource",
"requirements",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L257-L299 | [
"def",
"resources_from_resource_arguments",
"(",
"default_num_cpus",
",",
"default_num_gpus",
",",
"default_resources",
",",
"runtime_num_cpus",
",",
"runtime_num_gpus",
",",
"runtime_resources",
")",
":",
"if",
"runtime_resources",
"is",
"not",
"None",
":",
"resources",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | setup_logger | Setup default logging for ray. | python/ray/utils.py | def setup_logger(logging_level, logging_format):
"""Setup default logging for ray."""
logger = logging.getLogger("ray")
if type(logging_level) is str:
logging_level = logging.getLevelName(logging_level.upper())
logger.setLevel(logging_level)
global _default_handler
if _default_handler is... | def setup_logger(logging_level, logging_format):
"""Setup default logging for ray."""
logger = logging.getLogger("ray")
if type(logging_level) is str:
logging_level = logging.getLevelName(logging_level.upper())
logger.setLevel(logging_level)
global _default_handler
if _default_handler is... | [
"Setup",
"default",
"logging",
"for",
"ray",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L305-L316 | [
"def",
"setup_logger",
"(",
"logging_level",
",",
"logging_format",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"ray\"",
")",
"if",
"type",
"(",
"logging_level",
")",
"is",
"str",
":",
"logging_level",
"=",
"logging",
".",
"getLevelName",
"(... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | vmstat | Run vmstat and get a particular statistic.
Args:
stat: The statistic that we are interested in retrieving.
Returns:
The parsed output. | python/ray/utils.py | def vmstat(stat):
"""Run vmstat and get a particular statistic.
Args:
stat: The statistic that we are interested in retrieving.
Returns:
The parsed output.
"""
out = subprocess.check_output(["vmstat", "-s"])
stat = stat.encode("ascii")
for line in out.split(b"\n"):
... | def vmstat(stat):
"""Run vmstat and get a particular statistic.
Args:
stat: The statistic that we are interested in retrieving.
Returns:
The parsed output.
"""
out = subprocess.check_output(["vmstat", "-s"])
stat = stat.encode("ascii")
for line in out.split(b"\n"):
... | [
"Run",
"vmstat",
"and",
"get",
"a",
"particular",
"statistic",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L321-L336 | [
"def",
"vmstat",
"(",
"stat",
")",
":",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"vmstat\"",
",",
"\"-s\"",
"]",
")",
"stat",
"=",
"stat",
".",
"encode",
"(",
"\"ascii\"",
")",
"for",
"line",
"in",
"out",
".",
"split",
"(",
"b\"\\n\... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | sysctl | Run a sysctl command and parse the output.
Args:
command: A sysctl command with an argument, for example,
["sysctl", "hw.memsize"].
Returns:
The parsed output. | python/ray/utils.py | def sysctl(command):
"""Run a sysctl command and parse the output.
Args:
command: A sysctl command with an argument, for example,
["sysctl", "hw.memsize"].
Returns:
The parsed output.
"""
out = subprocess.check_output(command)
result = out.split(b" ")[1]
try:
... | def sysctl(command):
"""Run a sysctl command and parse the output.
Args:
command: A sysctl command with an argument, for example,
["sysctl", "hw.memsize"].
Returns:
The parsed output.
"""
out = subprocess.check_output(command)
result = out.split(b" ")[1]
try:
... | [
"Run",
"a",
"sysctl",
"command",
"and",
"parse",
"the",
"output",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L341-L356 | [
"def",
"sysctl",
"(",
"command",
")",
":",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"command",
")",
"result",
"=",
"out",
".",
"split",
"(",
"b\" \"",
")",
"[",
"1",
"]",
"try",
":",
"return",
"int",
"(",
"result",
")",
"except",
"ValueErr... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_system_memory | Return the total amount of system memory in bytes.
Returns:
The total amount of system memory in bytes. | python/ray/utils.py | def get_system_memory():
"""Return the total amount of system memory in bytes.
Returns:
The total amount of system memory in bytes.
"""
# Try to accurately figure out the memory limit if we are in a docker
# container. Note that this file is not specific to Docker and its value is
# oft... | def get_system_memory():
"""Return the total amount of system memory in bytes.
Returns:
The total amount of system memory in bytes.
"""
# Try to accurately figure out the memory limit if we are in a docker
# container. Note that this file is not specific to Docker and its value is
# oft... | [
"Return",
"the",
"total",
"amount",
"of",
"system",
"memory",
"in",
"bytes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L359-L395 | [
"def",
"get_system_memory",
"(",
")",
":",
"# Try to accurately figure out the memory limit if we are in a docker",
"# container. Note that this file is not specific to Docker and its value is",
"# often much larger than the actual amount of memory.",
"docker_limit",
"=",
"None",
"memory_limit... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_shared_memory_bytes | Get the size of the shared memory file system.
Returns:
The size of the shared memory file system in bytes. | python/ray/utils.py | def get_shared_memory_bytes():
"""Get the size of the shared memory file system.
Returns:
The size of the shared memory file system in bytes.
"""
# Make sure this is only called on Linux.
assert sys.platform == "linux" or sys.platform == "linux2"
shm_fd = os.open("/dev/shm", os.O_RDONL... | def get_shared_memory_bytes():
"""Get the size of the shared memory file system.
Returns:
The size of the shared memory file system in bytes.
"""
# Make sure this is only called on Linux.
assert sys.platform == "linux" or sys.platform == "linux2"
shm_fd = os.open("/dev/shm", os.O_RDONL... | [
"Get",
"the",
"size",
"of",
"the",
"shared",
"memory",
"file",
"system",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L398-L417 | [
"def",
"get_shared_memory_bytes",
"(",
")",
":",
"# Make sure this is only called on Linux.",
"assert",
"sys",
".",
"platform",
"==",
"\"linux\"",
"or",
"sys",
".",
"platform",
"==",
"\"linux2\"",
"shm_fd",
"=",
"os",
".",
"open",
"(",
"\"/dev/shm\"",
",",
"os",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | check_oversized_pickle | Send a warning message if the pickled object is too large.
Args:
pickled: the pickled object.
name: name of the pickled object.
obj_type: type of the pickled object, can be 'function',
'remote function', 'actor', or 'object'.
worker: the worker used to send warning messa... | python/ray/utils.py | def check_oversized_pickle(pickled, name, obj_type, worker):
"""Send a warning message if the pickled object is too large.
Args:
pickled: the pickled object.
name: name of the pickled object.
obj_type: type of the pickled object, can be 'function',
'remote function', 'actor'... | def check_oversized_pickle(pickled, name, obj_type, worker):
"""Send a warning message if the pickled object is too large.
Args:
pickled: the pickled object.
name: name of the pickled object.
obj_type: type of the pickled object, can be 'function',
'remote function', 'actor'... | [
"Send",
"a",
"warning",
"message",
"if",
"the",
"pickled",
"object",
"is",
"too",
"large",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L420-L442 | [
"def",
"check_oversized_pickle",
"(",
"pickled",
",",
"name",
",",
"obj_type",
",",
"worker",
")",
":",
"length",
"=",
"len",
"(",
"pickled",
")",
"if",
"length",
"<=",
"ray_constants",
".",
"PICKLE_OBJECT_WARNING_SIZE",
":",
"return",
"warning_message",
"=",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | thread_safe_client | Create a thread-safe proxy which locks every method call
for the given client.
Args:
client: the client object to be guarded.
lock: the lock object that will be used to lock client's methods.
If None, a new lock will be used.
Returns:
A thread-safe proxy for the given c... | python/ray/utils.py | def thread_safe_client(client, lock=None):
"""Create a thread-safe proxy which locks every method call
for the given client.
Args:
client: the client object to be guarded.
lock: the lock object that will be used to lock client's methods.
If None, a new lock will be used.
Re... | def thread_safe_client(client, lock=None):
"""Create a thread-safe proxy which locks every method call
for the given client.
Args:
client: the client object to be guarded.
lock: the lock object that will be used to lock client's methods.
If None, a new lock will be used.
Re... | [
"Create",
"a",
"thread",
"-",
"safe",
"proxy",
"which",
"locks",
"every",
"method",
"call",
"for",
"the",
"given",
"client",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L482-L496 | [
"def",
"thread_safe_client",
"(",
"client",
",",
"lock",
"=",
"None",
")",
":",
"if",
"lock",
"is",
"None",
":",
"lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"return",
"_ThreadSafeProxy",
"(",
"client",
",",
"lock",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | try_to_create_directory | Attempt to create a directory that is globally readable/writable.
Args:
directory_path: The path of the directory to create. | python/ray/utils.py | def try_to_create_directory(directory_path):
"""Attempt to create a directory that is globally readable/writable.
Args:
directory_path: The path of the directory to create.
"""
logger = logging.getLogger("ray")
directory_path = os.path.expanduser(directory_path)
if not os.path.exists(di... | def try_to_create_directory(directory_path):
"""Attempt to create a directory that is globally readable/writable.
Args:
directory_path: The path of the directory to create.
"""
logger = logging.getLogger("ray")
directory_path = os.path.expanduser(directory_path)
if not os.path.exists(di... | [
"Attempt",
"to",
"create",
"a",
"directory",
"that",
"is",
"globally",
"readable",
"/",
"writable",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L503-L533 | [
"def",
"try_to_create_directory",
"(",
"directory_path",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"ray\"",
")",
"directory_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory_path",
")",
"if",
"not",
"os",
".",
"path",
".",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | subblocks | This function produces a distributed array from a subset of the blocks in
the `a`. The result and `a` will have the same number of dimensions. For
example,
subblocks(a, [0, 1], [2, 4])
will produce a DistArray whose objectids are
[[a.objectids[0, 2], a.objectids[0, 4]],
[a.objectids... | python/ray/experimental/array/distributed/core.py | def subblocks(a, *ranges):
"""
This function produces a distributed array from a subset of the blocks in
the `a`. The result and `a` will have the same number of dimensions. For
example,
subblocks(a, [0, 1], [2, 4])
will produce a DistArray whose objectids are
[[a.objectids[0, 2], a.... | def subblocks(a, *ranges):
"""
This function produces a distributed array from a subset of the blocks in
the `a`. The result and `a` will have the same number of dimensions. For
example,
subblocks(a, [0, 1], [2, 4])
will produce a DistArray whose objectids are
[[a.objectids[0, 2], a.... | [
"This",
"function",
"produces",
"a",
"distributed",
"array",
"from",
"a",
"subset",
"of",
"the",
"blocks",
"in",
"the",
"a",
".",
"The",
"result",
"and",
"a",
"will",
"have",
"the",
"same",
"number",
"of",
"dimensions",
".",
"For",
"example",
"subblocks",
... | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/core.py#L204-L245 | [
"def",
"subblocks",
"(",
"a",
",",
"*",
"ranges",
")",
":",
"ranges",
"=",
"list",
"(",
"ranges",
")",
"if",
"len",
"(",
"ranges",
")",
"!=",
"a",
".",
"ndim",
":",
"raise",
"Exception",
"(",
"\"sub_blocks expects to receive a number of ranges \"",
"\"equal ... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DistArray.assemble | Assemble an array from a distributed array of object IDs. | python/ray/experimental/array/distributed/core.py | def assemble(self):
"""Assemble an array from a distributed array of object IDs."""
first_block = ray.get(self.objectids[(0, ) * self.ndim])
dtype = first_block.dtype
result = np.zeros(self.shape, dtype=dtype)
for index in np.ndindex(*self.num_blocks):
lower = DistArr... | def assemble(self):
"""Assemble an array from a distributed array of object IDs."""
first_block = ray.get(self.objectids[(0, ) * self.ndim])
dtype = first_block.dtype
result = np.zeros(self.shape, dtype=dtype)
for index in np.ndindex(*self.num_blocks):
lower = DistArr... | [
"Assemble",
"an",
"array",
"from",
"a",
"distributed",
"array",
"of",
"object",
"IDs",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/core.py#L58-L68 | [
"def",
"assemble",
"(",
"self",
")",
":",
"first_block",
"=",
"ray",
".",
"get",
"(",
"self",
".",
"objectids",
"[",
"(",
"0",
",",
")",
"*",
"self",
".",
"ndim",
"]",
")",
"dtype",
"=",
"first_block",
".",
"dtype",
"result",
"=",
"np",
".",
"zer... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | multi_log_probs_from_logits_and_actions | Computes action log-probs from policy logits and actions.
In the notation used throughout documentation and comments, T refers to the
time dimension ranging from 0 to T-1. B refers to the batch size and
ACTION_SPACE refers to the list of numbers each representing a number of
actions.
Args:
policy_logits... | python/ray/rllib/agents/impala/vtrace.py | def multi_log_probs_from_logits_and_actions(policy_logits, actions):
"""Computes action log-probs from policy logits and actions.
In the notation used throughout documentation and comments, T refers to the
time dimension ranging from 0 to T-1. B refers to the batch size and
ACTION_SPACE refers to the list of... | def multi_log_probs_from_logits_and_actions(policy_logits, actions):
"""Computes action log-probs from policy logits and actions.
In the notation used throughout documentation and comments, T refers to the
time dimension ranging from 0 to T-1. B refers to the batch size and
ACTION_SPACE refers to the list of... | [
"Computes",
"action",
"log",
"-",
"probs",
"from",
"policy",
"logits",
"and",
"actions",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L54-L91 | [
"def",
"multi_log_probs_from_logits_and_actions",
"(",
"policy_logits",
",",
"actions",
")",
":",
"log_probs",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"policy_logits",
")",
")",
":",
"log_probs",
".",
"append",
"(",
"-",
"tf",
".",
"nn",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | from_logits | multi_from_logits wrapper used only for tests | python/ray/rllib/agents/impala/vtrace.py | def from_logits(behaviour_policy_logits,
target_policy_logits,
actions,
discounts,
rewards,
values,
bootstrap_value,
clip_rho_threshold=1.0,
clip_pg_rho_threshold=1.0,
name="vt... | def from_logits(behaviour_policy_logits,
target_policy_logits,
actions,
discounts,
rewards,
values,
bootstrap_value,
clip_rho_threshold=1.0,
clip_pg_rho_threshold=1.0,
name="vt... | [
"multi_from_logits",
"wrapper",
"used",
"only",
"for",
"tests"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L94-L124 | [
"def",
"from_logits",
"(",
"behaviour_policy_logits",
",",
"target_policy_logits",
",",
"actions",
",",
"discounts",
",",
"rewards",
",",
"values",
",",
"bootstrap_value",
",",
"clip_rho_threshold",
"=",
"1.0",
",",
"clip_pg_rho_threshold",
"=",
"1.0",
",",
"name",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | multi_from_logits | r"""V-trace for softmax policies.
Calculates V-trace actor critic targets for softmax polices as described in
"IMPALA: Scalable Distributed Deep-RL with
Importance Weighted Actor-Learner Architectures"
by Espeholt, Soyer, Munos et al.
Target policy refers to the policy we are interested in improving and
... | python/ray/rllib/agents/impala/vtrace.py | def multi_from_logits(behaviour_policy_logits,
target_policy_logits,
actions,
discounts,
rewards,
values,
bootstrap_value,
clip_rho_threshold=1.0,
... | def multi_from_logits(behaviour_policy_logits,
target_policy_logits,
actions,
discounts,
rewards,
values,
bootstrap_value,
clip_rho_threshold=1.0,
... | [
"r",
"V",
"-",
"trace",
"for",
"softmax",
"policies",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L127-L244 | [
"def",
"multi_from_logits",
"(",
"behaviour_policy_logits",
",",
"target_policy_logits",
",",
"actions",
",",
"discounts",
",",
"rewards",
",",
"values",
",",
"bootstrap_value",
",",
"clip_rho_threshold",
"=",
"1.0",
",",
"clip_pg_rho_threshold",
"=",
"1.0",
",",
"n... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | from_importance_weights | r"""V-trace from log importance weights.
Calculates V-trace actor critic targets as described in
"IMPALA: Scalable Distributed Deep-RL with
Importance Weighted Actor-Learner Architectures"
by Espeholt, Soyer, Munos et al.
In the notation used throughout documentation and comments, T refers to the
time di... | python/ray/rllib/agents/impala/vtrace.py | def from_importance_weights(log_rhos,
discounts,
rewards,
values,
bootstrap_value,
clip_rho_threshold=1.0,
clip_pg_rho_threshold=1.0,
... | def from_importance_weights(log_rhos,
discounts,
rewards,
values,
bootstrap_value,
clip_rho_threshold=1.0,
clip_pg_rho_threshold=1.0,
... | [
"r",
"V",
"-",
"trace",
"from",
"log",
"importance",
"weights",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L247-L386 | [
"def",
"from_importance_weights",
"(",
"log_rhos",
",",
"discounts",
",",
"rewards",
",",
"values",
",",
"bootstrap_value",
",",
"clip_rho_threshold",
"=",
"1.0",
",",
"clip_pg_rho_threshold",
"=",
"1.0",
",",
"name",
"=",
"\"vtrace_from_importance_weights\"",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_log_rhos | With the selected log_probs for multi-discrete actions of behaviour
and target policies we compute the log_rhos for calculating the vtrace. | python/ray/rllib/agents/impala/vtrace.py | def get_log_rhos(target_action_log_probs, behaviour_action_log_probs):
"""With the selected log_probs for multi-discrete actions of behaviour
and target policies we compute the log_rhos for calculating the vtrace."""
t = tf.stack(target_action_log_probs)
b = tf.stack(behaviour_action_log_probs)
log_... | def get_log_rhos(target_action_log_probs, behaviour_action_log_probs):
"""With the selected log_probs for multi-discrete actions of behaviour
and target policies we compute the log_rhos for calculating the vtrace."""
t = tf.stack(target_action_log_probs)
b = tf.stack(behaviour_action_log_probs)
log_... | [
"With",
"the",
"selected",
"log_probs",
"for",
"multi",
"-",
"discrete",
"actions",
"of",
"behaviour",
"and",
"target",
"policies",
"we",
"compute",
"the",
"log_rhos",
"for",
"calculating",
"the",
"vtrace",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L389-L395 | [
"def",
"get_log_rhos",
"(",
"target_action_log_probs",
",",
"behaviour_action_log_probs",
")",
":",
"t",
"=",
"tf",
".",
"stack",
"(",
"target_action_log_probs",
")",
"b",
"=",
"tf",
".",
"stack",
"(",
"behaviour_action_log_probs",
")",
"log_rhos",
"=",
"tf",
".... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | weight_variable | weight_variable generates a weight variable of a given shape. | python/ray/tune/examples/tune_mnist_async_hyperband.py | def weight_variable(shape):
"""weight_variable generates a weight variable of a given shape."""
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial) | def weight_variable(shape):
"""weight_variable generates a weight variable of a given shape."""
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial) | [
"weight_variable",
"generates",
"a",
"weight",
"variable",
"of",
"a",
"given",
"shape",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/tune_mnist_async_hyperband.py#L121-L124 | [
"def",
"weight_variable",
"(",
"shape",
")",
":",
"initial",
"=",
"tf",
".",
"truncated_normal",
"(",
"shape",
",",
"stddev",
"=",
"0.1",
")",
"return",
"tf",
".",
"Variable",
"(",
"initial",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | bias_variable | bias_variable generates a bias variable of a given shape. | python/ray/tune/examples/tune_mnist_async_hyperband.py | def bias_variable(shape):
"""bias_variable generates a bias variable of a given shape."""
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial) | def bias_variable(shape):
"""bias_variable generates a bias variable of a given shape."""
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial) | [
"bias_variable",
"generates",
"a",
"bias",
"variable",
"of",
"a",
"given",
"shape",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/tune_mnist_async_hyperband.py#L127-L130 | [
"def",
"bias_variable",
"(",
"shape",
")",
":",
"initial",
"=",
"tf",
".",
"constant",
"(",
"0.1",
",",
"shape",
"=",
"shape",
")",
"return",
"tf",
".",
"Variable",
"(",
"initial",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | print_format_output | Prints output of given dataframe to fit into terminal.
Returns:
table (pd.DataFrame): Final outputted dataframe.
dropped_cols (list): Columns dropped due to terminal size.
empty_cols (list): Empty columns (dropped on default). | python/ray/tune/commands.py | def print_format_output(dataframe):
"""Prints output of given dataframe to fit into terminal.
Returns:
table (pd.DataFrame): Final outputted dataframe.
dropped_cols (list): Columns dropped due to terminal size.
empty_cols (list): Empty columns (dropped on default).
"""
print_df ... | def print_format_output(dataframe):
"""Prints output of given dataframe to fit into terminal.
Returns:
table (pd.DataFrame): Final outputted dataframe.
dropped_cols (list): Columns dropped due to terminal size.
empty_cols (list): Empty columns (dropped on default).
"""
print_df ... | [
"Prints",
"output",
"of",
"given",
"dataframe",
"to",
"fit",
"into",
"terminal",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L72-L108 | [
"def",
"print_format_output",
"(",
"dataframe",
")",
":",
"print_df",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"dropped_cols",
"=",
"[",
"]",
"empty_cols",
"=",
"[",
"]",
"# column display priority is based on the info_keys passed in",
"for",
"i",
",",
"col",
"in",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | list_trials | Lists trials in the directory subtree starting at the given path.
Args:
experiment_path (str): Directory where trials are located.
Corresponds to Experiment.local_dir/Experiment.name.
sort (str): Key to sort by.
output (str): Name of file where output is saved.
filter_op... | python/ray/tune/commands.py | def list_trials(experiment_path,
sort=None,
output=None,
filter_op=None,
info_keys=None,
result_keys=None):
"""Lists trials in the directory subtree starting at the given path.
Args:
experiment_path (str): Directory where t... | def list_trials(experiment_path,
sort=None,
output=None,
filter_op=None,
info_keys=None,
result_keys=None):
"""Lists trials in the directory subtree starting at the given path.
Args:
experiment_path (str): Directory where t... | [
"Lists",
"trials",
"in",
"the",
"directory",
"subtree",
"starting",
"at",
"the",
"given",
"path",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L128-L208 | [
"def",
"list_trials",
"(",
"experiment_path",
",",
"sort",
"=",
"None",
",",
"output",
"=",
"None",
",",
"filter_op",
"=",
"None",
",",
"info_keys",
"=",
"None",
",",
"result_keys",
"=",
"None",
")",
":",
"_check_tabulate",
"(",
")",
"experiment_state",
"=... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | list_experiments | Lists experiments in the directory subtree.
Args:
project_path (str): Directory where experiments are located.
Corresponds to Experiment.local_dir.
sort (str): Key to sort by.
output (str): Name of file where output is saved.
filter_op (str): Filter operation in the form... | python/ray/tune/commands.py | def list_experiments(project_path,
sort=None,
output=None,
filter_op=None,
info_keys=None):
"""Lists experiments in the directory subtree.
Args:
project_path (str): Directory where experiments are located.
C... | def list_experiments(project_path,
sort=None,
output=None,
filter_op=None,
info_keys=None):
"""Lists experiments in the directory subtree.
Args:
project_path (str): Directory where experiments are located.
C... | [
"Lists",
"experiments",
"in",
"the",
"directory",
"subtree",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L211-L309 | [
"def",
"list_experiments",
"(",
"project_path",
",",
"sort",
"=",
"None",
",",
"output",
"=",
"None",
",",
"filter_op",
"=",
"None",
",",
"info_keys",
"=",
"None",
")",
":",
"_check_tabulate",
"(",
")",
"base",
",",
"experiment_folders",
",",
"_",
"=",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | add_note | Opens a txt file at the given path where user can add and save notes.
Args:
path (str): Directory where note will be saved.
filename (str): Name of note. Defaults to "note.txt" | python/ray/tune/commands.py | def add_note(path, filename="note.txt"):
"""Opens a txt file at the given path where user can add and save notes.
Args:
path (str): Directory where note will be saved.
filename (str): Name of note. Defaults to "note.txt"
"""
path = os.path.expanduser(path)
assert os.path.isdir(path)... | def add_note(path, filename="note.txt"):
"""Opens a txt file at the given path where user can add and save notes.
Args:
path (str): Directory where note will be saved.
filename (str): Name of note. Defaults to "note.txt"
"""
path = os.path.expanduser(path)
assert os.path.isdir(path)... | [
"Opens",
"a",
"txt",
"file",
"at",
"the",
"given",
"path",
"where",
"user",
"can",
"add",
"and",
"save",
"notes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L312-L333 | [
"def",
"add_note",
"(",
"path",
",",
"filename",
"=",
"\"note.txt\"",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
"assert",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
",",
"\"{} is not a valid directory.\"",
"."... | 4eade036a0505e244c976f36aaa2d64386b5129b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.