id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
24,300
ray-project/ray
python/ray/tune/suggest/variant_generator.py
resolve_nested_dict
def resolve_nested_dict(nested_dict): """Flattens a nested dict by joining keys into tuple of paths. Can then be passed into `format_vars`. """ res = {} for k, v in nested_dict.items(): if isinstance(v, dict): for k_, v_ in resolve_nested_dict(v).items(): res[(k,...
python
def resolve_nested_dict(nested_dict): """Flattens a nested dict by joining keys into tuple of paths. Can then be passed into `format_vars`. """ res = {} for k, v in nested_dict.items(): if isinstance(v, dict): for k_, v_ in resolve_nested_dict(v).items(): res[(k,...
[ "def", "resolve_nested_dict", "(", "nested_dict", ")", ":", "res", "=", "{", "}", "for", "k", ",", "v", "in", "nested_dict", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "for", "k_", ",", "v_", "in", "resolve_ne...
Flattens a nested dict by joining keys into tuple of paths. Can then be passed into `format_vars`.
[ "Flattens", "a", "nested", "dict", "by", "joining", "keys", "into", "tuple", "of", "paths", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/variant_generator.py#L108-L120
24,301
ray-project/ray
python/ray/tune/automlboard/run.py
run_board
def run_board(args): """ Run main entry for AutoMLBoard. Args: args: args parsed from command line """ init_config(args) # backend service, should import after django settings initialized from backend.collector import CollectorService service = CollectorService( args.l...
python
def run_board(args): """ Run main entry for AutoMLBoard. Args: args: args parsed from command line """ init_config(args) # backend service, should import after django settings initialized from backend.collector import CollectorService service = CollectorService( args.l...
[ "def", "run_board", "(", "args", ")", ":", "init_config", "(", "args", ")", "# backend service, should import after django settings initialized", "from", "backend", ".", "collector", "import", "CollectorService", "service", "=", "CollectorService", "(", "args", ".", "lo...
Run main entry for AutoMLBoard. Args: args: args parsed from command line
[ "Run", "main", "entry", "for", "AutoMLBoard", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L18-L43
24,302
ray-project/ray
python/ray/tune/automlboard/run.py
init_config
def init_config(args): """ Initialize configs of the service. Do the following things: 1. automl board settings 2. database settings 3. django settings """ os.environ["AUTOMLBOARD_LOGDIR"] = args.logdir os.environ["AUTOMLBOARD_LOGLEVEL"] = args.log_level os.environ["AUTOMLBOARD_...
python
def init_config(args): """ Initialize configs of the service. Do the following things: 1. automl board settings 2. database settings 3. django settings """ os.environ["AUTOMLBOARD_LOGDIR"] = args.logdir os.environ["AUTOMLBOARD_LOGLEVEL"] = args.log_level os.environ["AUTOMLBOARD_...
[ "def", "init_config", "(", "args", ")", ":", "os", ".", "environ", "[", "\"AUTOMLBOARD_LOGDIR\"", "]", "=", "args", ".", "logdir", "os", ".", "environ", "[", "\"AUTOMLBOARD_LOGLEVEL\"", "]", "=", "args", ".", "log_level", "os", ".", "environ", "[", "\"AUTO...
Initialize configs of the service. Do the following things: 1. automl board settings 2. database settings 3. django settings
[ "Initialize", "configs", "of", "the", "service", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L46-L80
24,303
ray-project/ray
python/ray/worker.py
get_gpu_ids
def get_gpu_ids(): """Get the IDs of the GPUs that are available to the worker. If the CUDA_VISIBLE_DEVICES environment variable was set when the worker started up, then the IDs returned by this method will be a subset of the IDs in CUDA_VISIBLE_DEVICES. If not, the IDs will fall in the range [0, N...
python
def get_gpu_ids(): """Get the IDs of the GPUs that are available to the worker. If the CUDA_VISIBLE_DEVICES environment variable was set when the worker started up, then the IDs returned by this method will be a subset of the IDs in CUDA_VISIBLE_DEVICES. If not, the IDs will fall in the range [0, N...
[ "def", "get_gpu_ids", "(", ")", ":", "if", "_mode", "(", ")", "==", "LOCAL_MODE", ":", "raise", "Exception", "(", "\"ray.get_gpu_ids() currently does not work in PYTHON \"", "\"MODE.\"", ")", "all_resource_ids", "=", "global_worker", ".", "raylet_client", ".", "resour...
Get the IDs of the GPUs that are available to the worker. If the CUDA_VISIBLE_DEVICES environment variable was set when the worker started up, then the IDs returned by this method will be a subset of the IDs in CUDA_VISIBLE_DEVICES. If not, the IDs will fall in the range [0, NUM_GPUS - 1], where NUM_GP...
[ "Get", "the", "IDs", "of", "the", "GPUs", "that", "are", "available", "to", "the", "worker", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1042-L1069
24,304
ray-project/ray
python/ray/worker.py
error_info
def error_info(): """Return information about failed tasks.""" worker = global_worker worker.check_connected() return (global_state.error_messages(driver_id=worker.task_driver_id) + global_state.error_messages(driver_id=DriverID.nil()))
python
def error_info(): """Return information about failed tasks.""" worker = global_worker worker.check_connected() return (global_state.error_messages(driver_id=worker.task_driver_id) + global_state.error_messages(driver_id=DriverID.nil()))
[ "def", "error_info", "(", ")", ":", "worker", "=", "global_worker", "worker", ".", "check_connected", "(", ")", "return", "(", "global_state", ".", "error_messages", "(", "driver_id", "=", "worker", ".", "task_driver_id", ")", "+", "global_state", ".", "error_...
Return information about failed tasks.
[ "Return", "information", "about", "failed", "tasks", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1134-L1139
24,305
ray-project/ray
python/ray/worker.py
_initialize_serialization
def _initialize_serialization(driver_id, worker=global_worker): """Initialize the serialization library. This defines a custom serializer for object IDs and also tells ray to serialize several exception classes that we define for error handling. """ serialization_context = pyarrow.default_serializa...
python
def _initialize_serialization(driver_id, worker=global_worker): """Initialize the serialization library. This defines a custom serializer for object IDs and also tells ray to serialize several exception classes that we define for error handling. """ serialization_context = pyarrow.default_serializa...
[ "def", "_initialize_serialization", "(", "driver_id", ",", "worker", "=", "global_worker", ")", ":", "serialization_context", "=", "pyarrow", ".", "default_serialization_context", "(", ")", "# Tell the serialization context to use the cloudpickle version that we", "# ship with Ra...
Initialize the serialization library. This defines a custom serializer for object IDs and also tells ray to serialize several exception classes that we define for error handling.
[ "Initialize", "the", "serialization", "library", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1142-L1210
24,306
ray-project/ray
python/ray/worker.py
print_logs
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_...
python
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", ")", ":", "pubsub_client", "=", "redis_client", ".", "pubsub", "(", "ignore_subscribe_messages", "=", "True", ")", "pubsub_client", ".", "subscribe", "(", "ray", ".", "gcs_utils", ".", "LOG_FILE_CHA...
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.
[ "Prints", "log", "messages", "from", "workers", "on", "all", "of", "the", "nodes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1526-L1575
24,307
ray-project/ray
python/ray/worker.py
print_error_messages_raylet
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...
python
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", ")", ":", "while", "True", ":", "# Exit if we received a signal that we should stop.", "if", "threads_stopped", ".", "is_set", "(", ")", ":", "return", "try", ":", "error", ",", "t"...
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 ...
[ "Prints", "message", "received", "in", "the", "given", "output", "queue", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1578-L1610
24,308
ray-project/ray
python/ray/worker.py
listen_error_messages_raylet
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...
python
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", ")", ":", "worker", ".", "error_message_pubsub_client", "=", "worker", ".", "redis_client", ".", "pubsub", "(", "ignore_subscribe_messages", "=", "True", ")", "# Exp...
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 ...
[ "Listen", "to", "error", "messages", "in", "the", "background", "on", "the", "driver", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1613-L1675
24,309
ray-project/ray
python/ray/worker.py
disconnect
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 ...
python
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", "(", ")", ":", "# 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...
Disconnect this worker from the raylet and object store.
[ "Disconnect", "this", "worker", "from", "the", "raylet", "and", "object", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1961-L1994
24,310
ray-project/ray
python/ray/worker.py
_try_to_compute_deterministic_class_id
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...
python
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", ")", ":", "# Pickling, loading, and pickling again seems to produce more consistent", "# results than simply pickling. This is a bit", "class_id", "=", "pickle", ".", "dumps", "(", "cls", ")", ...
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...
[ "Attempt", "to", "produce", "a", "deterministic", "class", "ID", "for", "a", "given", "class", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2006-L2045
24,311
ray-project/ray
python/ray/worker.py
register_custom_serializer
def register_custom_serializer(cls, use_pickle=False, use_dict=False, serializer=None, deserializer=None, local=False, driver_id=None,...
python
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", ",", "class_id", "...
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...
[ "Enable", "serialization", "and", "deserialization", "for", "a", "particular", "class", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2048-L2148
24,312
ray-project/ray
python/ray/worker.py
get
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 ...
python
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", ")", ":", "worker", "=", "global_worker", "worker", ".", "check_connected", "(", ")", "with", "profiling", ".", "profile", "(", "\"ray.get\"", ")", ":", "if", "worker", ".", "mode", "==", "LOCAL_MODE", ":", "# In LOCAL_MODE, ...
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...
[ "Get", "a", "remote", "object", "or", "a", "list", "of", "remote", "objects", "from", "the", "object", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2151-L2194
24,313
ray-project/ray
python/ray/worker.py
put
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: ...
python
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", ")", ":", "worker", "=", "global_worker", "worker", ".", "check_connected", "(", ")", "with", "profiling", ".", "profile", "(", "\"ray.put\"", ")", ":", "if", "worker", ".", "mode", "==", "LOCAL_MODE", ":", "# In LOCAL_MODE, ray.p...
Store an object in the object store. Args: value: The Python object to be stored. Returns: The object ID assigned to this value.
[ "Store", "an", "object", "in", "the", "object", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2197-L2218
24,314
ray-project/ray
python/ray/worker.py
remote
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): ...
python
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", ")", ":", "worker", "=", "get_global_worker", "(", ")", "if", "len", "(", "args", ")", "==", "1", "and", "len", "(", "kwargs", ")", "==", "0", "and", "callable", "(", "args", "[", "0", ...
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...
[ "Define", "a", "remote", "function", "or", "an", "actor", "class", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2369-L2467
24,315
ray-project/ray
python/ray/worker.py
Worker.task_context
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...
python
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", ")", ":", "if", "not", "hasattr", "(", "self", ".", "_task_context", ",", "\"initialized\"", ")", ":", "# Initialize task_context for the current thread.", "if", "ray", ".", "utils", ".", "is_main_thread", "(", ")", ":", "# If...
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 ...
[ "A", "thread", "-", "local", "that", "contains", "the", "following", "attributes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L175-L210
24,316
ray-project/ray
python/ray/worker.py
Worker.get_serialization_context
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...
python
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", ")", ":", "# 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", ...
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.
[ "Get", "the", "SerializationContext", "of", "the", "driver", "that", "this", "worker", "is", "processing", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L227-L244
24,317
ray-project/ray
python/ray/worker.py
Worker.store_and_register
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...
python
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", ")", ":", "counter", "=", "0", "while", "True", ":", "if", "counter", "==", "depth", ":", "raise", "Exception", "(", "\"Ray exceeded the maximum number of class...
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...
[ "Store", "an", "object", "and", "attempt", "to", "register", "its", "class", "if", "needed", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L276-L350
24,318
ray-project/ray
python/ray/worker.py
Worker.put_object
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 ...
python
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", ")", ":", "# 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 \"", ...
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...
[ "Put", "value", "in", "the", "local", "object", "store", "with", "object", "id", "objectid", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L352-L400
24,319
ray-project/ray
python/ray/worker.py
Worker.get_object
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: ...
python
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", ")", ":", "# Make sure that the values are object IDs.", "for", "object_id", "in", "object_ids", ":", "if", "not", "isinstance", "(", "object_id", ",", "ObjectID", ")", ":", "raise", "TypeError", "(", "\"Attempt...
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...
[ "Get", "the", "value", "or", "values", "in", "the", "object", "store", "associated", "with", "the", "IDs", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L479-L559
24,320
ray-project/ray
python/ray/worker.py
Worker.submit_task
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, ...
python
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", "=", "Non...
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...
[ "Submit", "a", "remote", "task", "to", "the", "scheduler", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L561-L699
24,321
ray-project/ray
python/ray/worker.py
Worker.run_function_on_all_workers
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 ...
python
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", ")", ":", "# 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", ...
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...
[ "Run", "arbitrary", "code", "on", "all", "of", "the", "workers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L701-L752
24,322
ray-project/ray
python/ray/worker.py
Worker._get_arguments_for_execution
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...
python
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", ")", ":", "arguments", "=", "[", "]", "for", "(", "i", ",", "arg", ")", "in", "enumerate", "(", "serialized_args", ")", ":", "if", "isinstance", "(", "arg", "...
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: ...
[ "Retrieve", "the", "arguments", "for", "the", "remote", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L759-L794
24,323
ray-project/ray
python/ray/worker.py
Worker._store_outputs_in_object_store
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...
python
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", ")", ":", "for", "i", "in", "range", "(", "len", "(", "object_ids", ")", ")", ":", "if", "isinstance", "(", "outputs", "[", "i", "]", ",", "ray", ".", "actor", "."...
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...
[ "Store", "the", "outputs", "of", "a", "remote", "function", "in", "the", "local", "object", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L796-L828
24,324
ray-project/ray
python/ray/worker.py
Worker._process_task
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...
python
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", ")", ":", "assert", "self", ".", "current_task_id", ".", "is_nil", "(", ")", "assert", "self", ".", "task_context", ".", "task_index", "==", "0", "assert", "self", ".", "task_c...
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...
[ "Execute", "a", "task", "assigned", "to", "this", "worker", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L830-L921
24,325
ray-project/ray
python/ray/worker.py
Worker._wait_for_and_process_task
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() ...
python
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", ")", ":", "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. Args: task: The task to execute.
[ "Wait", "for", "a", "task", "to", "be", "ready", "and", "process", "the", "task", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L943-L1012
24,326
ray-project/ray
python/ray/worker.py
Worker._get_next_task_from_raylet
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. ...
python
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", ")", ":", "with", "profiling", ".", "profile", "(", "\"worker_idle\"", ")", ":", "task", "=", "self", ".", "raylet_client", ".", "get_task", "(", ")", "# Automatically restrict the GPUs available to this task.", "ray",...
Get the next task from the raylet. Returns: A task from the raylet.
[ "Get", "the", "next", "task", "from", "the", "raylet", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1014-L1026
24,327
ray-project/ray
python/ray/worker.py
Worker.main_loop
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_...
python
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", ")", ":", "def", "exit", "(", "signum", ",", "frame", ")", ":", "shutdown", "(", ")", "sys", ".", "exit", "(", "0", ")", "signal", ".", "signal", "(", "signal", ".", "SIGTERM", ",", "exit", ")", "while", "True", "...
The main loop a worker runs to receive and execute tasks.
[ "The", "main", "loop", "a", "worker", "runs", "to", "receive", "and", "execute", "tasks", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1028-L1039
24,328
ray-project/ray
python/ray/rllib/agents/ppo/utils.py
flatten
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. """ ...
python
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", ")", ":", "for", "key", ",", "val", "in", "weights", ".", "items", "(", ")", ":", "new_shape", "=", "val", ".", "shape", "[", "0", ":", "start", "]", "+", "(", "...
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", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ppo/utils.py#L8-L21
24,329
ray-project/ray
python/ray/node.py
Node.address_info
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, ...
python
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", ")", ":", "return", "{", "\"node_ip_address\"", ":", "self", ".", "_node_ip_address", ",", "\"redis_address\"", ":", "self", ".", "_redis_address", ",", "\"object_store_address\"", ":", "self", ".", "_plasma_store_socket_name", ",...
Get a dictionary of addresses.
[ "Get", "a", "dictionary", "of", "addresses", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L199-L207
24,330
ray-project/ray
python/ray/node.py
Node.create_redis_client
def create_redis_client(self): """Create a redis client.""" return ray.services.create_redis_client( self._redis_address, self._ray_params.redis_password)
python
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", ")", ":", "return", "ray", ".", "services", ".", "create_redis_client", "(", "self", ".", "_redis_address", ",", "self", ".", "_ray_params", ".", "redis_password", ")" ]
Create a redis client.
[ "Create", "a", "redis", "client", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L209-L212
24,331
ray-project/ray
python/ray/node.py
Node._make_inc_temp
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...
python
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\"", ")", ":", "directory_name", "=", "os", ".", "path", ".", "expanduser", "(", "directory_name", ")", "index", "=", "self...
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 ...
[ "Return", "a", "incremental", "temporary", "file", "name", ".", "The", "file", "is", "not", "created", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L226-L256
24,332
ray-project/ray
python/ray/node.py
Node.new_log_files
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...
python
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", ")", ":", "if", "redirect_output", "is", "None", ":", "redirect_output", "=", "self", ".", "_ray_params", ".", "redirect_output", "if", "not", "redirect_output", ":", "retur...
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....
[ "Generate", "partially", "randomized", "filenames", "for", "log", "files", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L258-L287
24,333
ray-project/ray
python/ray/node.py
Node._prepare_socket_file
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...
python
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", ")", ":", "if", "socket_path", "is", "not", "None", ":", "if", "os", ".", "path", ".", "exists", "(", "socket_path", ")", ":", "raise", "Exception", "(", "\"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.
[ "Prepare", "the", "socket", "file", "for", "raylet", "and", "plasma", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L289-L306
24,334
ray-project/ray
python/ray/node.py
Node.start_redis
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...
python
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", ")", ":", "assert", "self", ".", "_redis_address", "is", "None", "redis_log_files", "=", "[", "self", ".", "new_log_files", "(", "\"redis\"", ")", "]", "for", "i", "in", "range", "(", "self", ".", "_ray_params", ".", "n...
Start the Redis servers.
[ "Start", "the", "Redis", "servers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L308-L330
24,335
ray-project/ray
python/ray/node.py
Node.start_log_monitor
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...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"log_monitor\"", ")", "process_info", "=", "ray", ".", "services", ".", "start_log_monitor", "(", "self", ".", "redis_address", ",", ...
Start the log monitor.
[ "Start", "the", "log", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L332-L344
24,336
ray-project/ray
python/ray/node.py
Node.start_reporter
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...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"reporter\"", ",", "True", ")", "process_info", "=", "ray", ".", "services", ".", "start_reporter", "(", "self", ".", "redis_address", ...
Start the reporter.
[ "Start", "the", "reporter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L346-L358
24,337
ray-project/ray
python/ray/node.py
Node.start_dashboard
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...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"dashboard\"", ",", "True", ")", "self", ".", "_webui_url", ",", "process_info", "=", "ray", ".", "services", ".", "start_dashboard", ...
Start the dashboard.
[ "Start", "the", "dashboard", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L360-L375
24,338
ray-project/ray
python/ray/node.py
Node.start_plasma_store
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...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"plasma_store\"", ")", "process_info", "=", "ray", ".", "services", ".", "start_plasma_store", "(", "stdout_file", "=", "stdout_file", ...
Start the plasma store.
[ "Start", "the", "plasma", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L377-L391
24,339
ray-project/ray
python/ray/node.py
Node.start_raylet
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. ...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"raylet\"", ")", "process_info", "=", "ray", ".", "services", "."...
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", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L393-L426
24,340
ray-project/ray
python/ray/node.py
Node.new_worker_redirected_log_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
python
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", ")", ":", "worker_stdout_file", ",", "worker_stderr_file", "=", "(", "self", ".", "new_log_files", "(", "\"worker-\"", "+", "ray", ".", "utils", ".", "binary_to_hex", "(", "worker_id", ")", ...
Create new logging files for workers to redirect its output.
[ "Create", "new", "logging", "files", "for", "workers", "to", "redirect", "its", "output", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L428-L432
24,341
ray-project/ray
python/ray/node.py
Node.start_monitor
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...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"monitor\"", ")", "process_info", "=", "ray", ".", "services", ".", "start_monitor", "(", "self", ".", "_redis_address", ",", "stdout_fi...
Start the monitor.
[ "Start", "the", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L438-L448
24,342
ray-project/ray
python/ray/node.py
Node.start_raylet_monitor
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, ...
python
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", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"raylet_monitor\"", ")", "process_info", "=", "ray", ".", "services", ".", "start_raylet_monitor", "(", "self", ".", "_redis_address"...
Start the raylet monitor.
[ "Start", "the", "raylet", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L450-L463
24,343
ray-project/ray
python/ray/node.py
Node.start_head_processes
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...
python
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", ")", ":", "logger", ".", "info", "(", "\"Process STDOUT and STDERR is being redirected to {}.\"", ".", "format", "(", "self", ".", "_logs_dir", ")", ")", "assert", "self", ".", "_redis_address", "is", "None", "# If this is...
Start head processes on the node.
[ "Start", "head", "processes", "on", "the", "node", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L465-L477
24,344
ray-project/ray
python/ray/node.py
Node.start_ray_processes
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...
python
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", ")", ":", "logger", ".", "info", "(", "\"Process STDOUT and STDERR is being redirected to {}.\"", ".", "format", "(", "self", ".", "_logs_dir", ")", ")", "self", ".", "start_plasma_store", "(", ")", "self", ".", "start_ra...
Start all of the processes on the node.
[ "Start", "all", "of", "the", "processes", "on", "the", "node", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L479-L491
24,345
ray-project/ray
python/ray/node.py
Node._kill_process_type
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...
python
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", ")", ":", "process_infos", "=", "self", ".", "all_processes", "[", "process_type", "]", "if", "pro...
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...
[ "Kill", "a", "process", "of", "a", "given", "type", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L493-L579
24,346
ray-project/ray
python/ray/node.py
Node.kill_redis
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...
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_REDIS_SERVER", ",", "check_alive", "=", "check_alive", ")" ]
Kill the Redis servers. Args: check_alive (bool): Raise an exception if any of the processes were already dead.
[ "Kill", "the", "Redis", "servers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L581-L589
24,347
ray-project/ray
python/ray/node.py
Node.kill_plasma_store
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)
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_PLASMA_STORE", ",", "check_alive", "=", "check_alive", ")" ]
Kill the plasma store. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "plasma", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L591-L599
24,348
ray-project/ray
python/ray/node.py
Node.kill_raylet
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)
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_RAYLET", ",", "check_alive", "=", "check_alive", ")" ]
Kill the raylet. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "raylet", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L601-L609
24,349
ray-project/ray
python/ray/node.py
Node.kill_log_monitor
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)
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_LOG_MONITOR", ",", "check_alive", "=", "check_alive", ")" ]
Kill the log monitor. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "log", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L611-L619
24,350
ray-project/ray
python/ray/node.py
Node.kill_reporter
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...
python
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", ")", ":", "# reporter is started only in PY3.", "if", "PY3", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_REPORTER", ",", "check_alive", "=", "check_alive", ")"...
Kill the reporter. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "reporter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L621-L631
24,351
ray-project/ray
python/ray/node.py
Node.kill_dashboard
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)
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_DASHBOARD", ",", "check_alive", "=", "check_alive", ")" ]
Kill the dashboard. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "dashboard", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L633-L641
24,352
ray-project/ray
python/ray/node.py
Node.kill_monitor
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)
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_MONITOR", ",", "check_alive", "=", "check_alive", ")" ]
Kill the monitor. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L643-L651
24,353
ray-project/ray
python/ray/node.py
Node.kill_raylet_monitor
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...
python
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", ")", ":", "self", ".", "_kill_process_type", "(", "ray_constants", ".", "PROCESS_TYPE_RAYLET_MONITOR", ",", "check_alive", "=", "check_alive", ")" ]
Kill the raylet monitor. Args: check_alive (bool): Raise an exception if the process was already dead.
[ "Kill", "the", "raylet", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L653-L661
24,354
ray-project/ray
python/ray/node.py
Node.kill_all_processes
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 ...
python
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 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...
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.
[ "Kill", "all", "of", "the", "processes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L663-L690
24,355
ray-project/ray
python/ray/node.py
Node.live_processes
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...
python
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", ")", ":", "result", "=", "[", "]", "for", "process_type", ",", "process_infos", "in", "self", ".", "all_processes", ".", "items", "(", ")", ":", "for", "process_info", "in", "process_infos", ":", "if", "process_info", ...
Return a list of the live processes. Returns: A list of the live processes.
[ "Return", "a", "list", "of", "the", "live", "processes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L692-L703
24,356
ray-project/ray
python/ray/rllib/agents/es/es.py
create_shared_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
python
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", ")", ":", "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.
[ "Create", "a", "large", "array", "of", "noise", "to", "be", "shared", "by", "all", "workers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/es/es.py#L51-L55
24,357
ray-project/ray
python/ray/experimental/sgd/tfbench/model_config.py
get_model_config
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: ...
python
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", ")", ":", "model_map", "=", "_get_model_map", "(", "dataset", ".", "name", ")", "if", "model_name", "not", "in", "model_map", ":", "raise", "ValueError", "(", "\"Invalid model name \\\"%s\\\" for dataset ...
Map model name to model network configuration.
[ "Map", "model", "name", "to", "model", "network", "configuration", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model_config.py#L41-L48
24,358
ray-project/ray
python/ray/experimental/sgd/tfbench/model_config.py
register_model
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\"" ...
python
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", ")", ":", "model_map", "=", "_get_model_map", "(", "dataset_name", ")", "if", "model_name", "in", "model_map", ":", "raise", "ValueError", "(", "\"Model \\\"%s\\\" is already registere...
Register a new model that can be obtained with `get_model_config`.
[ "Register", "a", "new", "model", "that", "can", "be", "obtained", "with", "get_model_config", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model_config.py#L51-L57
24,359
ray-project/ray
python/ray/rllib/agents/ars/policies.py
rollout
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...
python
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", ")", ":", "env_timestep_limit", "=", "env", ".", "spec", ".", "max_episode_steps", "timestep_limit", "=", "(", "env_ti...
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...
[ "Do", "a", "rollout", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ars/policies.py#L19-L54
24,360
ray-project/ray
python/ray/tune/suggest/basic_variant.py
BasicVariantGenerator.next_trials
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...
python
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", ")", ":", "trials", "=", "list", "(", "self", ".", "_trial_generator", ")", "if", "self", ".", "_shuffle", ":", "random", ".", "shuffle", "(", "trials", ")", "self", ".", "_finished", "=", "True", "return", "trials" ]
Provides Trial objects to be queued into the TrialRunner. Returns: trials (list): Returns a list of trials.
[ "Provides", "Trial", "objects", "to", "be", "queued", "into", "the", "TrialRunner", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/basic_variant.py#L51-L61
24,361
ray-project/ray
python/ray/tune/suggest/basic_variant.py
BasicVariantGenerator._generate_trials
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...
python
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", "=", "\"\"", ")", ":", "if", "\"run\"", "not", "in", "unresolved_spec", ":", "raise", "TuneError", "(", "\"Must specify `run` in {}\"", ".", "format", "(", "unresolved_spec", ")", ...
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
[ "Generates", "Trial", "objects", "with", "the", "variant", "generation", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/basic_variant.py#L63-L87
24,362
ray-project/ray
python/ray/rllib/optimizers/segment_tree.py
SegmentTree.reduce
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...
python
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", ")", ":", "if", "end", "is", "None", ":", "end", "=", "self", ".", "_capacity", "-", "1", "if", "end", "<", "0", ":", "end", "+=", "self", ".", "_capacity", "return"...
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 ...
[ "Returns", "result", "of", "applying", "self", ".", "operation", "to", "a", "contiguous", "subsequence", "of", "the", "array", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/segment_tree.py#L59-L83
24,363
ray-project/ray
python/ray/experimental/gcs_flush_policy.py
set_flushing_policy
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." ...
python
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", ")", ":", "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 ...
Serialize this policy for Monitor to pick up.
[ "Serialize", "this", "policy", "for", "Monitor", "to", "pick", "up", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/gcs_flush_policy.py#L80-L91
24,364
ray-project/ray
python/ray/tune/cluster_info.py
get_ssh_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...
python
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", "(", ")", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "\"TUNE_CLUSTER_SSH_KEY\"", ",", "os", ".", "path", ".", "expanduser", "(", "\"~/ray_bootstrap_key.pem\"", ")", ")", "if", "os", ".", "path", ".", "exists", "(", "pa...
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.
[ "Returns", "ssh", "key", "to", "connecting", "to", "cluster", "workers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/cluster_info.py#L15-L25
24,365
ray-project/ray
python/ray/tune/suggest/hyperopt.py
HyperOptSearch.on_trial_complete
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...
python
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", ")", ":", "ho_trial", "=", "self", ".", "_get_hyperopt_trial", "(", "trial_id", ")", "if", "ho_trial", ...
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.
[ "Passes", "the", "result", "to", "HyperOpt", "unless", "early", "terminated", "or", "errored", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/hyperopt.py#L126-L151
24,366
ray-project/ray
python/ray/experimental/streaming/batched_queue.py
plasma_prefetch
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)
python
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", ")", ":", "local_sched_client", "=", "ray", ".", "worker", ".", "global_worker", ".", "raylet_client", "ray_obj_id", "=", "ray", ".", "ObjectID", "(", "object_id", ")", "local_sched_client", ".", "fetch_or_reconstruct", ...
Tells plasma to prefetch the given object_id.
[ "Tells", "plasma", "to", "prefetch", "the", "given", "object_id", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L17-L21
24,367
ray-project/ray
python/ray/experimental/streaming/batched_queue.py
plasma_get
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(...
python
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", ")", ":", "client", "=", "ray", ".", "worker", ".", "global_worker", ".", "plasma_client", "plasma_id", "=", "ray", ".", "pyarrow", ".", "plasma", ".", "ObjectID", "(", "object_id", ")", "while", "not", "client", ".",...
Get an object directly from plasma without going through object table. Precondition: plasma_prefetch(object_id) has been called before.
[ "Get", "an", "object", "directly", "from", "plasma", "without", "going", "through", "object", "table", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L24-L33
24,368
ray-project/ray
python/ray/experimental/streaming/batched_queue.py
BatchedQueue.enable_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)
python
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", ")", ":", "self", ".", "write_buffer", "=", "[", "]", "self", ".", "flush_lock", "=", "threading", ".", "RLock", "(", ")", "self", ".", "flush_thread", "=", "FlushThread", "(", "self", ".", "max_batch_time", ",", "sel...
Restores the state of the batched queue for writing.
[ "Restores", "the", "state", "of", "the", "batched", "queue", "for", "writing", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L136-L141
24,369
ray-project/ray
python/ray/experimental/streaming/batched_queue.py
BatchedQueue._wait_for_reader
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_...
python
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", ")", ":", "if", "self", ".", "max_size", "<=", "0", ":", "# Unlimited queue", "return", "if", "self", ".", "write_item_offset", "-", "self", ".", "cached_remote_offset", "<=", "self", ".", "max_size", ":", "return", "#...
Checks for backpressure by the downstream reader.
[ "Checks", "for", "backpressure", "by", "the", "downstream", "reader", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L166-L187
24,370
ray-project/ray
python/ray/rllib/optimizers/rollout.py
collect_samples
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...
python
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", ")", ":", "num_timesteps_so_far", "=", "0", "trajectories", "=", "[", "]", "agent_dict", "=", "{", "}", "for", "agent", "in", "agents", ":", ...
Collects at least train_batch_size samples, never discarding any.
[ "Collects", "at", "least", "train_batch_size", "samples", "never", "discarding", "any", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/rollout.py#L14-L40
24,371
ray-project/ray
python/ray/rllib/optimizers/rollout.py
collect_samples_straggler_mitigation
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...
python
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", ")", ":", "num_timesteps_so_far", "=", "0", "trajectories", "=", "[", "]", "agent_dict", "=", "{", "}", "for", "agent", "in", "agents", ":", "fut_sample", "=", "agent", ".", ...
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.
[ "Collects", "at", "least", "train_batch_size", "samples", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/rollout.py#L43-L72
24,372
ray-project/ray
python/ray/utils.py
format_error_message
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. ...
python
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", ")", ":", "lines", "=", "exception_message", ".", "split", "(", "\"\\n\"", ")", "if", "task_exception", ":", "# For errors that occur inside of tasks, remove lines 1 and 2 which ar...
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...
[ "Improve", "the", "formatting", "of", "an", "exception", "thrown", "by", "a", "remote", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L32-L51
24,373
ray-project/ray
python/ray/utils.py
is_cython
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...
python
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", ")", ":", "# 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...
Check if an object is a Cython function or method
[ "Check", "if", "an", "object", "is", "a", "Cython", "function", "or", "method" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L102-L114
24,374
ray-project/ray
python/ray/utils.py
is_function_or_method
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)
python
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", ")", ":", "return", "inspect", ".", "isfunction", "(", "obj", ")", "or", "inspect", ".", "ismethod", "(", "obj", ")", "or", "is_cython", "(", "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.
[ "Check", "if", "an", "object", "is", "a", "function", "or", "method", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L117-L126
24,375
ray-project/ray
python/ray/utils.py
random_string
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...
python
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", "(", ")", ":", "# 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...
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...
[ "Generate", "a", "random", "string", "to", "use", "as", "an", "ID", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L134-L157
24,376
ray-project/ray
python/ray/utils.py
decode
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. ...
python
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", ")", ":", "if", "byte_str", "is", "None", "and", "allow_none", ":", "return", "\"\"", "if", "not", "isinstance", "(", "byte_str", ",", "bytes", ")", ":", "raise", "ValueError", "(", "\"Th...
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...
[ "Make", "this", "unicode", "in", "Python", "3", "otherwise", "leave", "it", "as", "bytes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L160-L181
24,377
ray-project/ray
python/ray/utils.py
get_cuda_visible_devices
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...
python
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", "(", ")", ":", "gpu_ids_str", "=", "os", ".", "environ", ".", "get", "(", "\"CUDA_VISIBLE_DEVICES\"", ",", "None", ")", "if", "gpu_ids_str", "is", "None", ":", "return", "None", "if", "gpu_ids_str", "==", "\"\"", ":", "retu...
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.
[ "Get", "the", "device", "IDs", "in", "the", "CUDA_VISIBLE_DEVICES", "environment", "variable", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L230-L245
24,378
ray-project/ray
python/ray/utils.py
resources_from_resource_arguments
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...
python
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", ")", ":", "if", "runtime_resources", "is", "not", "None", ":", "resources", ...
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...
[ "Determine", "a", "task", "s", "resource", "requirements", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L257-L299
24,379
ray-project/ray
python/ray/utils.py
setup_logger
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...
python
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", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"ray\"", ")", "if", "type", "(", "logging_level", ")", "is", "str", ":", "logging_level", "=", "logging", ".", "getLevelName", "(...
Setup default logging for ray.
[ "Setup", "default", "logging", "for", "ray", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L305-L316
24,380
ray-project/ray
python/ray/utils.py
vmstat
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"): ...
python
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", ")", ":", "out", "=", "subprocess", ".", "check_output", "(", "[", "\"vmstat\"", ",", "\"-s\"", "]", ")", "stat", "=", "stat", ".", "encode", "(", "\"ascii\"", ")", "for", "line", "in", "out", ".", "split", "(", "b\"\\n\...
Run vmstat and get a particular statistic. Args: stat: The statistic that we are interested in retrieving. Returns: The parsed output.
[ "Run", "vmstat", "and", "get", "a", "particular", "statistic", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L321-L336
24,381
ray-project/ray
python/ray/utils.py
sysctl
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: ...
python
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", ")", ":", "out", "=", "subprocess", ".", "check_output", "(", "command", ")", "result", "=", "out", ".", "split", "(", "b\" \"", ")", "[", "1", "]", "try", ":", "return", "int", "(", "result", ")", "except", "ValueErr...
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.
[ "Run", "a", "sysctl", "command", "and", "parse", "the", "output", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L341-L356
24,382
ray-project/ray
python/ray/utils.py
get_system_memory
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...
python
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", "(", ")", ":", "# 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...
Return the total amount of system memory in bytes. Returns: The total amount of system memory in bytes.
[ "Return", "the", "total", "amount", "of", "system", "memory", "in", "bytes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L359-L395
24,383
ray-project/ray
python/ray/utils.py
get_shared_memory_bytes
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...
python
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", "(", ")", ":", "# Make sure this is only called on Linux.", "assert", "sys", ".", "platform", "==", "\"linux\"", "or", "sys", ".", "platform", "==", "\"linux2\"", "shm_fd", "=", "os", ".", "open", "(", "\"/dev/shm\"", ",", "os", ...
Get the size of the shared memory file system. Returns: The size of the shared memory file system in bytes.
[ "Get", "the", "size", "of", "the", "shared", "memory", "file", "system", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L398-L417
24,384
ray-project/ray
python/ray/utils.py
check_oversized_pickle
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'...
python
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", ")", ":", "length", "=", "len", "(", "pickled", ")", "if", "length", "<=", "ray_constants", ".", "PICKLE_OBJECT_WARNING_SIZE", ":", "return", "warning_message", "=", ...
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...
[ "Send", "a", "warning", "message", "if", "the", "pickled", "object", "is", "too", "large", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L420-L442
24,385
ray-project/ray
python/ray/utils.py
thread_safe_client
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...
python
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", ")", ":", "if", "lock", "is", "None", ":", "lock", "=", "threading", ".", "Lock", "(", ")", "return", "_ThreadSafeProxy", "(", "client", ",", "lock", ")" ]
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...
[ "Create", "a", "thread", "-", "safe", "proxy", "which", "locks", "every", "method", "call", "for", "the", "given", "client", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L482-L496
24,386
ray-project/ray
python/ray/experimental/array/distributed/core.py
DistArray.assemble
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...
python
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", ")", ":", "first_block", "=", "ray", ".", "get", "(", "self", ".", "objectids", "[", "(", "0", ",", ")", "*", "self", ".", "ndim", "]", ")", "dtype", "=", "first_block", ".", "dtype", "result", "=", "np", ".", "zer...
Assemble an array from a distributed array of object IDs.
[ "Assemble", "an", "array", "from", "a", "distributed", "array", "of", "object", "IDs", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/core.py#L58-L68
24,387
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
multi_log_probs_from_logits_and_actions
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...
python
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", ")", ":", "log_probs", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "policy_logits", ")", ")", ":", "log_probs", ".", "append", "(", "-", "tf", ".", "nn",...
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...
[ "Computes", "action", "log", "-", "probs", "from", "policy", "logits", "and", "actions", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L54-L91
24,388
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
from_logits
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...
python
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", ...
multi_from_logits wrapper used only for tests
[ "multi_from_logits", "wrapper", "used", "only", "for", "tests" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L94-L124
24,389
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
multi_from_logits
def multi_from_logits(behaviour_policy_logits, target_policy_logits, actions, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, ...
python
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", ",", "clip_pg_rho_threshold", "=", "1.0", ",", "n...
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 ...
[ "r", "V", "-", "trace", "for", "softmax", "policies", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L127-L244
24,390
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
get_log_rhos
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_...
python
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", ")", ":", "t", "=", "tf", ".", "stack", "(", "target_action_log_probs", ")", "b", "=", "tf", ".", "stack", "(", "behaviour_action_log_probs", ")", "log_rhos", "=", "tf", "....
With the selected log_probs for multi-discrete actions of behaviour and target policies we compute the log_rhos for calculating the vtrace.
[ "With", "the", "selected", "log_probs", "for", "multi", "-", "discrete", "actions", "of", "behaviour", "and", "target", "policies", "we", "compute", "the", "log_rhos", "for", "calculating", "the", "vtrace", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L389-L395
24,391
ray-project/ray
python/ray/tune/examples/tune_mnist_async_hyperband.py
weight_variable
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)
python
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", ")", ":", "initial", "=", "tf", ".", "truncated_normal", "(", "shape", ",", "stddev", "=", "0.1", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
weight_variable generates a weight variable of a given shape.
[ "weight_variable", "generates", "a", "weight", "variable", "of", "a", "given", "shape", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/tune_mnist_async_hyperband.py#L121-L124
24,392
ray-project/ray
python/ray/tune/examples/tune_mnist_async_hyperband.py
bias_variable
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)
python
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", ")", ":", "initial", "=", "tf", ".", "constant", "(", "0.1", ",", "shape", "=", "shape", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
bias_variable generates a bias variable of a given shape.
[ "bias_variable", "generates", "a", "bias", "variable", "of", "a", "given", "shape", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/tune_mnist_async_hyperband.py#L127-L130
24,393
ray-project/ray
python/ray/tune/commands.py
print_format_output
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 ...
python
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", ")", ":", "print_df", "=", "pd", ".", "DataFrame", "(", ")", "dropped_cols", "=", "[", "]", "empty_cols", "=", "[", "]", "# column display priority is based on the info_keys passed in", "for", "i", ",", "col", "in", ...
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).
[ "Prints", "output", "of", "given", "dataframe", "to", "fit", "into", "terminal", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L72-L108
24,394
ray-project/ray
python/ray/tune/commands.py
add_note
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)...
python
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\"", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "assert", "os", ".", "path", ".", "isdir", "(", "path", ")", ",", "\"{} is not a valid directory.\"", "."...
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"
[ "Opens", "a", "txt", "file", "at", "the", "given", "path", "where", "user", "can", "add", "and", "save", "notes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L312-L333
24,395
ray-project/ray
python/ray/tune/automlboard/frontend/query.py
query_job
def query_job(request): """Rest API to query the job info, with the given job_id. The url pattern should be like this: curl http://<server>:<port>/query_job?job_id=<job_id> The response may be: { "running_trials": 0, "start_time": "2018-07-19 20:49:40", "current_round": 1...
python
def query_job(request): """Rest API to query the job info, with the given job_id. The url pattern should be like this: curl http://<server>:<port>/query_job?job_id=<job_id> The response may be: { "running_trials": 0, "start_time": "2018-07-19 20:49:40", "current_round": 1...
[ "def", "query_job", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "jobs", "=", "JobRecord", ".", "objects", ".", "filter", "(", "job_id", "=", "job_id", ")", "trials", "=", "TrialRecord", ".", "obje...
Rest API to query the job info, with the given job_id. The url pattern should be like this: curl http://<server>:<port>/query_job?job_id=<job_id> The response may be: { "running_trials": 0, "start_time": "2018-07-19 20:49:40", "current_round": 1, "failed_trials": 0, ...
[ "Rest", "API", "to", "query", "the", "job", "info", "with", "the", "given", "job_id", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/query.py#L14-L71
24,396
ray-project/ray
python/ray/tune/automlboard/frontend/query.py
query_trial
def query_trial(request): """Rest API to query the trial info, with the given trial_id. The url pattern should be like this: curl http://<server>:<port>/query_trial?trial_id=<trial_id> The response may be: { "app_url": "None", "trial_status": "TERMINATED", "params": {'a':...
python
def query_trial(request): """Rest API to query the trial info, with the given trial_id. The url pattern should be like this: curl http://<server>:<port>/query_trial?trial_id=<trial_id> The response may be: { "app_url": "None", "trial_status": "TERMINATED", "params": {'a':...
[ "def", "query_trial", "(", "request", ")", ":", "trial_id", "=", "request", ".", "GET", ".", "get", "(", "\"trial_id\"", ")", "trials", "=", "TrialRecord", ".", "objects", ".", "filter", "(", "trial_id", "=", "trial_id", ")", ".", "order_by", "(", "\"-st...
Rest API to query the trial info, with the given trial_id. The url pattern should be like this: curl http://<server>:<port>/query_trial?trial_id=<trial_id> The response may be: { "app_url": "None", "trial_status": "TERMINATED", "params": {'a': 1, 'b': 2}, "job_id": "a...
[ "Rest", "API", "to", "query", "the", "trial", "info", "with", "the", "given", "trial_id", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/query.py#L74-L110
24,397
ray-project/ray
python/ray/tune/schedulers/median_stopping_rule.py
MedianStoppingRule.on_trial_result
def on_trial_result(self, trial_runner, trial, result): """Callback for early stopping. This stopping rule stops a running trial if the trial's best objective value by step `t` is strictly worse than the median of the running averages of all completed trials' objectives reported up to s...
python
def on_trial_result(self, trial_runner, trial, result): """Callback for early stopping. This stopping rule stops a running trial if the trial's best objective value by step `t` is strictly worse than the median of the running averages of all completed trials' objectives reported up to s...
[ "def", "on_trial_result", "(", "self", ",", "trial_runner", ",", "trial", ",", "result", ")", ":", "if", "trial", "in", "self", ".", "_stopped_trials", ":", "assert", "not", "self", ".", "_hard_stop", "return", "TrialScheduler", ".", "CONTINUE", "# fall back t...
Callback for early stopping. This stopping rule stops a running trial if the trial's best objective value by step `t` is strictly worse than the median of the running averages of all completed trials' objectives reported up to step `t`.
[ "Callback", "for", "early", "stopping", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/median_stopping_rule.py#L56-L85
24,398
ray-project/ray
python/ray/tune/schedulers/median_stopping_rule.py
MedianStoppingRule.on_trial_remove
def on_trial_remove(self, trial_runner, trial): """Marks trial as completed if it is paused and has previously ran.""" if trial.status is Trial.PAUSED and trial in self._results: self._completed_trials.add(trial)
python
def on_trial_remove(self, trial_runner, trial): """Marks trial as completed if it is paused and has previously ran.""" if trial.status is Trial.PAUSED and trial in self._results: self._completed_trials.add(trial)
[ "def", "on_trial_remove", "(", "self", ",", "trial_runner", ",", "trial", ")", ":", "if", "trial", ".", "status", "is", "Trial", ".", "PAUSED", "and", "trial", "in", "self", ".", "_results", ":", "self", ".", "_completed_trials", ".", "add", "(", "trial"...
Marks trial as completed if it is paused and has previously ran.
[ "Marks", "trial", "as", "completed", "if", "it", "is", "paused", "and", "has", "previously", "ran", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/median_stopping_rule.py#L91-L94
24,399
ray-project/ray
python/ray/tune/automlboard/models/models.py
JobRecord.from_json
def from_json(cls, json_info): """Build a Job instance from a json string.""" if json_info is None: return None return JobRecord( job_id=json_info["job_id"], name=json_info["job_name"], user=json_info["user"], type=json_info["type"], ...
python
def from_json(cls, json_info): """Build a Job instance from a json string.""" if json_info is None: return None return JobRecord( job_id=json_info["job_id"], name=json_info["job_name"], user=json_info["user"], type=json_info["type"], ...
[ "def", "from_json", "(", "cls", ",", "json_info", ")", ":", "if", "json_info", "is", "None", ":", "return", "None", "return", "JobRecord", "(", "job_id", "=", "json_info", "[", "\"job_id\"", "]", ",", "name", "=", "json_info", "[", "\"job_name\"", "]", "...
Build a Job instance from a json string.
[ "Build", "a", "Job", "instance", "from", "a", "json", "string", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L20-L29