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,500
ray-project/ray
python/ray/services.py
create_redis_client
def create_redis_client(redis_address, password=None): """Create a Redis client. Args: The IP address, port, and password of the Redis server. Returns: A Redis client. """ redis_ip_address, redis_port = redis_address.split(":") # For this command to work, some other client (on ...
python
def create_redis_client(redis_address, password=None): """Create a Redis client. Args: The IP address, port, and password of the Redis server. Returns: A Redis client. """ redis_ip_address, redis_port = redis_address.split(":") # For this command to work, some other client (on ...
[ "def", "create_redis_client", "(", "redis_address", ",", "password", "=", "None", ")", ":", "redis_ip_address", ",", "redis_port", "=", "redis_address", ".", "split", "(", "\":\"", ")", "# For this command to work, some other client (on the same machine", "# as Redis) must ...
Create a Redis client. Args: The IP address, port, and password of the Redis server. Returns: A Redis client.
[ "Create", "a", "Redis", "client", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L229-L242
24,501
ray-project/ray
python/ray/services.py
wait_for_redis_to_start
def wait_for_redis_to_start(redis_ip_address, redis_port, password=None, num_retries=5): """Wait for a Redis server to be available. This is accomplished by creating a Redis client and sending a random command to the server...
python
def wait_for_redis_to_start(redis_ip_address, redis_port, password=None, num_retries=5): """Wait for a Redis server to be available. This is accomplished by creating a Redis client and sending a random command to the server...
[ "def", "wait_for_redis_to_start", "(", "redis_ip_address", ",", "redis_port", ",", "password", "=", "None", ",", "num_retries", "=", "5", ")", ":", "redis_client", "=", "redis", ".", "StrictRedis", "(", "host", "=", "redis_ip_address", ",", "port", "=", "redis...
Wait for a Redis server to be available. This is accomplished by creating a Redis client and sending a random command to the server until the command gets through. Args: redis_ip_address (str): The IP address of the redis server. redis_port (int): The port of the redis server. pass...
[ "Wait", "for", "a", "Redis", "server", "to", "be", "available", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L381-L421
24,502
ray-project/ray
python/ray/services.py
_autodetect_num_gpus
def _autodetect_num_gpus(): """Attempt to detect the number of GPUs on this machine. TODO(rkn): This currently assumes Nvidia GPUs and Linux. Returns: The number of GPUs if any were detected, otherwise 0. """ proc_gpus_path = "/proc/driver/nvidia/gpus" if os.path.isdir(proc_gpus_path):...
python
def _autodetect_num_gpus(): """Attempt to detect the number of GPUs on this machine. TODO(rkn): This currently assumes Nvidia GPUs and Linux. Returns: The number of GPUs if any were detected, otherwise 0. """ proc_gpus_path = "/proc/driver/nvidia/gpus" if os.path.isdir(proc_gpus_path):...
[ "def", "_autodetect_num_gpus", "(", ")", ":", "proc_gpus_path", "=", "\"/proc/driver/nvidia/gpus\"", "if", "os", ".", "path", ".", "isdir", "(", "proc_gpus_path", ")", ":", "return", "len", "(", "os", ".", "listdir", "(", "proc_gpus_path", ")", ")", "return", ...
Attempt to detect the number of GPUs on this machine. TODO(rkn): This currently assumes Nvidia GPUs and Linux. Returns: The number of GPUs if any were detected, otherwise 0.
[ "Attempt", "to", "detect", "the", "number", "of", "GPUs", "on", "this", "machine", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L424-L435
24,503
ray-project/ray
python/ray/services.py
_compute_version_info
def _compute_version_info(): """Compute the versions of Python, pyarrow, and Ray. Returns: A tuple containing the version information. """ ray_version = ray.__version__ python_version = ".".join(map(str, sys.version_info[:3])) pyarrow_version = pyarrow.__version__ return ray_version...
python
def _compute_version_info(): """Compute the versions of Python, pyarrow, and Ray. Returns: A tuple containing the version information. """ ray_version = ray.__version__ python_version = ".".join(map(str, sys.version_info[:3])) pyarrow_version = pyarrow.__version__ return ray_version...
[ "def", "_compute_version_info", "(", ")", ":", "ray_version", "=", "ray", ".", "__version__", "python_version", "=", "\".\"", ".", "join", "(", "map", "(", "str", ",", "sys", ".", "version_info", "[", ":", "3", "]", ")", ")", "pyarrow_version", "=", "pya...
Compute the versions of Python, pyarrow, and Ray. Returns: A tuple containing the version information.
[ "Compute", "the", "versions", "of", "Python", "pyarrow", "and", "Ray", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L438-L447
24,504
ray-project/ray
python/ray/services.py
check_version_info
def check_version_info(redis_client): """Check if various version info of this process is correct. This will be used to detect if workers or drivers are started using different versions of Python, pyarrow, or Ray. If the version information is not present in Redis, then no check is done. Args: ...
python
def check_version_info(redis_client): """Check if various version info of this process is correct. This will be used to detect if workers or drivers are started using different versions of Python, pyarrow, or Ray. If the version information is not present in Redis, then no check is done. Args: ...
[ "def", "check_version_info", "(", "redis_client", ")", ":", "redis_reply", "=", "redis_client", ".", "get", "(", "\"VERSION_INFO\"", ")", "# Don't do the check if there is no version information in Redis. This", "# is to make it easier to do things like start the processes by hand.", ...
Check if various version info of this process is correct. This will be used to detect if workers or drivers are started using different versions of Python, pyarrow, or Ray. If the version information is not present in Redis, then no check is done. Args: redis_client: A client for the primary R...
[ "Check", "if", "various", "version", "info", "of", "this", "process", "is", "correct", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L462-L498
24,505
ray-project/ray
python/ray/services.py
_start_redis_instance
def _start_redis_instance(executable, modules, port=None, redis_max_clients=None, num_retries=20, stdout_file=None, stderr_file=None, pass...
python
def _start_redis_instance(executable, modules, port=None, redis_max_clients=None, num_retries=20, stdout_file=None, stderr_file=None, pass...
[ "def", "_start_redis_instance", "(", "executable", ",", "modules", ",", "port", "=", "None", ",", "redis_max_clients", "=", "None", ",", "num_retries", "=", "20", ",", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ",", "password", "=", "None",...
Start a single Redis server. Notes: If "port" is not None, then we will only use this port and try only once. Otherwise, random ports will be used and the maximum retries count is "num_retries". Args: executable (str): Full path of the redis-server executable. modules (...
[ "Start", "a", "single", "Redis", "server", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L703-L841
24,506
ray-project/ray
python/ray/services.py
start_log_monitor
def start_log_monitor(redis_address, logs_dir, stdout_file=None, stderr_file=None, redis_password=None): """Start a log monitor process. Args: redis_address (str): The address of the Redis instance. logs_dir...
python
def start_log_monitor(redis_address, logs_dir, stdout_file=None, stderr_file=None, redis_password=None): """Start a log monitor process. Args: redis_address (str): The address of the Redis instance. logs_dir...
[ "def", "start_log_monitor", "(", "redis_address", ",", "logs_dir", ",", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ",", "redis_password", "=", "None", ")", ":", "log_monitor_filepath", "=", "os", ".", "path", ".", "join", "(", "os", ".", ...
Start a log monitor process. Args: redis_address (str): The address of the Redis instance. logs_dir (str): The directory of logging files. stdout_file: A file handle opened for writing to redirect stdout to. If no redirection should happen, then this should be None. stde...
[ "Start", "a", "log", "monitor", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L844-L877
24,507
ray-project/ray
python/ray/services.py
start_reporter
def start_reporter(redis_address, stdout_file=None, stderr_file=None, redis_password=None): """Start a reporter process. Args: redis_address (str): The address of the Redis instance. stdout_file: A file handle opened for writing to redire...
python
def start_reporter(redis_address, stdout_file=None, stderr_file=None, redis_password=None): """Start a reporter process. Args: redis_address (str): The address of the Redis instance. stdout_file: A file handle opened for writing to redire...
[ "def", "start_reporter", "(", "redis_address", ",", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ",", "redis_password", "=", "None", ")", ":", "reporter_filepath", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname",...
Start a reporter process. Args: redis_address (str): The address of the Redis instance. stdout_file: A file handle opened for writing to redirect stdout to. If no redirection should happen, then this should be None. stderr_file: A file handle opened for writing to redirect stder...
[ "Start", "a", "reporter", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L880-L918
24,508
ray-project/ray
python/ray/services.py
start_dashboard
def start_dashboard(redis_address, temp_dir, stdout_file=None, stderr_file=None, redis_password=None): """Start a dashboard process. Args: redis_address (str): The address of the Redis instance. temp_dir (str): The ...
python
def start_dashboard(redis_address, temp_dir, stdout_file=None, stderr_file=None, redis_password=None): """Start a dashboard process. Args: redis_address (str): The address of the Redis instance. temp_dir (str): The ...
[ "def", "start_dashboard", "(", "redis_address", ",", "temp_dir", ",", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ",", "redis_password", "=", "None", ")", ":", "port", "=", "8080", "while", "True", ":", "try", ":", "port_test_socket", "=", ...
Start a dashboard process. Args: redis_address (str): The address of the Redis instance. temp_dir (str): The temporary directory used for log files and information for this Ray session. stdout_file: A file handle opened for writing to redirect stdout to. If no redire...
[ "Start", "a", "dashboard", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L921-L987
24,509
ray-project/ray
python/ray/services.py
check_and_update_resources
def check_and_update_resources(num_cpus, num_gpus, resources): """Sanity check a resource dictionary and add sensible defaults. Args: num_cpus: The number of CPUs. num_gpus: The number of GPUs. resources: A dictionary mapping resource names to resource quantities. Returns: ...
python
def check_and_update_resources(num_cpus, num_gpus, resources): """Sanity check a resource dictionary and add sensible defaults. Args: num_cpus: The number of CPUs. num_gpus: The number of GPUs. resources: A dictionary mapping resource names to resource quantities. Returns: ...
[ "def", "check_and_update_resources", "(", "num_cpus", ",", "num_gpus", ",", "resources", ")", ":", "if", "resources", "is", "None", ":", "resources", "=", "{", "}", "resources", "=", "resources", ".", "copy", "(", ")", "assert", "\"CPU\"", "not", "in", "re...
Sanity check a resource dictionary and add sensible defaults. Args: num_cpus: The number of CPUs. num_gpus: The number of GPUs. resources: A dictionary mapping resource names to resource quantities. Returns: A new resource dictionary.
[ "Sanity", "check", "a", "resource", "dictionary", "and", "add", "sensible", "defaults", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L990-L1057
24,510
ray-project/ray
python/ray/services.py
start_raylet
def start_raylet(redis_address, node_ip_address, raylet_name, plasma_store_name, worker_path, temp_dir, num_cpus=None, num_gpus=None, resources=None, object_manager_po...
python
def start_raylet(redis_address, node_ip_address, raylet_name, plasma_store_name, worker_path, temp_dir, num_cpus=None, num_gpus=None, resources=None, object_manager_po...
[ "def", "start_raylet", "(", "redis_address", ",", "node_ip_address", ",", "raylet_name", ",", "plasma_store_name", ",", "worker_path", ",", "temp_dir", ",", "num_cpus", "=", "None", ",", "num_gpus", "=", "None", ",", "resources", "=", "None", ",", "object_manage...
Start a raylet, which is a combined local scheduler and object manager. Args: redis_address (str): The address of the primary Redis server. node_ip_address (str): The IP address of this node. raylet_name (str): The name of the raylet socket to create. plasma_store_name (str): The na...
[ "Start", "a", "raylet", "which", "is", "a", "combined", "local", "scheduler", "and", "object", "manager", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L1060-L1206
24,511
ray-project/ray
python/ray/services.py
build_java_worker_command
def build_java_worker_command( java_worker_options, redis_address, plasma_store_name, raylet_name, redis_password, temp_dir, ): """This method assembles the command used to start a Java worker. Args: java_worker_options (str): The command options for Java...
python
def build_java_worker_command( java_worker_options, redis_address, plasma_store_name, raylet_name, redis_password, temp_dir, ): """This method assembles the command used to start a Java worker. Args: java_worker_options (str): The command options for Java...
[ "def", "build_java_worker_command", "(", "java_worker_options", ",", "redis_address", ",", "plasma_store_name", ",", "raylet_name", ",", "redis_password", ",", "temp_dir", ",", ")", ":", "assert", "java_worker_options", "is", "not", "None", "command", "=", "\"java \""...
This method assembles the command used to start a Java worker. Args: java_worker_options (str): The command options for Java worker. redis_address (str): Redis address of GCS. plasma_store_name (str): The name of the plasma store socket to connect to. raylet_name (str): T...
[ "This", "method", "assembles", "the", "command", "used", "to", "start", "a", "Java", "worker", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L1209-L1256
24,512
ray-project/ray
python/ray/services.py
determine_plasma_store_config
def determine_plasma_store_config(object_store_memory=None, plasma_directory=None, huge_pages=False): """Figure out how to configure the plasma object store. This will determine which directory to use for the plasma store (e.g., /tmp or /d...
python
def determine_plasma_store_config(object_store_memory=None, plasma_directory=None, huge_pages=False): """Figure out how to configure the plasma object store. This will determine which directory to use for the plasma store (e.g., /tmp or /d...
[ "def", "determine_plasma_store_config", "(", "object_store_memory", "=", "None", ",", "plasma_directory", "=", "None", ",", "huge_pages", "=", "False", ")", ":", "system_memory", "=", "ray", ".", "utils", ".", "get_system_memory", "(", ")", "# Choose a default objec...
Figure out how to configure the plasma object store. This will determine which directory to use for the plasma store (e.g., /tmp or /dev/shm) and how much memory to start the store with. On Linux, we will try to use /dev/shm unless the shared memory file system is too small, in which case we will fall ...
[ "Figure", "out", "how", "to", "configure", "the", "plasma", "object", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L1259-L1337
24,513
ray-project/ray
python/ray/services.py
_start_plasma_store
def _start_plasma_store(plasma_store_memory, use_valgrind=False, use_profiler=False, stdout_file=None, stderr_file=None, plasma_directory=None, huge_pages=False, ...
python
def _start_plasma_store(plasma_store_memory, use_valgrind=False, use_profiler=False, stdout_file=None, stderr_file=None, plasma_directory=None, huge_pages=False, ...
[ "def", "_start_plasma_store", "(", "plasma_store_memory", ",", "use_valgrind", "=", "False", ",", "use_profiler", "=", "False", ",", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ",", "plasma_directory", "=", "None", ",", "huge_pages", "=", "False...
Start a plasma store process. Args: plasma_store_memory (int): The amount of memory in bytes to start the plasma store with. use_valgrind (bool): True if the plasma store should be started inside of valgrind. If this is True, use_profiler must be False. use_profiler ...
[ "Start", "a", "plasma", "store", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L1340-L1402
24,514
ray-project/ray
python/ray/services.py
start_plasma_store
def start_plasma_store(stdout_file=None, stderr_file=None, object_store_memory=None, plasma_directory=None, huge_pages=False, plasma_store_socket_name=None): """This method starts an object store proce...
python
def start_plasma_store(stdout_file=None, stderr_file=None, object_store_memory=None, plasma_directory=None, huge_pages=False, plasma_store_socket_name=None): """This method starts an object store proce...
[ "def", "start_plasma_store", "(", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ",", "object_store_memory", "=", "None", ",", "plasma_directory", "=", "None", ",", "huge_pages", "=", "False", ",", "plasma_store_socket_name", "=", "None", ")", ":",...
This method starts an object store process. Args: stdout_file: A file handle opened for writing to redirect stdout to. If no redirection should happen, then this should be None. stderr_file: A file handle opened for writing to redirect stderr to. If no redirection should hap...
[ "This", "method", "starts", "an", "object", "store", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L1405-L1452
24,515
ray-project/ray
python/ray/services.py
start_worker
def start_worker(node_ip_address, object_store_name, raylet_name, redis_address, worker_path, temp_dir, stdout_file=None, stderr_file=None): """This method starts a worker process. Args: ...
python
def start_worker(node_ip_address, object_store_name, raylet_name, redis_address, worker_path, temp_dir, stdout_file=None, stderr_file=None): """This method starts a worker process. Args: ...
[ "def", "start_worker", "(", "node_ip_address", ",", "object_store_name", ",", "raylet_name", ",", "redis_address", ",", "worker_path", ",", "temp_dir", ",", "stdout_file", "=", "None", ",", "stderr_file", "=", "None", ")", ":", "command", "=", "[", "sys", ".",...
This method starts a worker process. Args: node_ip_address (str): The IP address of the node that this worker is running on. object_store_name (str): The socket name of the object store. raylet_name (str): The socket name of the raylet server. redis_address (str): The ad...
[ "This", "method", "starts", "a", "worker", "process", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/services.py#L1455-L1494
24,516
ray-project/ray
python/ray/rllib/models/model.py
restore_original_dimensions
def restore_original_dimensions(obs, obs_space, tensorlib=tf): """Unpacks Dict and Tuple space observations into their original form. This is needed since we flatten Dict and Tuple observations in transit. Before sending them to the model though, we should unflatten them into Dicts or Tuples of tensors...
python
def restore_original_dimensions(obs, obs_space, tensorlib=tf): """Unpacks Dict and Tuple space observations into their original form. This is needed since we flatten Dict and Tuple observations in transit. Before sending them to the model though, we should unflatten them into Dicts or Tuples of tensors...
[ "def", "restore_original_dimensions", "(", "obs", ",", "obs_space", ",", "tensorlib", "=", "tf", ")", ":", "if", "hasattr", "(", "obs_space", ",", "\"original_space\"", ")", ":", "return", "_unpack_obs", "(", "obs", ",", "obs_space", ".", "original_space", ","...
Unpacks Dict and Tuple space observations into their original form. This is needed since we flatten Dict and Tuple observations in transit. Before sending them to the model though, we should unflatten them into Dicts or Tuples of tensors. Arguments: obs: The flattened observation tensor. ...
[ "Unpacks", "Dict", "and", "Tuple", "space", "observations", "into", "their", "original", "form", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/model.py#L208-L229
24,517
ray-project/ray
python/ray/autoscaler/aws/node_provider.py
to_aws_format
def to_aws_format(tags): """Convert the Ray node name tag to the AWS-specific 'Name' tag.""" if TAG_RAY_NODE_NAME in tags: tags["Name"] = tags[TAG_RAY_NODE_NAME] del tags[TAG_RAY_NODE_NAME] return tags
python
def to_aws_format(tags): """Convert the Ray node name tag to the AWS-specific 'Name' tag.""" if TAG_RAY_NODE_NAME in tags: tags["Name"] = tags[TAG_RAY_NODE_NAME] del tags[TAG_RAY_NODE_NAME] return tags
[ "def", "to_aws_format", "(", "tags", ")", ":", "if", "TAG_RAY_NODE_NAME", "in", "tags", ":", "tags", "[", "\"Name\"", "]", "=", "tags", "[", "TAG_RAY_NODE_NAME", "]", "del", "tags", "[", "TAG_RAY_NODE_NAME", "]", "return", "tags" ]
Convert the Ray node name tag to the AWS-specific 'Name' tag.
[ "Convert", "the", "Ray", "node", "name", "tag", "to", "the", "AWS", "-", "specific", "Name", "tag", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/aws/node_provider.py#L18-L24
24,518
ray-project/ray
python/ray/autoscaler/aws/node_provider.py
AWSNodeProvider._node_tag_update_loop
def _node_tag_update_loop(self): """ Update the AWS tags for a cluster periodically. The purpose of this loop is to avoid excessive EC2 calls when a large number of nodes are being launched simultaneously. """ while True: self.tag_cache_update_event.wait() ...
python
def _node_tag_update_loop(self): """ Update the AWS tags for a cluster periodically. The purpose of this loop is to avoid excessive EC2 calls when a large number of nodes are being launched simultaneously. """ while True: self.tag_cache_update_event.wait() ...
[ "def", "_node_tag_update_loop", "(", "self", ")", ":", "while", "True", ":", "self", ".", "tag_cache_update_event", ".", "wait", "(", ")", "self", ".", "tag_cache_update_event", ".", "clear", "(", ")", "batch_updates", "=", "defaultdict", "(", "list", ")", "...
Update the AWS tags for a cluster periodically. The purpose of this loop is to avoid excessive EC2 calls when a large number of nodes are being launched simultaneously.
[ "Update", "the", "AWS", "tags", "for", "a", "cluster", "periodically", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/aws/node_provider.py#L59-L94
24,519
ray-project/ray
python/ray/autoscaler/aws/node_provider.py
AWSNodeProvider._get_node
def _get_node(self, node_id): """Refresh and get info for this node, updating the cache.""" self.non_terminated_nodes({}) # Side effect: updates cache if node_id in self.cached_nodes: return self.cached_nodes[node_id] # Node not in {pending, running} -- retry with a point ...
python
def _get_node(self, node_id): """Refresh and get info for this node, updating the cache.""" self.non_terminated_nodes({}) # Side effect: updates cache if node_id in self.cached_nodes: return self.cached_nodes[node_id] # Node not in {pending, running} -- retry with a point ...
[ "def", "_get_node", "(", "self", ",", "node_id", ")", ":", "self", ".", "non_terminated_nodes", "(", "{", "}", ")", "# Side effect: updates cache", "if", "node_id", "in", "self", ".", "cached_nodes", ":", "return", "self", ".", "cached_nodes", "[", "node_id", ...
Refresh and get info for this node, updating the cache.
[ "Refresh", "and", "get", "info", "for", "this", "node", "updating", "the", "cache", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/aws/node_provider.py#L231-L242
24,520
ray-project/ray
python/ray/tune/trial.py
ExportFormat.validate
def validate(export_formats): """Validates export_formats. Raises: ValueError if the format is unknown. """ for i in range(len(export_formats)): export_formats[i] = export_formats[i].strip().lower() if export_formats[i] not in [ Ex...
python
def validate(export_formats): """Validates export_formats. Raises: ValueError if the format is unknown. """ for i in range(len(export_formats)): export_formats[i] = export_formats[i].strip().lower() if export_formats[i] not in [ Ex...
[ "def", "validate", "(", "export_formats", ")", ":", "for", "i", "in", "range", "(", "len", "(", "export_formats", ")", ")", ":", "export_formats", "[", "i", "]", "=", "export_formats", "[", "i", "]", ".", "strip", "(", ")", ".", "lower", "(", ")", ...
Validates export_formats. Raises: ValueError if the format is unknown.
[ "Validates", "export_formats", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L215-L227
24,521
ray-project/ray
python/ray/tune/trial.py
Trial.init_logger
def init_logger(self): """Init logger.""" if not self.result_logger: if not os.path.exists(self.local_dir): os.makedirs(self.local_dir) if not self.logdir: self.logdir = tempfile.mkdtemp( prefix="{}_{}".format( ...
python
def init_logger(self): """Init logger.""" if not self.result_logger: if not os.path.exists(self.local_dir): os.makedirs(self.local_dir) if not self.logdir: self.logdir = tempfile.mkdtemp( prefix="{}_{}".format( ...
[ "def", "init_logger", "(", "self", ")", ":", "if", "not", "self", ".", "result_logger", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "local_dir", ")", ":", "os", ".", "makedirs", "(", "self", ".", "local_dir", ")", "if", "n...
Init logger.
[ "Init", "logger", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L346-L365
24,522
ray-project/ray
python/ray/tune/trial.py
Trial.should_stop
def should_stop(self, result): """Whether the given result meets this trial's stopping criteria.""" if result.get(DONE): return True for criteria, stop_value in self.stopping_criterion.items(): if criteria not in result: raise TuneError( ...
python
def should_stop(self, result): """Whether the given result meets this trial's stopping criteria.""" if result.get(DONE): return True for criteria, stop_value in self.stopping_criterion.items(): if criteria not in result: raise TuneError( ...
[ "def", "should_stop", "(", "self", ",", "result", ")", ":", "if", "result", ".", "get", "(", "DONE", ")", ":", "return", "True", "for", "criteria", ",", "stop_value", "in", "self", ".", "stopping_criterion", ".", "items", "(", ")", ":", "if", "criteria...
Whether the given result meets this trial's stopping criteria.
[ "Whether", "the", "given", "result", "meets", "this", "trial", "s", "stopping", "criteria", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L403-L417
24,523
ray-project/ray
python/ray/tune/trial.py
Trial.should_checkpoint
def should_checkpoint(self): """Whether this trial is due for checkpointing.""" result = self.last_result or {} if result.get(DONE) and self.checkpoint_at_end: return True if self.checkpoint_freq: return result.get(TRAINING_ITERATION, ...
python
def should_checkpoint(self): """Whether this trial is due for checkpointing.""" result = self.last_result or {} if result.get(DONE) and self.checkpoint_at_end: return True if self.checkpoint_freq: return result.get(TRAINING_ITERATION, ...
[ "def", "should_checkpoint", "(", "self", ")", ":", "result", "=", "self", ".", "last_result", "or", "{", "}", "if", "result", ".", "get", "(", "DONE", ")", "and", "self", ".", "checkpoint_at_end", ":", "return", "True", "if", "self", ".", "checkpoint_fre...
Whether this trial is due for checkpointing.
[ "Whether", "this", "trial", "is", "due", "for", "checkpointing", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L419-L430
24,524
ray-project/ray
python/ray/tune/trial.py
Trial.progress_string
def progress_string(self): """Returns a progress message for printing out to the console.""" if not self.last_result: return self._status_string() def location_string(hostname, pid): if hostname == os.uname()[1]: return "pid={}".format(pid) e...
python
def progress_string(self): """Returns a progress message for printing out to the console.""" if not self.last_result: return self._status_string() def location_string(hostname, pid): if hostname == os.uname()[1]: return "pid={}".format(pid) e...
[ "def", "progress_string", "(", "self", ")", ":", "if", "not", "self", ".", "last_result", ":", "return", "self", ".", "_status_string", "(", ")", "def", "location_string", "(", "hostname", ",", "pid", ")", ":", "if", "hostname", "==", "os", ".", "uname",...
Returns a progress message for printing out to the console.
[ "Returns", "a", "progress", "message", "for", "printing", "out", "to", "the", "console", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L432-L472
24,525
ray-project/ray
python/ray/tune/trial.py
Trial.should_recover
def should_recover(self): """Returns whether the trial qualifies for restoring. This is if a checkpoint frequency is set and has not failed more than max_failures. This may return true even when there may not yet be a checkpoint. """ return (self.checkpoint_freq > 0 ...
python
def should_recover(self): """Returns whether the trial qualifies for restoring. This is if a checkpoint frequency is set and has not failed more than max_failures. This may return true even when there may not yet be a checkpoint. """ return (self.checkpoint_freq > 0 ...
[ "def", "should_recover", "(", "self", ")", ":", "return", "(", "self", ".", "checkpoint_freq", ">", "0", "and", "(", "self", ".", "num_failures", "<", "self", ".", "max_failures", "or", "self", ".", "max_failures", "<", "0", ")", ")" ]
Returns whether the trial qualifies for restoring. This is if a checkpoint frequency is set and has not failed more than max_failures. This may return true even when there may not yet be a checkpoint.
[ "Returns", "whether", "the", "trial", "qualifies", "for", "restoring", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L486-L495
24,526
ray-project/ray
python/ray/tune/trial.py
Trial.compare_checkpoints
def compare_checkpoints(self, attr_mean): """Compares two checkpoints based on the attribute attr_mean param. Greater than is used by default. If command-line parameter checkpoint_score_attr starts with "min-" less than is used. Arguments: attr_mean: mean of attribute value...
python
def compare_checkpoints(self, attr_mean): """Compares two checkpoints based on the attribute attr_mean param. Greater than is used by default. If command-line parameter checkpoint_score_attr starts with "min-" less than is used. Arguments: attr_mean: mean of attribute value...
[ "def", "compare_checkpoints", "(", "self", ",", "attr_mean", ")", ":", "if", "self", ".", "_cmp_greater", "and", "attr_mean", ">", "self", ".", "best_checkpoint_attr_value", ":", "return", "True", "elif", "(", "not", "self", ".", "_cmp_greater", "and", "attr_m...
Compares two checkpoints based on the attribute attr_mean param. Greater than is used by default. If command-line parameter checkpoint_score_attr starts with "min-" less than is used. Arguments: attr_mean: mean of attribute value for the current checkpoint Returns: ...
[ "Compares", "two", "checkpoints", "based", "on", "the", "attribute", "attr_mean", "param", ".", "Greater", "than", "is", "used", "by", "default", ".", "If", "command", "-", "line", "parameter", "checkpoint_score_attr", "starts", "with", "min", "-", "less", "th...
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L509-L529
24,527
ray-project/ray
examples/rl_pong/driver.py
discount_rewards
def discount_rewards(r): """take 1D float array of rewards and compute discounted reward""" discounted_r = np.zeros_like(r) running_add = 0 for t in reversed(range(0, r.size)): # Reset the sum, since this was a game boundary (pong specific!). if r[t] != 0: running_add = 0 ...
python
def discount_rewards(r): """take 1D float array of rewards and compute discounted reward""" discounted_r = np.zeros_like(r) running_add = 0 for t in reversed(range(0, r.size)): # Reset the sum, since this was a game boundary (pong specific!). if r[t] != 0: running_add = 0 ...
[ "def", "discount_rewards", "(", "r", ")", ":", "discounted_r", "=", "np", ".", "zeros_like", "(", "r", ")", "running_add", "=", "0", "for", "t", "in", "reversed", "(", "range", "(", "0", ",", "r", ".", "size", ")", ")", ":", "# Reset the sum, since thi...
take 1D float array of rewards and compute discounted reward
[ "take", "1D", "float", "array", "of", "rewards", "and", "compute", "discounted", "reward" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/rl_pong/driver.py#L50-L60
24,528
ray-project/ray
python/ray/autoscaler/node_provider.py
load_class
def load_class(path): """ Load a class at runtime given a full path. Example of the path: mypkg.mysubpkg.myclass """ class_data = path.split(".") if len(class_data) < 2: raise ValueError( "You need to pass a valid path like mymodule.provider_class") module_path = ".".joi...
python
def load_class(path): """ Load a class at runtime given a full path. Example of the path: mypkg.mysubpkg.myclass """ class_data = path.split(".") if len(class_data) < 2: raise ValueError( "You need to pass a valid path like mymodule.provider_class") module_path = ".".joi...
[ "def", "load_class", "(", "path", ")", ":", "class_data", "=", "path", ".", "split", "(", "\".\"", ")", "if", "len", "(", "class_data", ")", "<", "2", ":", "raise", "ValueError", "(", "\"You need to pass a valid path like mymodule.provider_class\"", ")", "module...
Load a class at runtime given a full path. Example of the path: mypkg.mysubpkg.myclass
[ "Load", "a", "class", "at", "runtime", "given", "a", "full", "path", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/node_provider.py#L76-L89
24,529
ray-project/ray
python/ray/autoscaler/node_provider.py
NodeProvider.terminate_nodes
def terminate_nodes(self, node_ids): """Terminates a set of nodes. May be overridden with a batch method.""" for node_id in node_ids: logger.info("NodeProvider: " "{}: Terminating node".format(node_id)) self.terminate_node(node_id)
python
def terminate_nodes(self, node_ids): """Terminates a set of nodes. May be overridden with a batch method.""" for node_id in node_ids: logger.info("NodeProvider: " "{}: Terminating node".format(node_id)) self.terminate_node(node_id)
[ "def", "terminate_nodes", "(", "self", ",", "node_ids", ")", ":", "for", "node_id", "in", "node_ids", ":", "logger", ".", "info", "(", "\"NodeProvider: \"", "\"{}: Terminating node\"", ".", "format", "(", "node_id", ")", ")", "self", ".", "terminate_node", "("...
Terminates a set of nodes. May be overridden with a batch method.
[ "Terminates", "a", "set", "of", "nodes", ".", "May", "be", "overridden", "with", "a", "batch", "method", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/node_provider.py#L181-L186
24,530
ray-project/ray
python/ray/tune/suggest/bayesopt.py
BayesOptSearch.on_trial_complete
def on_trial_complete(self, trial_id, result=None, error=False, early_terminated=False): """Passes the result to BayesOpt unless early terminated or errored""" if result: self.optimizer.re...
python
def on_trial_complete(self, trial_id, result=None, error=False, early_terminated=False): """Passes the result to BayesOpt unless early terminated or errored""" if result: self.optimizer.re...
[ "def", "on_trial_complete", "(", "self", ",", "trial_id", ",", "result", "=", "None", ",", "error", "=", "False", ",", "early_terminated", "=", "False", ")", ":", "if", "result", ":", "self", ".", "optimizer", ".", "register", "(", "params", "=", "self",...
Passes the result to BayesOpt unless early terminated or errored
[ "Passes", "the", "result", "to", "BayesOpt", "unless", "early", "terminated", "or", "errored" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/bayesopt.py#L79-L90
24,531
ray-project/ray
python/ray/experimental/serve/mixin.py
_execute_and_seal_error
def _execute_and_seal_error(method, arg, method_name): """Execute method with arg and return the result. If the method fails, return a RayTaskError so it can be sealed in the resultOID and retried by user. """ try: return method(arg) except Exception: return ray.worker.RayTaskEr...
python
def _execute_and_seal_error(method, arg, method_name): """Execute method with arg and return the result. If the method fails, return a RayTaskError so it can be sealed in the resultOID and retried by user. """ try: return method(arg) except Exception: return ray.worker.RayTaskEr...
[ "def", "_execute_and_seal_error", "(", "method", ",", "arg", ",", "method_name", ")", ":", "try", ":", "return", "method", "(", "arg", ")", "except", "Exception", ":", "return", "ray", ".", "worker", ".", "RayTaskError", "(", "method_name", ",", "traceback",...
Execute method with arg and return the result. If the method fails, return a RayTaskError so it can be sealed in the resultOID and retried by user.
[ "Execute", "method", "with", "arg", "and", "return", "the", "result", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/serve/mixin.py#L21-L30
24,532
ray-project/ray
python/ray/experimental/serve/mixin.py
RayServeMixin._dispatch
def _dispatch(self, input_batch: List[SingleQuery]): """Helper method to dispatch a batch of input to self.serve_method.""" method = getattr(self, self.serve_method) if hasattr(method, "ray_serve_batched_input"): batch = [inp.data for inp in input_batch] result = _execute...
python
def _dispatch(self, input_batch: List[SingleQuery]): """Helper method to dispatch a batch of input to self.serve_method.""" method = getattr(self, self.serve_method) if hasattr(method, "ray_serve_batched_input"): batch = [inp.data for inp in input_batch] result = _execute...
[ "def", "_dispatch", "(", "self", ",", "input_batch", ":", "List", "[", "SingleQuery", "]", ")", ":", "method", "=", "getattr", "(", "self", ",", "self", ".", "serve_method", ")", "if", "hasattr", "(", "method", ",", "\"ray_serve_batched_input\"", ")", ":",...
Helper method to dispatch a batch of input to self.serve_method.
[ "Helper", "method", "to", "dispatch", "a", "batch", "of", "input", "to", "self", ".", "serve_method", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/serve/mixin.py#L50-L63
24,533
ray-project/ray
python/ray/rllib/env/atari_wrappers.py
get_wrapper_by_cls
def get_wrapper_by_cls(env, cls): """Returns the gym env wrapper of the given class, or None.""" currentenv = env while True: if isinstance(currentenv, cls): return currentenv elif isinstance(currentenv, gym.Wrapper): currentenv = currentenv.env else: ...
python
def get_wrapper_by_cls(env, cls): """Returns the gym env wrapper of the given class, or None.""" currentenv = env while True: if isinstance(currentenv, cls): return currentenv elif isinstance(currentenv, gym.Wrapper): currentenv = currentenv.env else: ...
[ "def", "get_wrapper_by_cls", "(", "env", ",", "cls", ")", ":", "currentenv", "=", "env", "while", "True", ":", "if", "isinstance", "(", "currentenv", ",", "cls", ")", ":", "return", "currentenv", "elif", "isinstance", "(", "currentenv", ",", "gym", ".", ...
Returns the gym env wrapper of the given class, or None.
[ "Returns", "the", "gym", "env", "wrapper", "of", "the", "given", "class", "or", "None", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/env/atari_wrappers.py#L17-L26
24,534
ray-project/ray
python/ray/rllib/env/atari_wrappers.py
wrap_deepmind
def wrap_deepmind(env, dim=84, framestack=True): """Configure environment for DeepMind-style Atari. Note that we assume reward clipping is done outside the wrapper. Args: dim (int): Dimension to resize observations to (dim x dim). framestack (bool): Whether to framestack observations. ...
python
def wrap_deepmind(env, dim=84, framestack=True): """Configure environment for DeepMind-style Atari. Note that we assume reward clipping is done outside the wrapper. Args: dim (int): Dimension to resize observations to (dim x dim). framestack (bool): Whether to framestack observations. ...
[ "def", "wrap_deepmind", "(", "env", ",", "dim", "=", "84", ",", "framestack", "=", "True", ")", ":", "env", "=", "MonitorEnv", "(", "env", ")", "env", "=", "NoopResetEnv", "(", "env", ",", "noop_max", "=", "30", ")", "if", "\"NoFrameskip\"", "in", "e...
Configure environment for DeepMind-style Atari. Note that we assume reward clipping is done outside the wrapper. Args: dim (int): Dimension to resize observations to (dim x dim). framestack (bool): Whether to framestack observations.
[ "Configure", "environment", "for", "DeepMind", "-", "style", "Atari", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/env/atari_wrappers.py#L270-L291
24,535
ray-project/ray
python/ray/rllib/utils/memory.py
ray_get_and_free
def ray_get_and_free(object_ids): """Call ray.get and then queue the object ids for deletion. This function should be used whenever possible in RLlib, to optimize memory usage. The only exception is when an object_id is shared among multiple readers. Args: object_ids (ObjectID|List[ObjectI...
python
def ray_get_and_free(object_ids): """Call ray.get and then queue the object ids for deletion. This function should be used whenever possible in RLlib, to optimize memory usage. The only exception is when an object_id is shared among multiple readers. Args: object_ids (ObjectID|List[ObjectI...
[ "def", "ray_get_and_free", "(", "object_ids", ")", ":", "global", "_last_free_time", "global", "_to_free", "result", "=", "ray", ".", "get", "(", "object_ids", ")", "if", "type", "(", "object_ids", ")", "is", "not", "list", ":", "object_ids", "=", "[", "ob...
Call ray.get and then queue the object ids for deletion. This function should be used whenever possible in RLlib, to optimize memory usage. The only exception is when an object_id is shared among multiple readers. Args: object_ids (ObjectID|List[ObjectID]): Object ids to fetch and free. R...
[ "Call", "ray", ".", "get", "and", "then", "queue", "the", "object", "ids", "for", "deletion", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/memory.py#L16-L46
24,536
ray-project/ray
python/ray/rllib/utils/memory.py
aligned_array
def aligned_array(size, dtype, align=64): """Returns an array of a given size that is 64-byte aligned. The returned array can be efficiently copied into GPU memory by TensorFlow. """ n = size * dtype.itemsize empty = np.empty(n + (align - 1), dtype=np.uint8) data_align = empty.ctypes.data % al...
python
def aligned_array(size, dtype, align=64): """Returns an array of a given size that is 64-byte aligned. The returned array can be efficiently copied into GPU memory by TensorFlow. """ n = size * dtype.itemsize empty = np.empty(n + (align - 1), dtype=np.uint8) data_align = empty.ctypes.data % al...
[ "def", "aligned_array", "(", "size", ",", "dtype", ",", "align", "=", "64", ")", ":", "n", "=", "size", "*", "dtype", ".", "itemsize", "empty", "=", "np", ".", "empty", "(", "n", "+", "(", "align", "-", "1", ")", ",", "dtype", "=", "np", ".", ...
Returns an array of a given size that is 64-byte aligned. The returned array can be efficiently copied into GPU memory by TensorFlow.
[ "Returns", "an", "array", "of", "a", "given", "size", "that", "is", "64", "-", "byte", "aligned", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/memory.py#L49-L63
24,537
ray-project/ray
python/ray/rllib/utils/memory.py
concat_aligned
def concat_aligned(items): """Concatenate arrays, ensuring the output is 64-byte aligned. We only align float arrays; other arrays are concatenated as normal. This should be used instead of np.concatenate() to improve performance when the output array is likely to be fed into TensorFlow. """ ...
python
def concat_aligned(items): """Concatenate arrays, ensuring the output is 64-byte aligned. We only align float arrays; other arrays are concatenated as normal. This should be used instead of np.concatenate() to improve performance when the output array is likely to be fed into TensorFlow. """ ...
[ "def", "concat_aligned", "(", "items", ")", ":", "if", "len", "(", "items", ")", "==", "0", ":", "return", "[", "]", "elif", "len", "(", "items", ")", "==", "1", ":", "# we assume the input is aligned. In any case, it doesn't help", "# performance to force align i...
Concatenate arrays, ensuring the output is 64-byte aligned. We only align float arrays; other arrays are concatenated as normal. This should be used instead of np.concatenate() to improve performance when the output array is likely to be fed into TensorFlow.
[ "Concatenate", "arrays", "ensuring", "the", "output", "is", "64", "-", "byte", "aligned", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/memory.py#L66-L92
24,538
ray-project/ray
python/ray/experimental/queue.py
Queue.get
def get(self, block=True, timeout=None): """Gets an item from the queue. Uses polling if block=True, so there is no guarantee of order if multiple consumers get from the same empty queue. Returns: The next item in the queue. Raises: Empty if the queue i...
python
def get(self, block=True, timeout=None): """Gets an item from the queue. Uses polling if block=True, so there is no guarantee of order if multiple consumers get from the same empty queue. Returns: The next item in the queue. Raises: Empty if the queue i...
[ "def", "get", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "if", "not", "block", ":", "success", ",", "item", "=", "ray", ".", "get", "(", "self", ".", "actor", ".", "get", ".", "remote", "(", ")", ")", "if", ...
Gets an item from the queue. Uses polling if block=True, so there is no guarantee of order if multiple consumers get from the same empty queue. Returns: The next item in the queue. Raises: Empty if the queue is empty and blocking is False.
[ "Gets", "an", "item", "from", "the", "queue", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/queue.py#L81-L115
24,539
ray-project/ray
python/ray/rllib/utils/annotations.py
override
def override(cls): """Annotation for documenting method overrides. Arguments: cls (type): The superclass that provides the overriden method. If this cls does not actually have the method, an error is raised. """ def check_override(method): if method.__name__ not in dir(cls)...
python
def override(cls): """Annotation for documenting method overrides. Arguments: cls (type): The superclass that provides the overriden method. If this cls does not actually have the method, an error is raised. """ def check_override(method): if method.__name__ not in dir(cls)...
[ "def", "override", "(", "cls", ")", ":", "def", "check_override", "(", "method", ")", ":", "if", "method", ".", "__name__", "not", "in", "dir", "(", "cls", ")", ":", "raise", "NameError", "(", "\"{} does not override any method of {}\"", ".", "format", "(", ...
Annotation for documenting method overrides. Arguments: cls (type): The superclass that provides the overriden method. If this cls does not actually have the method, an error is raised.
[ "Annotation", "for", "documenting", "method", "overrides", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/annotations.py#L6-L20
24,540
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler.on_trial_add
def on_trial_add(self, trial_runner, trial): """Adds new trial. On a new trial add, if current bracket is not filled, add to current bracket. Else, if current band is not filled, create new bracket, add to current bracket. Else, create new iteration, create new bracket, add to b...
python
def on_trial_add(self, trial_runner, trial): """Adds new trial. On a new trial add, if current bracket is not filled, add to current bracket. Else, if current band is not filled, create new bracket, add to current bracket. Else, create new iteration, create new bracket, add to b...
[ "def", "on_trial_add", "(", "self", ",", "trial_runner", ",", "trial", ")", ":", "cur_bracket", "=", "self", ".", "_state", "[", "\"bracket\"", "]", "cur_band", "=", "self", ".", "_hyperbands", "[", "self", ".", "_state", "[", "\"band_idx\"", "]", "]", "...
Adds new trial. On a new trial add, if current bracket is not filled, add to current bracket. Else, if current band is not filled, create new bracket, add to current bracket. Else, create new iteration, create new bracket, add to bracket.
[ "Adds", "new", "trial", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L98-L132
24,541
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler._cur_band_filled
def _cur_band_filled(self): """Checks if the current band is filled. The size of the current band should be equal to s_max_1""" cur_band = self._hyperbands[self._state["band_idx"]] return len(cur_band) == self._s_max_1
python
def _cur_band_filled(self): """Checks if the current band is filled. The size of the current band should be equal to s_max_1""" cur_band = self._hyperbands[self._state["band_idx"]] return len(cur_band) == self._s_max_1
[ "def", "_cur_band_filled", "(", "self", ")", ":", "cur_band", "=", "self", ".", "_hyperbands", "[", "self", ".", "_state", "[", "\"band_idx\"", "]", "]", "return", "len", "(", "cur_band", ")", "==", "self", ".", "_s_max_1" ]
Checks if the current band is filled. The size of the current band should be equal to s_max_1
[ "Checks", "if", "the", "current", "band", "is", "filled", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L134-L140
24,542
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler.on_trial_result
def on_trial_result(self, trial_runner, trial, result): """If bracket is finished, all trials will be stopped. If a given trial finishes and bracket iteration is not done, the trial will be paused and resources will be given up. This scheduler will not start trials but will stop trials...
python
def on_trial_result(self, trial_runner, trial, result): """If bracket is finished, all trials will be stopped. If a given trial finishes and bracket iteration is not done, the trial will be paused and resources will be given up. This scheduler will not start trials but will stop trials...
[ "def", "on_trial_result", "(", "self", ",", "trial_runner", ",", "trial", ",", "result", ")", ":", "bracket", ",", "_", "=", "self", ".", "_trial_info", "[", "trial", "]", "bracket", ".", "update_trial_stats", "(", "trial", ",", "result", ")", "if", "bra...
If bracket is finished, all trials will be stopped. If a given trial finishes and bracket iteration is not done, the trial will be paused and resources will be given up. This scheduler will not start trials but will stop trials. The current running trial will not be handled, as...
[ "If", "bracket", "is", "finished", "all", "trials", "will", "be", "stopped", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L142-L159
24,543
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler._process_bracket
def _process_bracket(self, trial_runner, bracket, trial): """This is called whenever a trial makes progress. When all live trials in the bracket have no more iterations left, Trials will be successively halved. If bracket is done, all non-running trials will be stopped and cleaned up, ...
python
def _process_bracket(self, trial_runner, bracket, trial): """This is called whenever a trial makes progress. When all live trials in the bracket have no more iterations left, Trials will be successively halved. If bracket is done, all non-running trials will be stopped and cleaned up, ...
[ "def", "_process_bracket", "(", "self", ",", "trial_runner", ",", "bracket", ",", "trial", ")", ":", "action", "=", "TrialScheduler", ".", "PAUSE", "if", "bracket", ".", "cur_iter_done", "(", ")", ":", "if", "bracket", ".", "finished", "(", ")", ":", "br...
This is called whenever a trial makes progress. When all live trials in the bracket have no more iterations left, Trials will be successively halved. If bracket is done, all non-running trials will be stopped and cleaned up, and during each halving phase, bad trials will be stopped whil...
[ "This", "is", "called", "whenever", "a", "trial", "makes", "progress", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L161-L197
24,544
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler.on_trial_remove
def on_trial_remove(self, trial_runner, trial): """Notification when trial terminates. Trial info is removed from bracket. Triggers halving if bracket is not finished.""" bracket, _ = self._trial_info[trial] bracket.cleanup_trial(trial) if not bracket.finished(): ...
python
def on_trial_remove(self, trial_runner, trial): """Notification when trial terminates. Trial info is removed from bracket. Triggers halving if bracket is not finished.""" bracket, _ = self._trial_info[trial] bracket.cleanup_trial(trial) if not bracket.finished(): ...
[ "def", "on_trial_remove", "(", "self", ",", "trial_runner", ",", "trial", ")", ":", "bracket", ",", "_", "=", "self", ".", "_trial_info", "[", "trial", "]", "bracket", ".", "cleanup_trial", "(", "trial", ")", "if", "not", "bracket", ".", "finished", "(",...
Notification when trial terminates. Trial info is removed from bracket. Triggers halving if bracket is not finished.
[ "Notification", "when", "trial", "terminates", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L199-L207
24,545
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler.choose_trial_to_run
def choose_trial_to_run(self, trial_runner): """Fair scheduling within iteration by completion percentage. List of trials not used since all trials are tracked as state of scheduler. If iteration is occupied (ie, no trials to run), then look into next iteration. """ for...
python
def choose_trial_to_run(self, trial_runner): """Fair scheduling within iteration by completion percentage. List of trials not used since all trials are tracked as state of scheduler. If iteration is occupied (ie, no trials to run), then look into next iteration. """ for...
[ "def", "choose_trial_to_run", "(", "self", ",", "trial_runner", ")", ":", "for", "hyperband", "in", "self", ".", "_hyperbands", ":", "# band will have None entries if no resources", "# are to be allocated to that bracket.", "scrubbed", "=", "[", "b", "for", "b", "in", ...
Fair scheduling within iteration by completion percentage. List of trials not used since all trials are tracked as state of scheduler. If iteration is occupied (ie, no trials to run), then look into next iteration.
[ "Fair", "scheduling", "within", "iteration", "by", "completion", "percentage", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L217-L235
24,546
ray-project/ray
python/ray/tune/schedulers/hyperband.py
HyperBandScheduler.debug_string
def debug_string(self): """This provides a progress notification for the algorithm. For each bracket, the algorithm will output a string as follows: Bracket(Max Size (n)=5, Milestone (r)=33, completed=14.6%): {PENDING: 2, RUNNING: 3, TERMINATED: 2} "Max Size" indicates...
python
def debug_string(self): """This provides a progress notification for the algorithm. For each bracket, the algorithm will output a string as follows: Bracket(Max Size (n)=5, Milestone (r)=33, completed=14.6%): {PENDING: 2, RUNNING: 3, TERMINATED: 2} "Max Size" indicates...
[ "def", "debug_string", "(", "self", ")", ":", "out", "=", "\"Using HyperBand: \"", "out", "+=", "\"num_stopped={} total_brackets={}\"", ".", "format", "(", "self", ".", "_num_stopped", ",", "sum", "(", "len", "(", "band", ")", "for", "band", "in", "self", "....
This provides a progress notification for the algorithm. For each bracket, the algorithm will output a string as follows: Bracket(Max Size (n)=5, Milestone (r)=33, completed=14.6%): {PENDING: 2, RUNNING: 3, TERMINATED: 2} "Max Size" indicates the max number of pending/running ...
[ "This", "provides", "a", "progress", "notification", "for", "the", "algorithm", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L237-L261
24,547
ray-project/ray
python/ray/tune/schedulers/hyperband.py
Bracket.add_trial
def add_trial(self, trial): """Add trial to bracket assuming bracket is not filled. At a later iteration, a newly added trial will be given equal opportunity to catch up.""" assert not self.filled(), "Cannot add trial to filled bracket!" self._live_trials[trial] = None s...
python
def add_trial(self, trial): """Add trial to bracket assuming bracket is not filled. At a later iteration, a newly added trial will be given equal opportunity to catch up.""" assert not self.filled(), "Cannot add trial to filled bracket!" self._live_trials[trial] = None s...
[ "def", "add_trial", "(", "self", ",", "trial", ")", ":", "assert", "not", "self", ".", "filled", "(", ")", ",", "\"Cannot add trial to filled bracket!\"", "self", ".", "_live_trials", "[", "trial", "]", "=", "None", "self", ".", "_all_trials", ".", "append",...
Add trial to bracket assuming bracket is not filled. At a later iteration, a newly added trial will be given equal opportunity to catch up.
[ "Add", "trial", "to", "bracket", "assuming", "bracket", "is", "not", "filled", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L287-L294
24,548
ray-project/ray
python/ray/tune/schedulers/hyperband.py
Bracket.cur_iter_done
def cur_iter_done(self): """Checks if all iterations have completed. TODO(rliaw): also check that `t.iterations == self._r`""" return all( self._get_result_time(result) >= self._cumul_r for result in self._live_trials.values())
python
def cur_iter_done(self): """Checks if all iterations have completed. TODO(rliaw): also check that `t.iterations == self._r`""" return all( self._get_result_time(result) >= self._cumul_r for result in self._live_trials.values())
[ "def", "cur_iter_done", "(", "self", ")", ":", "return", "all", "(", "self", ".", "_get_result_time", "(", "result", ")", ">=", "self", ".", "_cumul_r", "for", "result", "in", "self", ".", "_live_trials", ".", "values", "(", ")", ")" ]
Checks if all iterations have completed. TODO(rliaw): also check that `t.iterations == self._r`
[ "Checks", "if", "all", "iterations", "have", "completed", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L296-L302
24,549
ray-project/ray
python/ray/tune/schedulers/hyperband.py
Bracket.update_trial_stats
def update_trial_stats(self, trial, result): """Update result for trial. Called after trial has finished an iteration - will decrement iteration count. TODO(rliaw): The other alternative is to keep the trials in and make sure they're not set as pending later.""" assert trial in...
python
def update_trial_stats(self, trial, result): """Update result for trial. Called after trial has finished an iteration - will decrement iteration count. TODO(rliaw): The other alternative is to keep the trials in and make sure they're not set as pending later.""" assert trial in...
[ "def", "update_trial_stats", "(", "self", ",", "trial", ",", "result", ")", ":", "assert", "trial", "in", "self", ".", "_live_trials", "assert", "self", ".", "_get_result_time", "(", "result", ")", ">=", "0", "delta", "=", "self", ".", "_get_result_time", ...
Update result for trial. Called after trial has finished an iteration - will decrement iteration count. TODO(rliaw): The other alternative is to keep the trials in and make sure they're not set as pending later.
[ "Update", "result", "for", "trial", ".", "Called", "after", "trial", "has", "finished", "an", "iteration", "-", "will", "decrement", "iteration", "count", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L340-L354
24,550
ray-project/ray
python/ray/tune/schedulers/hyperband.py
Bracket.cleanup_full
def cleanup_full(self, trial_runner): """Cleans up bracket after bracket is completely finished. Lets the last trial continue to run until termination condition kicks in.""" for trial in self.current_trials(): if (trial.status == Trial.PAUSED): trial_runner.s...
python
def cleanup_full(self, trial_runner): """Cleans up bracket after bracket is completely finished. Lets the last trial continue to run until termination condition kicks in.""" for trial in self.current_trials(): if (trial.status == Trial.PAUSED): trial_runner.s...
[ "def", "cleanup_full", "(", "self", ",", "trial_runner", ")", ":", "for", "trial", "in", "self", ".", "current_trials", "(", ")", ":", "if", "(", "trial", ".", "status", "==", "Trial", ".", "PAUSED", ")", ":", "trial_runner", ".", "stop_trial", "(", "t...
Cleans up bracket after bracket is completely finished. Lets the last trial continue to run until termination condition kicks in.
[ "Cleans", "up", "bracket", "after", "bracket", "is", "completely", "finished", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/hyperband.py#L366-L373
24,551
ray-project/ray
python/ray/experimental/state.py
parse_client_table
def parse_client_table(redis_client): """Read the client table. Args: redis_client: A client to the primary Redis shard. Returns: A list of information about the nodes in the cluster. """ NIL_CLIENT_ID = ray.ObjectID.nil().binary() message = redis_client.execute_command("RAY.TA...
python
def parse_client_table(redis_client): """Read the client table. Args: redis_client: A client to the primary Redis shard. Returns: A list of information about the nodes in the cluster. """ NIL_CLIENT_ID = ray.ObjectID.nil().binary() message = redis_client.execute_command("RAY.TA...
[ "def", "parse_client_table", "(", "redis_client", ")", ":", "NIL_CLIENT_ID", "=", "ray", ".", "ObjectID", ".", "nil", "(", ")", ".", "binary", "(", ")", "message", "=", "redis_client", ".", "execute_command", "(", "\"RAY.TABLE_LOOKUP\"", ",", "ray", ".", "gc...
Read the client table. Args: redis_client: A client to the primary Redis shard. Returns: A list of information about the nodes in the cluster.
[ "Read", "the", "client", "table", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L20-L86
24,552
ray-project/ray
python/ray/experimental/state.py
GlobalState._initialize_global_state
def _initialize_global_state(self, redis_address, redis_password=None, timeout=20): """Initialize the GlobalState object by connecting to Redis. It's possible that certain keys in Redis may not have been ...
python
def _initialize_global_state(self, redis_address, redis_password=None, timeout=20): """Initialize the GlobalState object by connecting to Redis. It's possible that certain keys in Redis may not have been ...
[ "def", "_initialize_global_state", "(", "self", ",", "redis_address", ",", "redis_password", "=", "None", ",", "timeout", "=", "20", ")", ":", "self", ".", "redis_client", "=", "services", ".", "create_redis_client", "(", "redis_address", ",", "redis_password", ...
Initialize the GlobalState object by connecting to Redis. It's possible that certain keys in Redis may not have been fully populated yet. In this case, we will retry this method until they have been populated or we exceed a timeout. Args: redis_address: The Redis address to...
[ "Initialize", "the", "GlobalState", "object", "by", "connecting", "to", "Redis", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L128-L184
24,553
ray-project/ray
python/ray/experimental/state.py
GlobalState._execute_command
def _execute_command(self, key, *args): """Execute a Redis command on the appropriate Redis shard based on key. Args: key: The object ID or the task ID that the query is about. args: The command to run. Returns: The value returned by the Redis command. ...
python
def _execute_command(self, key, *args): """Execute a Redis command on the appropriate Redis shard based on key. Args: key: The object ID or the task ID that the query is about. args: The command to run. Returns: The value returned by the Redis command. ...
[ "def", "_execute_command", "(", "self", ",", "key", ",", "*", "args", ")", ":", "client", "=", "self", ".", "redis_clients", "[", "key", ".", "redis_shard_hash", "(", ")", "%", "len", "(", "self", ".", "redis_clients", ")", "]", "return", "client", "."...
Execute a Redis command on the appropriate Redis shard based on key. Args: key: The object ID or the task ID that the query is about. args: The command to run. Returns: The value returned by the Redis command.
[ "Execute", "a", "Redis", "command", "on", "the", "appropriate", "Redis", "shard", "based", "on", "key", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L186-L198
24,554
ray-project/ray
python/ray/experimental/state.py
GlobalState._keys
def _keys(self, pattern): """Execute the KEYS command on all Redis shards. Args: pattern: The KEYS pattern to query. Returns: The concatenated list of results from all shards. """ result = [] for client in self.redis_clients: result.e...
python
def _keys(self, pattern): """Execute the KEYS command on all Redis shards. Args: pattern: The KEYS pattern to query. Returns: The concatenated list of results from all shards. """ result = [] for client in self.redis_clients: result.e...
[ "def", "_keys", "(", "self", ",", "pattern", ")", ":", "result", "=", "[", "]", "for", "client", "in", "self", ".", "redis_clients", ":", "result", ".", "extend", "(", "list", "(", "client", ".", "scan_iter", "(", "match", "=", "pattern", ")", ")", ...
Execute the KEYS command on all Redis shards. Args: pattern: The KEYS pattern to query. Returns: The concatenated list of results from all shards.
[ "Execute", "the", "KEYS", "command", "on", "all", "Redis", "shards", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L200-L212
24,555
ray-project/ray
python/ray/experimental/state.py
GlobalState._object_table
def _object_table(self, object_id): """Fetch and parse the object table information for a single object ID. Args: object_id: An object ID to get information about. Returns: A dictionary with information about the object ID in question. """ # Allow the ar...
python
def _object_table(self, object_id): """Fetch and parse the object table information for a single object ID. Args: object_id: An object ID to get information about. Returns: A dictionary with information about the object ID in question. """ # Allow the ar...
[ "def", "_object_table", "(", "self", ",", "object_id", ")", ":", "# Allow the argument to be either an ObjectID or a hex string.", "if", "not", "isinstance", "(", "object_id", ",", "ray", ".", "ObjectID", ")", ":", "object_id", "=", "ray", ".", "ObjectID", "(", "h...
Fetch and parse the object table information for a single object ID. Args: object_id: An object ID to get information about. Returns: A dictionary with information about the object ID in question.
[ "Fetch", "and", "parse", "the", "object", "table", "information", "for", "a", "single", "object", "ID", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L214-L246
24,556
ray-project/ray
python/ray/experimental/state.py
GlobalState.object_table
def object_table(self, object_id=None): """Fetch and parse the object table info for one or more object IDs. Args: object_id: An object ID to fetch information about. If this is None, then the entire object table is fetched. Returns: Information from the...
python
def object_table(self, object_id=None): """Fetch and parse the object table info for one or more object IDs. Args: object_id: An object ID to fetch information about. If this is None, then the entire object table is fetched. Returns: Information from the...
[ "def", "object_table", "(", "self", ",", "object_id", "=", "None", ")", ":", "self", ".", "_check_connected", "(", ")", "if", "object_id", "is", "not", "None", ":", "# Return information about a single object ID.", "return", "self", ".", "_object_table", "(", "o...
Fetch and parse the object table info for one or more object IDs. Args: object_id: An object ID to fetch information about. If this is None, then the entire object table is fetched. Returns: Information from the object table.
[ "Fetch", "and", "parse", "the", "object", "table", "info", "for", "one", "or", "more", "object", "IDs", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L248-L275
24,557
ray-project/ray
python/ray/experimental/state.py
GlobalState._task_table
def _task_table(self, task_id): """Fetch and parse the task table information for a single task ID. Args: task_id: A task ID to get information about. Returns: A dictionary with information about the task ID in question. """ assert isinstance(task_id, ra...
python
def _task_table(self, task_id): """Fetch and parse the task table information for a single task ID. Args: task_id: A task ID to get information about. Returns: A dictionary with information about the task ID in question. """ assert isinstance(task_id, ra...
[ "def", "_task_table", "(", "self", ",", "task_id", ")", ":", "assert", "isinstance", "(", "task_id", ",", "ray", ".", "TaskID", ")", "message", "=", "self", ".", "_execute_command", "(", "task_id", ",", "\"RAY.TABLE_LOOKUP\"", ",", "ray", ".", "gcs_utils", ...
Fetch and parse the task table information for a single task ID. Args: task_id: A task ID to get information about. Returns: A dictionary with information about the task ID in question.
[ "Fetch", "and", "parse", "the", "task", "table", "information", "for", "a", "single", "task", "ID", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L277-L337
24,558
ray-project/ray
python/ray/experimental/state.py
GlobalState.task_table
def task_table(self, task_id=None): """Fetch and parse the task table information for one or more task IDs. Args: task_id: A hex string of the task ID to fetch information about. If this is None, then the task object table is fetched. Returns: Informatio...
python
def task_table(self, task_id=None): """Fetch and parse the task table information for one or more task IDs. Args: task_id: A hex string of the task ID to fetch information about. If this is None, then the task object table is fetched. Returns: Informatio...
[ "def", "task_table", "(", "self", ",", "task_id", "=", "None", ")", ":", "self", ".", "_check_connected", "(", ")", "if", "task_id", "is", "not", "None", ":", "task_id", "=", "ray", ".", "TaskID", "(", "hex_to_binary", "(", "task_id", ")", ")", "return...
Fetch and parse the task table information for one or more task IDs. Args: task_id: A hex string of the task ID to fetch information about. If this is None, then the task object table is fetched. Returns: Information from the task table.
[ "Fetch", "and", "parse", "the", "task", "table", "information", "for", "one", "or", "more", "task", "IDs", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L339-L365
24,559
ray-project/ray
python/ray/experimental/state.py
GlobalState.function_table
def function_table(self, function_id=None): """Fetch and parse the function table. Returns: A dictionary that maps function IDs to information about the function. """ self._check_connected() function_table_keys = self.redis_client.keys( ra...
python
def function_table(self, function_id=None): """Fetch and parse the function table. Returns: A dictionary that maps function IDs to information about the function. """ self._check_connected() function_table_keys = self.redis_client.keys( ra...
[ "def", "function_table", "(", "self", ",", "function_id", "=", "None", ")", ":", "self", ".", "_check_connected", "(", ")", "function_table_keys", "=", "self", ".", "redis_client", ".", "keys", "(", "ray", ".", "gcs_utils", ".", "FUNCTION_PREFIX", "+", "\"*\...
Fetch and parse the function table. Returns: A dictionary that maps function IDs to information about the function.
[ "Fetch", "and", "parse", "the", "function", "table", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L367-L386
24,560
ray-project/ray
python/ray/experimental/state.py
GlobalState._profile_table
def _profile_table(self, batch_id): """Get the profile events for a given batch of profile events. Args: batch_id: An identifier for a batch of profile events. Returns: A list of the profile events for the specified batch. """ # TODO(rkn): This method sh...
python
def _profile_table(self, batch_id): """Get the profile events for a given batch of profile events. Args: batch_id: An identifier for a batch of profile events. Returns: A list of the profile events for the specified batch. """ # TODO(rkn): This method sh...
[ "def", "_profile_table", "(", "self", ",", "batch_id", ")", ":", "# TODO(rkn): This method should support limiting the number of log", "# events and should also support returning a window of events.", "message", "=", "self", ".", "_execute_command", "(", "batch_id", ",", "\"RAY.T...
Get the profile events for a given batch of profile events. Args: batch_id: An identifier for a batch of profile events. Returns: A list of the profile events for the specified batch.
[ "Get", "the", "profile", "events", "for", "a", "given", "batch", "of", "profile", "events", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L398-L446
24,561
ray-project/ray
python/ray/experimental/state.py
GlobalState.chrome_tracing_dump
def chrome_tracing_dump(self, filename=None): """Return a list of profiling events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing in the Chrome w...
python
def chrome_tracing_dump(self, filename=None): """Return a list of profiling events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing in the Chrome w...
[ "def", "chrome_tracing_dump", "(", "self", ",", "filename", "=", "None", ")", ":", "# TODO(rkn): Support including the task specification data in the", "# timeline.", "# TODO(rkn): This should support viewing just a window of time or a", "# limited number of events.", "profile_table", ...
Return a list of profiling events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing in the Chrome web browser and load the dumped file. Make sure to...
[ "Return", "a", "list", "of", "profiling", "events", "that", "can", "viewed", "as", "a", "timeline", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L528-L596
24,562
ray-project/ray
python/ray/experimental/state.py
GlobalState.chrome_tracing_object_transfer_dump
def chrome_tracing_object_transfer_dump(self, filename=None): """Return a list of transfer events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing ...
python
def chrome_tracing_object_transfer_dump(self, filename=None): """Return a list of transfer events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing ...
[ "def", "chrome_tracing_object_transfer_dump", "(", "self", ",", "filename", "=", "None", ")", ":", "client_id_to_address", "=", "{", "}", "for", "client_info", "in", "ray", ".", "global_state", ".", "client_table", "(", ")", ":", "client_id_to_address", "[", "cl...
Return a list of transfer events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing in the Chrome web browser and load the dumped file. Make sure to ...
[ "Return", "a", "list", "of", "transfer", "events", "that", "can", "viewed", "as", "a", "timeline", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L598-L687
24,563
ray-project/ray
python/ray/experimental/state.py
GlobalState.workers
def workers(self): """Get a dictionary mapping worker ID to worker information.""" worker_keys = self.redis_client.keys("Worker*") workers_data = {} for worker_key in worker_keys: worker_info = self.redis_client.hgetall(worker_key) worker_id = binary_to_hex(worke...
python
def workers(self): """Get a dictionary mapping worker ID to worker information.""" worker_keys = self.redis_client.keys("Worker*") workers_data = {} for worker_key in worker_keys: worker_info = self.redis_client.hgetall(worker_key) worker_id = binary_to_hex(worke...
[ "def", "workers", "(", "self", ")", ":", "worker_keys", "=", "self", ".", "redis_client", ".", "keys", "(", "\"Worker*\"", ")", "workers_data", "=", "{", "}", "for", "worker_key", "in", "worker_keys", ":", "worker_info", "=", "self", ".", "redis_client", "...
Get a dictionary mapping worker ID to worker information.
[ "Get", "a", "dictionary", "mapping", "worker", "ID", "to", "worker", "information", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L689-L709
24,564
ray-project/ray
python/ray/experimental/state.py
GlobalState.cluster_resources
def cluster_resources(self): """Get the current total cluster resources. Note that this information can grow stale as nodes are added to or removed from the cluster. Returns: A dictionary mapping resource name to the total quantity of that resource in the cl...
python
def cluster_resources(self): """Get the current total cluster resources. Note that this information can grow stale as nodes are added to or removed from the cluster. Returns: A dictionary mapping resource name to the total quantity of that resource in the cl...
[ "def", "cluster_resources", "(", "self", ")", ":", "resources", "=", "defaultdict", "(", "int", ")", "clients", "=", "self", ".", "client_table", "(", ")", "for", "client", "in", "clients", ":", "# Only count resources from live clients.", "if", "client", "[", ...
Get the current total cluster resources. Note that this information can grow stale as nodes are added to or removed from the cluster. Returns: A dictionary mapping resource name to the total quantity of that resource in the cluster.
[ "Get", "the", "current", "total", "cluster", "resources", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L747-L765
24,565
ray-project/ray
python/ray/experimental/state.py
GlobalState.available_resources
def available_resources(self): """Get the current available cluster resources. This is different from `cluster_resources` in that this will return idle (available) resources rather than total resources. Note that this information can grow stale as tasks start and finish. Retur...
python
def available_resources(self): """Get the current available cluster resources. This is different from `cluster_resources` in that this will return idle (available) resources rather than total resources. Note that this information can grow stale as tasks start and finish. Retur...
[ "def", "available_resources", "(", "self", ")", ":", "available_resources_by_id", "=", "{", "}", "subscribe_clients", "=", "[", "redis_client", ".", "pubsub", "(", "ignore_subscribe_messages", "=", "True", ")", "for", "redis_client", "in", "self", ".", "redis_clie...
Get the current available cluster resources. This is different from `cluster_resources` in that this will return idle (available) resources rather than total resources. Note that this information can grow stale as tasks start and finish. Returns: A dictionary mapping resou...
[ "Get", "the", "current", "available", "cluster", "resources", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L774-L841
24,566
ray-project/ray
python/ray/experimental/state.py
GlobalState._error_messages
def _error_messages(self, driver_id): """Get the error messages for a specific driver. Args: driver_id: The ID of the driver to get the errors for. Returns: A list of the error messages for this driver. """ assert isinstance(driver_id, ray.DriverID) ...
python
def _error_messages(self, driver_id): """Get the error messages for a specific driver. Args: driver_id: The ID of the driver to get the errors for. Returns: A list of the error messages for this driver. """ assert isinstance(driver_id, ray.DriverID) ...
[ "def", "_error_messages", "(", "self", ",", "driver_id", ")", ":", "assert", "isinstance", "(", "driver_id", ",", "ray", ".", "DriverID", ")", "message", "=", "self", ".", "redis_client", ".", "execute_command", "(", "\"RAY.TABLE_LOOKUP\"", ",", "ray", ".", ...
Get the error messages for a specific driver. Args: driver_id: The ID of the driver to get the errors for. Returns: A list of the error messages for this driver.
[ "Get", "the", "error", "messages", "for", "a", "specific", "driver", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L843-L874
24,567
ray-project/ray
python/ray/experimental/state.py
GlobalState.error_messages
def error_messages(self, driver_id=None): """Get the error messages for all drivers or a specific driver. Args: driver_id: The specific driver to get the errors for. If this is None, then this method retrieves the errors for all drivers. Returns: A dicti...
python
def error_messages(self, driver_id=None): """Get the error messages for all drivers or a specific driver. Args: driver_id: The specific driver to get the errors for. If this is None, then this method retrieves the errors for all drivers. Returns: A dicti...
[ "def", "error_messages", "(", "self", ",", "driver_id", "=", "None", ")", ":", "if", "driver_id", "is", "not", "None", ":", "assert", "isinstance", "(", "driver_id", ",", "ray", ".", "DriverID", ")", "return", "self", ".", "_error_messages", "(", "driver_i...
Get the error messages for all drivers or a specific driver. Args: driver_id: The specific driver to get the errors for. If this is None, then this method retrieves the errors for all drivers. Returns: A dictionary mapping driver ID to a list of the error messag...
[ "Get", "the", "error", "messages", "for", "all", "drivers", "or", "a", "specific", "driver", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L876-L902
24,568
ray-project/ray
python/ray/experimental/tf_utils.py
TensorFlowVariables.get_flat_size
def get_flat_size(self): """Returns the total length of all of the flattened variables. Returns: The length of all flattened variables concatenated. """ return sum( np.prod(v.get_shape().as_list()) for v in self.variables.values())
python
def get_flat_size(self): """Returns the total length of all of the flattened variables. Returns: The length of all flattened variables concatenated. """ return sum( np.prod(v.get_shape().as_list()) for v in self.variables.values())
[ "def", "get_flat_size", "(", "self", ")", ":", "return", "sum", "(", "np", ".", "prod", "(", "v", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", ")", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")", ")" ]
Returns the total length of all of the flattened variables. Returns: The length of all flattened variables concatenated.
[ "Returns", "the", "total", "length", "of", "all", "of", "the", "flattened", "variables", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L111-L118
24,569
ray-project/ray
python/ray/experimental/tf_utils.py
TensorFlowVariables.get_flat
def get_flat(self): """Gets the weights and returns them as a flat array. Returns: 1D Array containing the flattened weights. """ self._check_sess() return np.concatenate([ v.eval(session=self.sess).flatten() for v in self.variables.values() ...
python
def get_flat(self): """Gets the weights and returns them as a flat array. Returns: 1D Array containing the flattened weights. """ self._check_sess() return np.concatenate([ v.eval(session=self.sess).flatten() for v in self.variables.values() ...
[ "def", "get_flat", "(", "self", ")", ":", "self", ".", "_check_sess", "(", ")", "return", "np", ".", "concatenate", "(", "[", "v", ".", "eval", "(", "session", "=", "self", ".", "sess", ")", ".", "flatten", "(", ")", "for", "v", "in", "self", "."...
Gets the weights and returns them as a flat array. Returns: 1D Array containing the flattened weights.
[ "Gets", "the", "weights", "and", "returns", "them", "as", "a", "flat", "array", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L127-L137
24,570
ray-project/ray
python/ray/experimental/tf_utils.py
TensorFlowVariables.set_flat
def set_flat(self, new_weights): """Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): ...
python
def set_flat(self, new_weights): """Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): ...
[ "def", "set_flat", "(", "self", ",", "new_weights", ")", ":", "self", ".", "_check_sess", "(", ")", "shapes", "=", "[", "v", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")", ...
Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): Flat array containing weights.
[ "Sets", "the", "weights", "to", "new_weights", "converting", "from", "a", "flat", "array", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L139-L157
24,571
ray-project/ray
python/ray/experimental/tf_utils.py
TensorFlowVariables.get_weights
def get_weights(self): """Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights. """ self._check_sess() return { k: v.eval(session=self.sess) for k, v in self.variables.items() ...
python
def get_weights(self): """Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights. """ self._check_sess() return { k: v.eval(session=self.sess) for k, v in self.variables.items() ...
[ "def", "get_weights", "(", "self", ")", ":", "self", ".", "_check_sess", "(", ")", "return", "{", "k", ":", "v", ".", "eval", "(", "session", "=", "self", ".", "sess", ")", "for", "k", ",", "v", "in", "self", ".", "variables", ".", "items", "(", ...
Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights.
[ "Returns", "a", "dictionary", "containing", "the", "weights", "of", "the", "network", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L159-L169
24,572
ray-project/ray
python/ray/experimental/tf_utils.py
TensorFlowVariables.set_weights
def set_weights(self, new_weights): """Sets the weights to new_weights. Note: Can set subsets of variables as well, by only passing in the variables you want to be set. Args: new_weights (Dict): Dictionary mapping variable names to their weig...
python
def set_weights(self, new_weights): """Sets the weights to new_weights. Note: Can set subsets of variables as well, by only passing in the variables you want to be set. Args: new_weights (Dict): Dictionary mapping variable names to their weig...
[ "def", "set_weights", "(", "self", ",", "new_weights", ")", ":", "self", ".", "_check_sess", "(", ")", "assign_list", "=", "[", "self", ".", "assignment_nodes", "[", "name", "]", "for", "name", "in", "new_weights", ".", "keys", "(", ")", "if", "name", ...
Sets the weights to new_weights. Note: Can set subsets of variables as well, by only passing in the variables you want to be set. Args: new_weights (Dict): Dictionary mapping variable names to their weights.
[ "Sets", "the", "weights", "to", "new_weights", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L171-L198
24,573
ray-project/ray
python/ray/gcs_utils.py
construct_error_message
def construct_error_message(driver_id, error_type, message, timestamp): """Construct a serialized ErrorTableData object. Args: driver_id: The ID of the driver that the error should go to. If this is nil, then the error will go to all drivers. error_type: The type of the error. ...
python
def construct_error_message(driver_id, error_type, message, timestamp): """Construct a serialized ErrorTableData object. Args: driver_id: The ID of the driver that the error should go to. If this is nil, then the error will go to all drivers. error_type: The type of the error. ...
[ "def", "construct_error_message", "(", "driver_id", ",", "error_type", ",", "message", ",", "timestamp", ")", ":", "builder", "=", "flatbuffers", ".", "Builder", "(", "0", ")", "driver_offset", "=", "builder", ".", "CreateString", "(", "driver_id", ".", "binar...
Construct a serialized ErrorTableData object. Args: driver_id: The ID of the driver that the error should go to. If this is nil, then the error will go to all drivers. error_type: The type of the error. message: The error message. timestamp: The time of the error. R...
[ "Construct", "a", "serialized", "ErrorTableData", "object", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/gcs_utils.py#L60-L91
24,574
ray-project/ray
python/ray/experimental/async_api.py
init
def init(): """ Initialize synchronously. """ loop = asyncio.get_event_loop() if loop.is_running(): raise Exception("You must initialize the Ray async API by calling " "async_api.init() or async_api.as_future(obj) before " "the event loop start...
python
def init(): """ Initialize synchronously. """ loop = asyncio.get_event_loop() if loop.is_running(): raise Exception("You must initialize the Ray async API by calling " "async_api.init() or async_api.as_future(obj) before " "the event loop start...
[ "def", "init", "(", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "if", "loop", ".", "is_running", "(", ")", ":", "raise", "Exception", "(", "\"You must initialize the Ray async API by calling \"", "\"async_api.init() or async_api.as_future(obj) bef...
Initialize synchronously.
[ "Initialize", "synchronously", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_api.py#L24-L34
24,575
ray-project/ray
python/ray/experimental/async_api.py
shutdown
def shutdown(): """Manually shutdown the async API. Cancels all related tasks and all the socket transportation. """ global handler, transport, protocol if handler is not None: handler.close() transport.close() handler = None transport = None protocol = None
python
def shutdown(): """Manually shutdown the async API. Cancels all related tasks and all the socket transportation. """ global handler, transport, protocol if handler is not None: handler.close() transport.close() handler = None transport = None protocol = None
[ "def", "shutdown", "(", ")", ":", "global", "handler", ",", "transport", ",", "protocol", "if", "handler", "is", "not", "None", ":", "handler", ".", "close", "(", ")", "transport", ".", "close", "(", ")", "handler", "=", "None", "transport", "=", "None...
Manually shutdown the async API. Cancels all related tasks and all the socket transportation.
[ "Manually", "shutdown", "the", "async", "API", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_api.py#L51-L62
24,576
ray-project/ray
python/ray/experimental/features.py
flush_redis_unsafe
def flush_redis_unsafe(redis_client=None): """This removes some non-critical state from the primary Redis shard. This removes the log files as well as the event log from Redis. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in Redis. However, it will only...
python
def flush_redis_unsafe(redis_client=None): """This removes some non-critical state from the primary Redis shard. This removes the log files as well as the event log from Redis. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in Redis. However, it will only...
[ "def", "flush_redis_unsafe", "(", "redis_client", "=", "None", ")", ":", "if", "redis_client", "is", "None", ":", "ray", ".", "worker", ".", "global_worker", ".", "check_connected", "(", ")", "redis_client", "=", "ray", ".", "worker", ".", "global_worker", "...
This removes some non-critical state from the primary Redis shard. This removes the log files as well as the event log from Redis. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in Redis. However, it will only partially address the issue as much of the da...
[ "This", "removes", "some", "non", "-", "critical", "state", "from", "the", "primary", "Redis", "shard", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/features.py#L13-L44
24,577
ray-project/ray
python/ray/rllib/agents/ppo/ppo_policy_graph.py
PPOPolicyGraph.copy
def copy(self, existing_inputs): """Creates a copy of self using existing input placeholders.""" return PPOPolicyGraph( self.observation_space, self.action_space, self.config, existing_inputs=existing_inputs)
python
def copy(self, existing_inputs): """Creates a copy of self using existing input placeholders.""" return PPOPolicyGraph( self.observation_space, self.action_space, self.config, existing_inputs=existing_inputs)
[ "def", "copy", "(", "self", ",", "existing_inputs", ")", ":", "return", "PPOPolicyGraph", "(", "self", ".", "observation_space", ",", "self", ".", "action_space", ",", "self", ".", "config", ",", "existing_inputs", "=", "existing_inputs", ")" ]
Creates a copy of self using existing input placeholders.
[ "Creates", "a", "copy", "of", "self", "using", "existing", "input", "placeholders", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ppo/ppo_policy_graph.py#L318-L324
24,578
ray-project/ray
examples/parameter_server/model.py
deepnn
def deepnn(x): """deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10)...
python
def deepnn(x): """deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10)...
[ "def", "deepnn", "(", "x", ")", ":", "# Reshape to use within a convolutional neural net.", "# Last dimension is for \"features\" - there is only one here, since images", "# are grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc.", "with", "tf", ".", "name_scope", "(", "\"resha...
deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10), with val...
[ "deepnn", "builds", "the", "graph", "for", "a", "deep", "net", "for", "classifying", "digits", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/parameter_server/model.py#L120-L180
24,579
ray-project/ray
python/ray/signature.py
get_signature_params
def get_signature_params(func): """Get signature parameters Support Cython functions by grabbing relevant attributes from the Cython function and attaching to a no-op function. This is somewhat brittle, since funcsigs may change, but given that funcsigs is written to a PEP, we hope it is relatively...
python
def get_signature_params(func): """Get signature parameters Support Cython functions by grabbing relevant attributes from the Cython function and attaching to a no-op function. This is somewhat brittle, since funcsigs may change, but given that funcsigs is written to a PEP, we hope it is relatively...
[ "def", "get_signature_params", "(", "func", ")", ":", "# The first condition for Cython functions, the latter for Cython instance", "# methods", "if", "is_cython", "(", "func", ")", ":", "attrs", "=", "[", "\"__code__\"", ",", "\"__annotations__\"", ",", "\"__defaults__\"",...
Get signature parameters Support Cython functions by grabbing relevant attributes from the Cython function and attaching to a no-op function. This is somewhat brittle, since funcsigs may change, but given that funcsigs is written to a PEP, we hope it is relatively stable. Future versions of Python may ...
[ "Get", "signature", "parameters" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L39-L75
24,580
ray-project/ray
python/ray/signature.py
check_signature_supported
def check_signature_supported(func, warn=False): """Check if we support the signature of this function. We currently do not allow remote functions to have **kwargs. We also do not support keyword arguments in conjunction with a *args argument. Args: func: The function whose signature should be...
python
def check_signature_supported(func, warn=False): """Check if we support the signature of this function. We currently do not allow remote functions to have **kwargs. We also do not support keyword arguments in conjunction with a *args argument. Args: func: The function whose signature should be...
[ "def", "check_signature_supported", "(", "func", ",", "warn", "=", "False", ")", ":", "function_name", "=", "func", ".", "__name__", "sig_params", "=", "get_signature_params", "(", "func", ")", "has_kwargs_param", "=", "False", "has_kwonly_param", "=", "False", ...
Check if we support the signature of this function. We currently do not allow remote functions to have **kwargs. We also do not support keyword arguments in conjunction with a *args argument. Args: func: The function whose signature should be checked. warn: If this is true, a warning will ...
[ "Check", "if", "we", "support", "the", "signature", "of", "this", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L78-L119
24,581
ray-project/ray
python/ray/signature.py
extract_signature
def extract_signature(func, ignore_first=False): """Extract the function signature from the function. Args: func: The function whose signature should be extracted. ignore_first: True if the first argument should be ignored. This should be used when func is a method of a class. ...
python
def extract_signature(func, ignore_first=False): """Extract the function signature from the function. Args: func: The function whose signature should be extracted. ignore_first: True if the first argument should be ignored. This should be used when func is a method of a class. ...
[ "def", "extract_signature", "(", "func", ",", "ignore_first", "=", "False", ")", ":", "sig_params", "=", "get_signature_params", "(", "func", ")", "if", "ignore_first", ":", "if", "len", "(", "sig_params", ")", "==", "0", ":", "raise", "Exception", "(", "\...
Extract the function signature from the function. Args: func: The function whose signature should be extracted. ignore_first: True if the first argument should be ignored. This should be used when func is a method of a class. Returns: A function signature object, which incl...
[ "Extract", "the", "function", "signature", "from", "the", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L122-L157
24,582
ray-project/ray
python/ray/signature.py
extend_args
def extend_args(function_signature, args, kwargs): """Extend the arguments that were passed into a function. This extends the arguments that were passed into a function with the default arguments provided in the function definition. Args: function_signature: The function signature of the funct...
python
def extend_args(function_signature, args, kwargs): """Extend the arguments that were passed into a function. This extends the arguments that were passed into a function with the default arguments provided in the function definition. Args: function_signature: The function signature of the funct...
[ "def", "extend_args", "(", "function_signature", ",", "args", ",", "kwargs", ")", ":", "arg_names", "=", "function_signature", ".", "arg_names", "arg_defaults", "=", "function_signature", ".", "arg_defaults", "arg_is_positionals", "=", "function_signature", ".", "arg_...
Extend the arguments that were passed into a function. This extends the arguments that were passed into a function with the default arguments provided in the function definition. Args: function_signature: The function signature of the function being called. args: The non-keywor...
[ "Extend", "the", "arguments", "that", "were", "passed", "into", "a", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L160-L222
24,583
ray-project/ray
python/ray/autoscaler/gcp/config.py
wait_for_crm_operation
def wait_for_crm_operation(operation): """Poll for cloud resource manager operation until finished.""" logger.info("wait_for_crm_operation: " "Waiting for operation {} to finish...".format(operation)) for _ in range(MAX_POLLS): result = crm.operations().get(name=operation["name"]).e...
python
def wait_for_crm_operation(operation): """Poll for cloud resource manager operation until finished.""" logger.info("wait_for_crm_operation: " "Waiting for operation {} to finish...".format(operation)) for _ in range(MAX_POLLS): result = crm.operations().get(name=operation["name"]).e...
[ "def", "wait_for_crm_operation", "(", "operation", ")", ":", "logger", ".", "info", "(", "\"wait_for_crm_operation: \"", "\"Waiting for operation {} to finish...\"", ".", "format", "(", "operation", ")", ")", "for", "_", "in", "range", "(", "MAX_POLLS", ")", ":", ...
Poll for cloud resource manager operation until finished.
[ "Poll", "for", "cloud", "resource", "manager", "operation", "until", "finished", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L36-L52
24,584
ray-project/ray
python/ray/autoscaler/gcp/config.py
wait_for_compute_global_operation
def wait_for_compute_global_operation(project_name, operation): """Poll for global compute operation until finished.""" logger.info("wait_for_compute_global_operation: " "Waiting for operation {} to finish...".format( operation["name"])) for _ in range(MAX_POLLS): ...
python
def wait_for_compute_global_operation(project_name, operation): """Poll for global compute operation until finished.""" logger.info("wait_for_compute_global_operation: " "Waiting for operation {} to finish...".format( operation["name"])) for _ in range(MAX_POLLS): ...
[ "def", "wait_for_compute_global_operation", "(", "project_name", ",", "operation", ")", ":", "logger", ".", "info", "(", "\"wait_for_compute_global_operation: \"", "\"Waiting for operation {} to finish...\"", ".", "format", "(", "operation", "[", "\"name\"", "]", ")", ")"...
Poll for global compute operation until finished.
[ "Poll", "for", "global", "compute", "operation", "until", "finished", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L55-L76
24,585
ray-project/ray
python/ray/autoscaler/gcp/config.py
key_pair_name
def key_pair_name(i, region, project_id, ssh_user): """Returns the ith default gcp_key_pair_name.""" key_name = "{}_gcp_{}_{}_{}".format(RAY, region, project_id, ssh_user, i) return key_name
python
def key_pair_name(i, region, project_id, ssh_user): """Returns the ith default gcp_key_pair_name.""" key_name = "{}_gcp_{}_{}_{}".format(RAY, region, project_id, ssh_user, i) return key_name
[ "def", "key_pair_name", "(", "i", ",", "region", ",", "project_id", ",", "ssh_user", ")", ":", "key_name", "=", "\"{}_gcp_{}_{}_{}\"", ".", "format", "(", "RAY", ",", "region", ",", "project_id", ",", "ssh_user", ",", "i", ")", "return", "key_name" ]
Returns the ith default gcp_key_pair_name.
[ "Returns", "the", "ith", "default", "gcp_key_pair_name", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L79-L82
24,586
ray-project/ray
python/ray/autoscaler/gcp/config.py
key_pair_paths
def key_pair_paths(key_name): """Returns public and private key paths for a given key_name.""" public_key_path = os.path.expanduser("~/.ssh/{}.pub".format(key_name)) private_key_path = os.path.expanduser("~/.ssh/{}.pem".format(key_name)) return public_key_path, private_key_path
python
def key_pair_paths(key_name): """Returns public and private key paths for a given key_name.""" public_key_path = os.path.expanduser("~/.ssh/{}.pub".format(key_name)) private_key_path = os.path.expanduser("~/.ssh/{}.pem".format(key_name)) return public_key_path, private_key_path
[ "def", "key_pair_paths", "(", "key_name", ")", ":", "public_key_path", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/.ssh/{}.pub\"", ".", "format", "(", "key_name", ")", ")", "private_key_path", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/.ss...
Returns public and private key paths for a given key_name.
[ "Returns", "public", "and", "private", "key", "paths", "for", "a", "given", "key_name", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L85-L89
24,587
ray-project/ray
python/ray/autoscaler/gcp/config.py
generate_rsa_key_pair
def generate_rsa_key_pair(): """Create public and private ssh-keys.""" key = rsa.generate_private_key( backend=default_backend(), public_exponent=65537, key_size=2048) public_key = key.public_key().public_bytes( serialization.Encoding.OpenSSH, serialization.PublicFormat.OpenSSH).de...
python
def generate_rsa_key_pair(): """Create public and private ssh-keys.""" key = rsa.generate_private_key( backend=default_backend(), public_exponent=65537, key_size=2048) public_key = key.public_key().public_bytes( serialization.Encoding.OpenSSH, serialization.PublicFormat.OpenSSH).de...
[ "def", "generate_rsa_key_pair", "(", ")", ":", "key", "=", "rsa", ".", "generate_private_key", "(", "backend", "=", "default_backend", "(", ")", ",", "public_exponent", "=", "65537", ",", "key_size", "=", "2048", ")", "public_key", "=", "key", ".", "public_k...
Create public and private ssh-keys.
[ "Create", "public", "and", "private", "ssh", "-", "keys", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L92-L107
24,588
ray-project/ray
python/ray/autoscaler/gcp/config.py
_configure_project
def _configure_project(config): """Setup a Google Cloud Platform Project. Google Compute Platform organizes all the resources, such as storage buckets, users, and instances under projects. This is different from aws ec2 where everything is global. """ project_id = config["provider"].get("projec...
python
def _configure_project(config): """Setup a Google Cloud Platform Project. Google Compute Platform organizes all the resources, such as storage buckets, users, and instances under projects. This is different from aws ec2 where everything is global. """ project_id = config["provider"].get("projec...
[ "def", "_configure_project", "(", "config", ")", ":", "project_id", "=", "config", "[", "\"provider\"", "]", ".", "get", "(", "\"project_id\"", ")", "assert", "config", "[", "\"provider\"", "]", "[", "\"project_id\"", "]", "is", "not", "None", ",", "(", "\...
Setup a Google Cloud Platform Project. Google Compute Platform organizes all the resources, such as storage buckets, users, and instances under projects. This is different from aws ec2 where everything is global.
[ "Setup", "a", "Google", "Cloud", "Platform", "Project", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L119-L144
24,589
ray-project/ray
python/ray/autoscaler/gcp/config.py
_configure_iam_role
def _configure_iam_role(config): """Setup a gcp service account with IAM roles. Creates a gcp service acconut and binds IAM roles which allow it to control control storage/compute services. Specifically, the head node needs to have an IAM role that allows it to create further gce instances and store it...
python
def _configure_iam_role(config): """Setup a gcp service account with IAM roles. Creates a gcp service acconut and binds IAM roles which allow it to control control storage/compute services. Specifically, the head node needs to have an IAM role that allows it to create further gce instances and store it...
[ "def", "_configure_iam_role", "(", "config", ")", ":", "email", "=", "SERVICE_ACCOUNT_EMAIL_TEMPLATE", ".", "format", "(", "account_id", "=", "DEFAULT_SERVICE_ACCOUNT_ID", ",", "project_id", "=", "config", "[", "\"provider\"", "]", "[", "\"project_id\"", "]", ")", ...
Setup a gcp service account with IAM roles. Creates a gcp service acconut and binds IAM roles which allow it to control control storage/compute services. Specifically, the head node needs to have an IAM role that allows it to create further gce instances and store items in google cloud storage. TO...
[ "Setup", "a", "gcp", "service", "account", "with", "IAM", "roles", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L147-L183
24,590
ray-project/ray
python/ray/autoscaler/gcp/config.py
_configure_key_pair
def _configure_key_pair(config): """Configure SSH access, using an existing key pair if possible. Creates a project-wide ssh key that can be used to access all the instances unless explicitly prohibited by instance config. The ssh-keys created by ray are of format: [USERNAME]:ssh-rsa [KEY_VALUE...
python
def _configure_key_pair(config): """Configure SSH access, using an existing key pair if possible. Creates a project-wide ssh key that can be used to access all the instances unless explicitly prohibited by instance config. The ssh-keys created by ray are of format: [USERNAME]:ssh-rsa [KEY_VALUE...
[ "def", "_configure_key_pair", "(", "config", ")", ":", "if", "\"ssh_private_key\"", "in", "config", "[", "\"auth\"", "]", ":", "return", "config", "ssh_user", "=", "config", "[", "\"auth\"", "]", "[", "\"ssh_user\"", "]", "project", "=", "compute", ".", "pro...
Configure SSH access, using an existing key pair if possible. Creates a project-wide ssh key that can be used to access all the instances unless explicitly prohibited by instance config. The ssh-keys created by ray are of format: [USERNAME]:ssh-rsa [KEY_VALUE] [USERNAME] where: [USERNAM...
[ "Configure", "SSH", "access", "using", "an", "existing", "key", "pair", "if", "possible", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L186-L269
24,591
ray-project/ray
python/ray/autoscaler/gcp/config.py
_configure_subnet
def _configure_subnet(config): """Pick a reasonable subnet if not specified by the config.""" # Rationale: avoid subnet lookup if the network is already # completely manually configured if ("networkInterfaces" in config["head_node"] and "networkInterfaces" in config["worker_nodes"]): ...
python
def _configure_subnet(config): """Pick a reasonable subnet if not specified by the config.""" # Rationale: avoid subnet lookup if the network is already # completely manually configured if ("networkInterfaces" in config["head_node"] and "networkInterfaces" in config["worker_nodes"]): ...
[ "def", "_configure_subnet", "(", "config", ")", ":", "# Rationale: avoid subnet lookup if the network is already", "# completely manually configured", "if", "(", "\"networkInterfaces\"", "in", "config", "[", "\"head_node\"", "]", "and", "\"networkInterfaces\"", "in", "config", ...
Pick a reasonable subnet if not specified by the config.
[ "Pick", "a", "reasonable", "subnet", "if", "not", "specified", "by", "the", "config", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L272-L309
24,592
ray-project/ray
python/ray/autoscaler/gcp/config.py
_add_iam_policy_binding
def _add_iam_policy_binding(service_account, roles): """Add new IAM roles for the service account.""" project_id = service_account["projectId"] email = service_account["email"] member_id = "serviceAccount:" + email policy = crm.projects().getIamPolicy(resource=project_id).execute() already_con...
python
def _add_iam_policy_binding(service_account, roles): """Add new IAM roles for the service account.""" project_id = service_account["projectId"] email = service_account["email"] member_id = "serviceAccount:" + email policy = crm.projects().getIamPolicy(resource=project_id).execute() already_con...
[ "def", "_add_iam_policy_binding", "(", "service_account", ",", "roles", ")", ":", "project_id", "=", "service_account", "[", "\"projectId\"", "]", "email", "=", "service_account", "[", "\"email\"", "]", "member_id", "=", "\"serviceAccount:\"", "+", "email", "policy"...
Add new IAM roles for the service account.
[ "Add", "new", "IAM", "roles", "for", "the", "service", "account", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L380-L416
24,593
ray-project/ray
python/ray/autoscaler/gcp/config.py
_create_project_ssh_key_pair
def _create_project_ssh_key_pair(project, public_key, ssh_user): """Inserts an ssh-key into project commonInstanceMetadata""" key_parts = public_key.split(" ") # Sanity checks to make sure that the generated key matches expectation assert len(key_parts) == 2, key_parts assert key_parts[0] == "ssh-...
python
def _create_project_ssh_key_pair(project, public_key, ssh_user): """Inserts an ssh-key into project commonInstanceMetadata""" key_parts = public_key.split(" ") # Sanity checks to make sure that the generated key matches expectation assert len(key_parts) == 2, key_parts assert key_parts[0] == "ssh-...
[ "def", "_create_project_ssh_key_pair", "(", "project", ",", "public_key", ",", "ssh_user", ")", ":", "key_parts", "=", "public_key", ".", "split", "(", "\" \"", ")", "# Sanity checks to make sure that the generated key matches expectation", "assert", "len", "(", "key_part...
Inserts an ssh-key into project commonInstanceMetadata
[ "Inserts", "an", "ssh", "-", "key", "into", "project", "commonInstanceMetadata" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L419-L451
24,594
ray-project/ray
python/ray/remote_function.py
RemoteFunction._remote
def _remote(self, args=None, kwargs=None, num_return_vals=None, num_cpus=None, num_gpus=None, resources=None): """An experimental alternate way to submit remote functions.""" worker = ray.worker.get_global_wo...
python
def _remote(self, args=None, kwargs=None, num_return_vals=None, num_cpus=None, num_gpus=None, resources=None): """An experimental alternate way to submit remote functions.""" worker = ray.worker.get_global_wo...
[ "def", "_remote", "(", "self", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "num_return_vals", "=", "None", ",", "num_cpus", "=", "None", ",", "num_gpus", "=", "None", ",", "resources", "=", "None", ")", ":", "worker", "=", "ray", ".", ...
An experimental alternate way to submit remote functions.
[ "An", "experimental", "alternate", "way", "to", "submit", "remote", "functions", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/remote_function.py#L92-L135
24,595
ray-project/ray
python/ray/experimental/async_plasma.py
PlasmaObjectLinkedList.append
def append(self, future): """Append an object to the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ future.prev = self.tail if self.tail is None: assert self.head is None self.head = future else: ...
python
def append(self, future): """Append an object to the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ future.prev = self.tail if self.tail is None: assert self.head is None self.head = future else: ...
[ "def", "append", "(", "self", ",", "future", ")", ":", "future", ".", "prev", "=", "self", ".", "tail", "if", "self", ".", "tail", "is", "None", ":", "assert", "self", ".", "head", "is", "None", "self", ".", "head", "=", "future", "else", ":", "s...
Append an object to the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance.
[ "Append", "an", "object", "to", "the", "linked", "list", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L97-L111
24,596
ray-project/ray
python/ray/experimental/async_plasma.py
PlasmaObjectLinkedList.remove
def remove(self, future): """Remove an object from the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ if self._loop.get_debug(): logger.debug("Removing %s from the linked list.", future) if future.prev is None: ...
python
def remove(self, future): """Remove an object from the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ if self._loop.get_debug(): logger.debug("Removing %s from the linked list.", future) if future.prev is None: ...
[ "def", "remove", "(", "self", ",", "future", ")", ":", "if", "self", ".", "_loop", ".", "get_debug", "(", ")", ":", "logger", ".", "debug", "(", "\"Removing %s from the linked list.\"", ",", "future", ")", "if", "future", ".", "prev", "is", "None", ":", ...
Remove an object from the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance.
[ "Remove", "an", "object", "from", "the", "linked", "list", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L113-L138
24,597
ray-project/ray
python/ray/experimental/async_plasma.py
PlasmaObjectLinkedList.cancel
def cancel(self, *args, **kwargs): """Manually cancel all tasks assigned to this event loop.""" # Because remove all futures will trigger `set_result`, # we cancel itself first. super().cancel() for future in self.traverse(): # All cancelled futures should have callba...
python
def cancel(self, *args, **kwargs): """Manually cancel all tasks assigned to this event loop.""" # Because remove all futures will trigger `set_result`, # we cancel itself first. super().cancel() for future in self.traverse(): # All cancelled futures should have callba...
[ "def", "cancel", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Because remove all futures will trigger `set_result`,", "# we cancel itself first.", "super", "(", ")", ".", "cancel", "(", ")", "for", "future", "in", "self", ".", "traverse",...
Manually cancel all tasks assigned to this event loop.
[ "Manually", "cancel", "all", "tasks", "assigned", "to", "this", "event", "loop", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L140-L150
24,598
ray-project/ray
python/ray/experimental/async_plasma.py
PlasmaObjectLinkedList.set_result
def set_result(self, result): """Complete all tasks. """ for future in self.traverse(): # All cancelled futures should have callbacks to removed itself # from this linked list. However, these callbacks are scheduled in # an event loop, so we could still find them in o...
python
def set_result(self, result): """Complete all tasks. """ for future in self.traverse(): # All cancelled futures should have callbacks to removed itself # from this linked list. However, these callbacks are scheduled in # an event loop, so we could still find them in o...
[ "def", "set_result", "(", "self", ",", "result", ")", ":", "for", "future", "in", "self", ".", "traverse", "(", ")", ":", "# All cancelled futures should have callbacks to removed itself", "# from this linked list. However, these callbacks are scheduled in", "# an event loop, s...
Complete all tasks.
[ "Complete", "all", "tasks", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L152-L160
24,599
ray-project/ray
python/ray/experimental/async_plasma.py
PlasmaObjectLinkedList.traverse
def traverse(self): """Traverse this linked list. Yields: PlasmaObjectFuture: PlasmaObjectFuture instances. """ current = self.head while current is not None: yield current current = current.next
python
def traverse(self): """Traverse this linked list. Yields: PlasmaObjectFuture: PlasmaObjectFuture instances. """ current = self.head while current is not None: yield current current = current.next
[ "def", "traverse", "(", "self", ")", ":", "current", "=", "self", ".", "head", "while", "current", "is", "not", "None", ":", "yield", "current", "current", "=", "current", ".", "next" ]
Traverse this linked list. Yields: PlasmaObjectFuture: PlasmaObjectFuture instances.
[ "Traverse", "this", "linked", "list", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L162-L171