Remove (object) from class declarations. (#6658)

This commit is contained in:
Robert Nishihara 2020-01-02 17:42:13 -08:00 committed by Philipp Moritz
parent f1b56fa5ee
commit 39a3459886
162 changed files with 397 additions and 398 deletions

View file

@ -27,7 +27,7 @@ def method(*args, **kwargs):
.. code-block:: python
@ray.remote
class Foo(object):
class Foo:
@ray.method(num_return_vals=2)
def bar(self):
return 1, 2
@ -54,7 +54,7 @@ def method(*args, **kwargs):
# Create objects to wrap method invocations. This is done so that we can
# invoke methods with actor.method.remote() instead of actor.method().
class ActorMethod(object):
class ActorMethod:
"""A class used to invoke an actor method.
Note: This class only keeps a weak ref to the actor, unless it has been
@ -143,7 +143,7 @@ class ActorMethod(object):
hardref=True)
class ActorClassMetadata(object):
class ActorClassMetadata:
"""Metadata for an actor class.
Attributes:
@ -234,7 +234,7 @@ class ActorClassMetadata(object):
method.__ray_invocation_decorator__)
class ActorClass(object):
class ActorClass:
"""An actor class.
This is a decorated class. It can be used to create actors.
@ -339,7 +339,7 @@ class ActorClass(object):
actor_cls = self
class ActorOptionWrapper(object):
class ActorOptionWrapper:
def remote(self, *args, **kwargs):
return actor_cls._remote(args=args, kwargs=kwargs, **options)
@ -518,7 +518,7 @@ class ActorClass(object):
return actor_handle
class ActorHandle(object):
class ActorHandle:
"""A handle to an actor.
The fields in this class are prefixed with _ray_ to hide them from the user

View file

@ -156,7 +156,7 @@ CLUSTER_CONFIG_SCHEMA = {
}
class LoadMetrics(object):
class LoadMetrics:
"""Container for cluster load metrics.
Metrics here are updated from raylet heartbeats. The autoscaler
@ -355,7 +355,7 @@ class NodeLauncher(threading.Thread):
logger.info(prefix + " {}".format(statement))
class ConcurrentCounter(object):
class ConcurrentCounter:
def __init__(self):
self._value = 0
self._lock = threading.Lock()
@ -377,7 +377,7 @@ class ConcurrentCounter(object):
return self._value
class StandardAutoscaler(object):
class StandardAutoscaler:
"""The autoscaling control loop for a Ray cluster.
There are two ways to start an autoscaling cluster: manually by running

View file

@ -19,7 +19,7 @@ filelock_logger = logging.getLogger("filelock")
filelock_logger.setLevel(logging.WARNING)
class ClusterState(object):
class ClusterState:
def __init__(self, lock_path, save_path, provider_config):
self.lock = RLock()
self.file_lock = FileLock(lock_path)

View file

@ -8,7 +8,7 @@ import logging
logger = logging.getLogger(__name__)
class LogTimer(object):
class LogTimer:
def __init__(self, message):
self._message = message

View file

@ -129,7 +129,7 @@ def get_default_config(provider_config):
return defaults
class NodeProvider(object):
class NodeProvider:
"""Interface for getting and returning nodes from a Cloud.
NodeProviders are namespaced by the `cluster_name` parameter; they only

View file

@ -37,7 +37,7 @@ def with_interactive(cmd):
return ["bash", "--login", "-c", "-i", quote(force_interactive + cmd)]
class KubernetesCommandRunner(object):
class KubernetesCommandRunner:
def __init__(self, log_prefix, namespace, node_id, auth_config,
process_runner):
@ -149,7 +149,7 @@ class KubernetesCommandRunner(object):
self.node_id)
class SSHCommandRunner(object):
class SSHCommandRunner:
def __init__(self, log_prefix, node_id, provider, auth_config,
cluster_name, process_runner, use_internal_ip):
@ -284,7 +284,7 @@ class SSHCommandRunner(object):
self.ssh_ip)
class NodeUpdater(object):
class NodeUpdater:
"""A process for syncing files and running init commands on a node."""
def __init__(self,

View file

@ -13,7 +13,7 @@ from ray import ray_constants
logger = logging.getLogger(__name__)
class Cluster(object):
class Cluster:
def __init__(self,
initialize_head=False,
connect=False,

View file

@ -72,7 +72,7 @@ def format_reply(reply):
format_reply(item)
class Dashboard(object):
class Dashboard:
"""A dashboard process for monitoring Ray nodes.
This dashboard is made up of a REST API which collates data published by

View file

@ -5,7 +5,7 @@ from __future__ import print_function
import ray
class ActorPool(object):
class ActorPool:
"""Utility class to operate on a fixed pool of actors.
Arguments:

View file

@ -9,7 +9,7 @@ import ray
BLOCK_SIZE = 10
class DistArray(object):
class DistArray:
def __init__(self, shape, objectids=None):
self.shape = shape
self.ndim = len(shape)

View file

@ -15,7 +15,7 @@ transport = None
protocol = None
class _ThreadSafeProxy(object):
class _ThreadSafeProxy:
"""This class is used to create a thread-safe proxy for a given object.
Every method call will be guarded with a lock.

View file

@ -9,7 +9,7 @@ import ray
import ray.cloudpickle as pickle
class GcsFlushPolicy(object):
class GcsFlushPolicy:
"""Experimental: a policy to control GCS flushing.
Used by Monitor to enable automatic control of memory usage.

View file

@ -105,7 +105,7 @@ class ResultThread(threading.Thread):
raise TimeoutError
class AsyncResult(object):
class AsyncResult:
"""An asynchronous interface to task results.
This should not be constructed directly.
@ -168,7 +168,7 @@ class AsyncResult(object):
return not self._result_thread.got_error()
class IMapIterator(object):
class IMapIterator:
"""Base class for OrderedIMapIterator and UnorderedIMapIterator."""
def __init__(self, pool, func, iterable, chunksize=None):
@ -273,7 +273,7 @@ class UnorderedIMapIterator(IMapIterator):
@ray.remote
class PoolActor(object):
class PoolActor:
"""Actor used to process tasks submitted to a Pool."""
def __init__(self, initializer=None, initargs=None):
@ -298,7 +298,7 @@ class PoolActor(object):
# https://docs.python.org/3/library/multiprocessing.html#module-multiprocessing.pool
class Pool(object):
class Pool:
"""A pool of actor processes that is used to process tasks in parallel.
Args:

View file

@ -3,7 +3,7 @@ from __future__ import division
from __future__ import print_function
class NoReturn(object):
class NoReturn:
"""Do not store the return value in the object store.
If a task returns this object, then Ray will not store this object in the

View file

@ -16,7 +16,7 @@ class Full(Exception):
pass
class Queue(object):
class Queue:
"""Queue implementation on Ray.
Args:
@ -132,7 +132,7 @@ class Queue(object):
@ray.remote
class _QueueActor(object):
class _QueueActor:
def __init__(self, maxsize):
self.maxsize = maxsize
self._init(maxsize)

View file

@ -8,7 +8,7 @@ from ray.experimental.serve.metric import MetricMonitor
@pytest.fixture(scope="session")
def start_target_actor(ray_instance):
@ray.remote
class Target(object):
class Target:
def __init__(self):
self.counter_value = 0

View file

@ -17,7 +17,7 @@ from ray.experimental.sgd import utils
logger = logging.getLogger(__name__)
class PyTorchRunner(object):
class PyTorchRunner:
"""Manages a PyTorch model for training."""
def __init__(self,

View file

@ -21,7 +21,7 @@ from ray.experimental.sgd.pytorch.pytorch_runner import PyTorchRunner
logger = logging.getLogger(__name__)
class PyTorchTrainer(object):
class PyTorchTrainer:
"""Train a PyTorch model using distributed PyTorch.
Launches a set of actors which connect via distributed PyTorch and

View file

@ -108,7 +108,7 @@ def validate(model, val_iterator, criterion, config):
return stats
class AverageMeter(object):
class AverageMeter:
"""Computes and stores the average and current value."""
def __init__(self):

View file

@ -20,7 +20,7 @@ def _try_import_strategy():
return tf.distribute.experimental.MultiWorkerMirroredStrategy
class TFRunner(object):
class TFRunner:
"""Manages a TensorFlow model for training."""
def __init__(self, model_creator, data_creator, config=None,

View file

@ -16,7 +16,7 @@ from ray.experimental.sgd.tf.tf_runner import TFRunner
logger = logging.getLogger(__name__)
class TFTrainer(object):
class TFTrainer:
def __init__(self,
model_creator,
data_creator,

View file

@ -8,7 +8,7 @@ import socket
import time
class TimerStat(object):
class TimerStat:
"""A running stat for conveniently logging the duration of a code block.
Note that this class is *not* thread-safe.
@ -108,7 +108,7 @@ def find_free_port():
return s.getsockname()[1]
class AverageMeter(object):
class AverageMeter:
"""Computes and stores the average and current value."""
def __init__(self):

View file

@ -18,7 +18,7 @@ ACTOR_DIED_STR = "ACTOR_DIED_SIGNAL"
logger = logging.getLogger(__name__)
class Signal(object):
class Signal:
"""Base class for Ray signals."""
pass

View file

@ -22,7 +22,7 @@ def unflatten(vector, shapes):
return arrays
class TensorFlowVariables(object):
class TensorFlowVariables:
"""A class used to set and get weights for Tensorflow networks.
Attributes:

View file

@ -39,7 +39,7 @@ FunctionExecutionInfo = namedtuple("FunctionExecutionInfo",
logger = logging.getLogger(__name__)
class FunctionDescriptor(object):
class FunctionDescriptor:
"""A class used to describe a python function.
Attributes:
@ -259,7 +259,7 @@ class FunctionDescriptor(object):
return len(self._class_name) > 0
class FunctionActorManager(object):
class FunctionActorManager:
"""A class used to export/load remote functions and actors.
Attributes:
@ -658,7 +658,7 @@ class FunctionActorManager(object):
class_name))
def _create_fake_actor_class(self, actor_class_name, actor_method_names):
class TemporaryActor(object):
class TemporaryActor:
pass
def temporary_actor_method(*args, **kwargs):

View file

@ -19,7 +19,7 @@ import logging
logger = logging.getLogger(__name__)
class ImportThread(object):
class ImportThread:
"""A thread used to import exports from the driver or other workers.
Note: The driver also has an import thread, which is used only to import

View file

@ -35,7 +35,7 @@ class LocalModeObjectID(ObjectID):
return new
class LocalModeManager(object):
class LocalModeManager:
"""Used to emulate remote operations when running in local mode."""
def __init__(self):

View file

@ -22,7 +22,7 @@ import ray.utils
logger = logging.getLogger(__name__)
class LogFileInfo(object):
class LogFileInfo:
def __init__(self,
filename=None,
size_when_last_opened=None,
@ -37,7 +37,7 @@ class LogFileInfo(object):
self.worker_pid = None
class LogMonitor(object):
class LogMonitor:
"""A monitor process for monitoring Ray log files.
This class mantains a list of open files and a list of closed log files. We

View file

@ -65,7 +65,7 @@ class RayOutOfMemoryError(Exception):
"these memory limits to a lower value.")
class MemoryMonitor(object):
class MemoryMonitor:
"""Helper class for raising errors on low memory.
This presents a much cleaner error message to users than what would happen

View file

@ -23,7 +23,7 @@ from ray.utils import (binary_to_hex, binary_to_object_id, binary_to_task_id,
logger = logging.getLogger(__name__)
class Monitor(object):
class Monitor:
"""A monitor for Ray processes.
The monitor is in charge of cleaning up the tables in the global state

View file

@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
SESSION_LATEST = "session_latest"
class Node(object):
class Node:
"""An encapsulation of the Ray processes on a single node.
This class is responsible for starting Ray processes and killing them,
@ -882,7 +882,7 @@ class Node(object):
return not any(self.dead_processes())
class LocalNode(object):
class LocalNode:
"""Imitate the node that manages the processes in local mode."""
def kill_all_processes(self, *args, **kwargs):

View file

@ -10,7 +10,7 @@ from packaging import version
import ray.ray_constants as ray_constants
class RayParams(object):
class RayParams:
"""A class used to store the parameters used by Ray.
Attributes:

View file

@ -5,7 +5,7 @@ from __future__ import print_function
import ray
class _NullLogSpan(object):
class _NullLogSpan:
"""A log span context manager that does nothing"""
def __enter__(self):

View file

@ -147,7 +147,7 @@ def load_project_or_throw():
"`ray project validate` to inspect the error.")
class SessionRunner(object):
class SessionRunner:
"""Class for setting up a session and executing commands in it."""
def __init__(self, session_name=None):

View file

@ -11,7 +11,7 @@ filter_pattern = os.environ.get("TESTS_TO_RUN", "")
@ray.remote(num_cpus=0)
class Actor(object):
class Actor:
def small_value(self):
return b"ok"
@ -23,7 +23,7 @@ class Actor(object):
@ray.remote(num_cpus=0)
class Client(object):
class Client:
def __init__(self, servers):
if not isinstance(servers, list):
servers = [servers]

View file

@ -21,7 +21,7 @@ DEFAULT_REMOTE_FUNCTION_NUM_TASK_RETRIES = 3
logger = logging.getLogger(__name__)
class RemoteFunction(object):
class RemoteFunction:
"""A remote function.
This is a decorated function. It can be used to spawn tasks.
@ -133,7 +133,7 @@ class RemoteFunction(object):
func_cls = self
class FuncWrapper(object):
class FuncWrapper:
def remote(self, *args, **kwargs):
return func_cls._remote(args=args, kwargs=kwargs, **options)

View file

@ -56,7 +56,7 @@ def to_posix_time(dt):
return (dt - datetime.datetime(1970, 1, 1)).total_seconds()
class Reporter(object):
class Reporter:
"""A monitor process for monitoring Ray nodes.
Attributes:

View file

@ -5,7 +5,7 @@ from __future__ import print_function
import ray.worker
class RuntimeContext(object):
class RuntimeContext:
"""A class used for getting runtime context."""
def __init__(self, worker=None):

View file

@ -40,7 +40,7 @@ class DeserializationError(Exception):
pass
class SerializedObject(object):
class SerializedObject:
def __init__(self, metadata):
self._metadata = metadata
@ -132,7 +132,7 @@ def _try_to_compute_deterministic_class_id(cls, depth=5):
return hashlib.sha1(new_class_id).digest()
class SerializationContext(object):
class SerializationContext:
"""Initialize the serialization library.
This defines a custom serializer for object IDs and also tells ray to

View file

@ -121,7 +121,7 @@ def _parse_resource_table(redis_client, client_id):
return resources
class GlobalState(object):
class GlobalState:
"""A class used to interface with the Ray control state.
# TODO(zongheng): In the future move this to use Ray's redis module in the

View file

@ -100,7 +100,7 @@ def test_args_intertwined(ray_start_regular):
def test_asyncio_actor(ray_start_regular_shared):
@ray.remote
class AsyncBatcher(object):
class AsyncBatcher:
def __init__(self):
self.batch = []
self.event = asyncio.Event()

View file

@ -22,7 +22,7 @@ from ray.experimental.internal_kv import _internal_kv_get, _internal_kv_put
def test_actor_init_error_propagated(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self, error=False):
if error:
raise Exception("oops")
@ -40,7 +40,7 @@ def test_actor_init_error_propagated(ray_start_regular):
def test_keyword_args(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self, arg0, arg1=1, arg2="a"):
self.arg0 = arg0
self.arg1 = arg1
@ -89,7 +89,7 @@ def test_keyword_args(ray_start_regular):
def test_variable_number_of_args(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self, arg0, arg1=1, *args):
self.arg0 = arg0
self.arg1 = arg1
@ -113,7 +113,7 @@ def test_variable_number_of_args(ray_start_regular):
2, 3, 1, 2, 3, 4)) == (3, 5, ("a", "b", "c", "d"), (1, 2, 3, 4))
@ray.remote
class Actor(object):
class Actor:
def __init__(self, *args):
self.args = args
@ -130,7 +130,7 @@ def test_variable_number_of_args(ray_start_regular):
def test_no_args(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -144,7 +144,7 @@ def test_no_args(ray_start_regular):
def test_no_constructor(ray_start_regular):
# If no __init__ method is provided, that should not be a problem.
@ray.remote
class Actor(object):
class Actor:
def get_values(self):
pass
@ -153,12 +153,12 @@ def test_no_constructor(ray_start_regular):
def test_custom_classes(ray_start_regular):
class Foo(object):
class Foo:
def __init__(self, x):
self.x = x
@ray.remote
class Actor(object):
class Actor:
def __init__(self, f2):
self.f1 = Foo(1)
self.f2 = f2
@ -180,13 +180,13 @@ def test_custom_classes(ray_start_regular):
def test_actor_class_attributes(ray_start_regular):
class Grandparent(object):
class Grandparent:
GRANDPARENT = 2
class Parent1(Grandparent):
PARENT1 = 6
class Parent2(object):
class Parent2:
PARENT2 = 7
@ray.remote
@ -216,7 +216,7 @@ def test_caching_actors(shutdown_only):
# Test defining actors before ray.init() has been called.
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
pass
@ -240,7 +240,7 @@ def test_decorator_args(ray_start_regular):
with pytest.raises(Exception):
@ray.remote()
class Actor(object):
class Actor:
def __init__(self):
pass
@ -248,7 +248,7 @@ def test_decorator_args(ray_start_regular):
with pytest.raises(Exception):
@ray.remote(invalid_kwarg=0) # noqa: F811
class Actor(object):
class Actor:
def __init__(self):
pass
@ -256,32 +256,32 @@ def test_decorator_args(ray_start_regular):
with pytest.raises(Exception):
@ray.remote(num_cpus=0, invalid_kwarg=0) # noqa: F811
class Actor(object):
class Actor:
def __init__(self):
pass
# This is a valid way of using the decorator.
@ray.remote(num_cpus=1) # noqa: F811
class Actor(object):
class Actor:
def __init__(self):
pass
# This is a valid way of using the decorator.
@ray.remote(num_gpus=1) # noqa: F811
class Actor(object):
class Actor:
def __init__(self):
pass
# This is a valid way of using the decorator.
@ray.remote(num_cpus=1, num_gpus=1) # noqa: F811
class Actor(object):
class Actor:
def __init__(self):
pass
def test_random_id_generation(ray_start_regular):
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
pass
@ -299,7 +299,7 @@ def test_random_id_generation(ray_start_regular):
def test_actor_class_name(ray_start_regular):
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
pass
@ -314,7 +314,7 @@ def test_actor_class_name(ray_start_regular):
def test_actor_inheritance(ray_start_regular):
class NonActorBase(object):
class NonActorBase:
def __init__(self):
pass
@ -342,7 +342,7 @@ def test_actor_inheritance(ray_start_regular):
def test_multiple_return_values(ray_start_regular):
@ray.remote
class Foo(object):
class Foo:
def method0(self):
return 1
@ -375,7 +375,7 @@ def test_multiple_return_values(ray_start_regular):
def test_define_actor(ray_start_regular):
@ray.remote
class Test(object):
class Test:
def __init__(self, x):
self.x = x
@ -395,7 +395,7 @@ def test_actor_deletion(ray_start_regular):
# destructor is called.
@ray.remote
class Actor(object):
class Actor:
def getpid(self):
return os.getpid()
@ -413,7 +413,7 @@ def test_actor_deletion(ray_start_regular):
def test_actor_method_deletion(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def method(self):
return 1
@ -426,7 +426,7 @@ def test_actor_method_deletion(ray_start_regular):
def test_multiple_actors(ray_start_regular):
@ray.remote
class Counter(object):
class Counter:
def __init__(self, value):
self.value = value
@ -479,7 +479,7 @@ def test_remote_function_within_actor(ray_start_10_cpus):
return ray.get(f.remote(x))
@ray.remote
class Actor(object):
class Actor:
def __init__(self, x):
self.x = x
self.y = val2
@ -515,13 +515,13 @@ def test_define_actor_within_actor(ray_start_10_cpus):
# Make sure we can use remote funtions within actors.
@ray.remote
class Actor1(object):
class Actor1:
def __init__(self, x):
self.x = x
def new_actor(self, z):
@ray.remote
class Actor2(object):
class Actor2:
def __init__(self, x):
self.x = x
@ -542,7 +542,7 @@ def test_use_actor_within_actor(ray_start_10_cpus):
# Make sure we can use actors within actors.
@ray.remote
class Actor1(object):
class Actor1:
def __init__(self, x):
self.x = x
@ -550,7 +550,7 @@ def test_use_actor_within_actor(ray_start_10_cpus):
return self.x
@ray.remote
class Actor2(object):
class Actor2:
def __init__(self, x, y):
self.x = x
self.actor1 = Actor1.remote(y)
@ -568,7 +568,7 @@ def test_define_actor_within_remote_function(ray_start_10_cpus):
@ray.remote
def f(x, n):
@ray.remote
class Actor1(object):
class Actor1:
def __init__(self, x):
self.x = x
@ -587,7 +587,7 @@ def test_use_actor_within_remote_function(ray_start_10_cpus):
# Make sure we can create and use actors within remote funtions.
@ray.remote
class Actor1(object):
class Actor1:
def __init__(self, x):
self.x = x
@ -618,7 +618,7 @@ def test_actor_import_counter(ray_start_10_cpus):
@ray.remote
def g():
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
# This should use the last version of f.
self.x = ray.get(f.remote())
@ -636,7 +636,7 @@ def test_inherit_actor_from_class(ray_start_regular):
# Make sure we can define an actor by inheriting from a regular class.
# Note that actors cannot inherit from other actors.
class Foo(object):
class Foo:
def __init__(self, x):
self.x = x
@ -663,7 +663,7 @@ def test_remote_functions_not_scheduled_on_actors(ray_start_regular):
# Make sure that regular remote functions are not scheduled on actors.
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -683,7 +683,7 @@ def test_remote_functions_not_scheduled_on_actors(ray_start_regular):
def test_actors_on_nodes_with_no_cpus(ray_start_no_cpu):
@ray.remote
class Foo(object):
class Foo:
def method(self):
pass
@ -700,7 +700,7 @@ def test_actor_load_balancing(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote
class Actor1(object):
class Actor1:
def __init__(self):
pass
@ -743,7 +743,7 @@ def test_actor_lifetime_load_balancing(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote(num_cpus=1)
class Actor(object):
class Actor:
def __init__(self):
pass
@ -759,7 +759,7 @@ def test_exception_raised_when_actor_node_dies(ray_start_cluster_head):
remote_node = cluster.add_node()
@ray.remote(max_reconstructions=0)
class Counter(object):
class Counter:
def __init__(self):
self.x = 0
@ -799,7 +799,7 @@ def test_actor_init_fails(ray_start_cluster_head):
remote_node = cluster.add_node()
@ray.remote(max_reconstructions=1)
class Counter(object):
class Counter:
def __init__(self):
self.x = 0
@ -825,7 +825,7 @@ def test_reconstruction_suppression(ray_start_cluster_head):
worker_nodes = [cluster.add_node() for _ in range(num_nodes)]
@ray.remote(max_reconstructions=1)
class Counter(object):
class Counter:
def __init__(self):
self.x = 0
@ -863,7 +863,7 @@ def setup_counter_actor(test_checkpoint=False,
checkpoint_interval = 5
@ray.remote(checkpoint_interval=checkpoint_interval)
class Counter(object):
class Counter:
_resume_exception = resume_exception
def __init__(self, save_exception):
@ -1031,7 +1031,7 @@ def _test_nondeterministic_reconstruction(
cluster, num_forks, num_items_per_fork, num_forks_to_wait):
# Make a shared queue.
@ray.remote
class Queue(object):
class Queue:
def __init__(self):
self.queue = []
@ -1115,7 +1115,7 @@ def setup_queue_actor():
ray.init(num_cpus=1, object_store_memory=int(150 * 1024 * 1024))
@ray.remote
class Queue(object):
class Queue:
def __init__(self):
self.queue = []
@ -1274,7 +1274,7 @@ def test_garbage_collection(setup_queue_actor):
def test_calling_put_on_actor_handle(ray_start_regular):
@ray.remote
class Counter(object):
class Counter:
def __init__(self):
self.x = 0
@ -1308,7 +1308,7 @@ def test_calling_put_on_actor_handle(ray_start_regular):
def test_pickling_actor_handle(ray_start_regular):
@ray.remote
class Foo(object):
class Foo:
def method(self):
pass
@ -1321,12 +1321,12 @@ def test_pickling_actor_handle(ray_start_regular):
def test_pickled_actor_handle_call_in_method_twice(ray_start_regular):
@ray.remote
class Actor1(object):
class Actor1:
def f(self):
return 1
@ray.remote
class Actor2(object):
class Actor2:
def __init__(self, constructor):
self.actor = constructor()
@ -1345,7 +1345,7 @@ def test_register_and_get_named_actors(ray_start_regular):
# TODO(heyucongtom): We should test this from another driver.
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
self.x = 0
@ -1381,7 +1381,7 @@ def test_register_and_get_named_actors(ray_start_regular):
def test_detached_actor(ray_start_regular):
@ray.remote
class DetachedActor(object):
class DetachedActor:
def ping(self):
return "pong"
@ -1400,7 +1400,7 @@ import ray
ray.init(address="{}")
@ray.remote
class DetachedActor(object):
class DetachedActor:
def ping(self):
return "pong"
@ -1415,7 +1415,7 @@ ray.get(actor.ping.remote())
def test_kill(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def hang(self):
# Never returns.
ray.get(ray.ObjectID.from_random())
@ -1434,7 +1434,7 @@ def test_kill(ray_start_regular):
def test_actor_creation_task_crash(ray_start_regular):
# Test actor death in constructor.
@ray.remote(max_reconstructions=0)
class Actor(object):
class Actor:
def __init__(self):
print("crash")
os._exit(0)
@ -1450,7 +1450,7 @@ def test_actor_creation_task_crash(ray_start_regular):
# Test an actor can be reconstructed successfully
# afte it dies in its constructor.
@ray.remote(max_reconstructions=3)
class ReconstructableActor(object):
class ReconstructableActor:
def __init__(self):
count = self.get_count()
count += 1

View file

@ -96,7 +96,7 @@ def test_actor_eviction(ray_start_object_store_memory):
object_store_memory = ray_start_object_store_memory
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -134,7 +134,7 @@ def test_actor_reconstruction(ray_start_regular):
"""Test actor reconstruction when actor process is killed."""
@ray.remote(max_reconstructions=1)
class ReconstructableActor(object):
class ReconstructableActor:
"""An actor that will be reconstructed at most once."""
def __init__(self):
@ -183,7 +183,7 @@ def test_actor_reconstruction_without_task(ray_start_regular):
"""Test a dead actor can be reconstructed without sending task to it."""
@ray.remote(max_reconstructions=1)
class ReconstructableActor(object):
class ReconstructableActor:
def __init__(self, obj_ids):
for obj_id in obj_ids:
# Every time the actor gets constructed,
@ -231,7 +231,7 @@ def test_actor_reconstruction_on_node_failure(ray_start_cluster_head):
cluster.remove_node(node_to_remove)
@ray.remote(max_reconstructions=max_reconstructions, resources={"a": 1})
class MyActor(object):
class MyActor:
def __init__(self):
self.value = 0
@ -296,7 +296,7 @@ def test_multiple_actor_reconstruction(ray_start_cluster_head):
]
@ray.remote(max_reconstructions=ray.ray_constants.INFINITE_RECONSTRUCTION)
class SlowCounter(object):
class SlowCounter:
def __init__(self):
self.x = 0
@ -636,7 +636,7 @@ def test_decorated_method(ray_start_regular):
return new_f_execution
@ray.remote
class Actor(object):
class Actor:
@method_execution_decorator
def decorated_method(self, x):
return x + 1
@ -663,7 +663,7 @@ def test_ray_wait_dead_actor(ray_start_cluster):
cluster = ray_start_cluster
@ray.remote(num_cpus=1)
class Actor(object):
class Actor:
def __init__(self):
pass
@ -707,7 +707,7 @@ def test_ray_wait_dead_actor(ray_start_cluster):
ray.experimental.set_resource(head_node_resource, 1)
@ray.remote(num_cpus=0, resources={head_node_resource: 1})
class ParentActor(object):
class ParentActor:
def __init__(self, ping_ids):
self.unready = ping_ids

View file

@ -18,7 +18,7 @@ def init():
def test_get_next(init):
@ray.remote
class MyActor(object):
class MyActor:
def __init__(self):
pass
@ -37,7 +37,7 @@ def test_get_next(init):
def test_get_next_unordered(init):
@ray.remote
class MyActor(object):
class MyActor:
def __init__(self):
pass
@ -62,7 +62,7 @@ def test_get_next_unordered(init):
def test_map(init):
@ray.remote
class MyActor(object):
class MyActor:
def __init__(self):
pass
@ -83,7 +83,7 @@ def test_map(init):
def test_map_unordered(init):
@ray.remote
class MyActor(object):
class MyActor:
def __init__(self):
pass
@ -105,7 +105,7 @@ def test_map_unordered(init):
def test_get_next_timeout(init):
@ray.remote
class MyActor(object):
class MyActor:
def __init__(self):
pass
@ -127,7 +127,7 @@ def test_get_next_timeout(init):
def test_get_next_unordered_timeout(init):
@ray.remote
class MyActor(object):
class MyActor:
def __init__(self):
pass

View file

@ -29,7 +29,7 @@ def test_actor_deletion_with_gpus(shutdown_only):
# are released.
@ray.remote(num_gpus=1)
class Actor(object):
class Actor:
def getpid(self):
return os.getpid()
@ -42,7 +42,7 @@ def test_actor_deletion_with_gpus(shutdown_only):
def test_actor_state(ray_start_regular):
@ray.remote
class Counter(object):
class Counter:
def __init__(self):
self.value = 0
@ -63,7 +63,7 @@ def test_actor_state(ray_start_regular):
def test_actor_class_methods(ray_start_regular):
class Foo(object):
class Foo:
x = 2
@classmethod
@ -98,7 +98,7 @@ def test_resource_assignment(shutdown_only):
resources={"Custom": 1},
object_store_memory=int(150 * 1024 * 1024))
class Actor(object):
class Actor:
def __init__(self):
self.resources = ray.get_resource_ids()
@ -188,7 +188,7 @@ def test_actor_gpus(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote(num_gpus=1)
class Actor1(object):
class Actor1:
def __init__(self):
self.gpu_ids = ray.get_gpu_ids()
@ -227,7 +227,7 @@ def test_actor_multiple_gpus(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote(num_gpus=2)
class Actor1(object):
class Actor1:
def __init__(self):
self.gpu_ids = ray.get_gpu_ids()
@ -259,7 +259,7 @@ def test_actor_multiple_gpus(ray_start_cluster):
# We should be able to create more actors that use only a single GPU.
@ray.remote(num_gpus=1)
class Actor2(object):
class Actor2:
def __init__(self):
self.gpu_ids = ray.get_gpu_ids()
@ -297,7 +297,7 @@ def test_actor_different_numbers_of_gpus(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote(num_gpus=1)
class Actor1(object):
class Actor1:
def __init__(self):
self.gpu_ids = ray.get_gpu_ids()
@ -343,7 +343,7 @@ def test_actor_multiple_gpus_from_multiple_tasks(ray_start_cluster):
@ray.remote
def create_actors(i, n):
@ray.remote(num_gpus=1)
class Actor(object):
class Actor:
def __init__(self, i, j):
self.gpu_ids = ray.get_gpu_ids()
@ -389,7 +389,7 @@ def test_actor_multiple_gpus_from_multiple_tasks(ray_start_cluster):
assert len(set(gpus_in_use[node_name])) == num_gpus_per_raylet
@ray.remote(num_gpus=1)
class Actor(object):
class Actor:
def __init__(self):
self.gpu_ids = ray.get_gpu_ids()
@ -452,7 +452,7 @@ def test_actors_and_tasks_with_gpus(ray_start_cluster):
[t1, t2])
@ray.remote(num_gpus=1)
class Actor1(object):
class Actor1:
def __init__(self):
self.gpu_ids = ray.get_gpu_ids()
assert len(self.gpu_ids) == 1
@ -528,7 +528,7 @@ def test_actors_and_tasks_with_gpus_version_two(shutdown_only):
# for a long time in order to make sure the GPU is not released
# prematurely.
@ray.remote
class RecordGPUs(object):
class RecordGPUs:
def __init__(self):
self.gpu_ids_seen = []
self.num_calls = 0
@ -550,7 +550,7 @@ def test_actors_and_tasks_with_gpus_version_two(shutdown_only):
time.sleep(1000)
@ray.remote(num_gpus=1)
class Actor(object):
class Actor:
def __init__(self, record_gpu_actor):
self.gpu_ids = ray.get_gpu_ids()
assert len(self.gpu_ids) == 1
@ -592,7 +592,7 @@ def test_blocking_actor_task(shutdown_only):
return 1
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
pass
@ -605,7 +605,7 @@ def test_blocking_actor_task(shutdown_only):
ray.get(actor.blocking_method.remote())
@ray.remote(num_cpus=1)
class CPUFoo(object):
class CPUFoo:
def __init__(self):
pass
@ -621,7 +621,7 @@ def test_blocking_actor_task(shutdown_only):
assert remaining_ids == [x_id]
@ray.remote(num_gpus=1)
class GPUFoo(object):
class GPUFoo:
def __init__(self):
pass
@ -639,13 +639,13 @@ def test_blocking_actor_task(shutdown_only):
def test_lifetime_and_transient_resources(ray_start_regular):
# This actor acquires resources only when running methods.
@ray.remote
class Actor1(object):
class Actor1:
def method(self):
pass
# This actor acquires resources for its lifetime.
@ray.remote(num_cpus=1)
class Actor2(object):
class Actor2:
def method(self):
pass
@ -666,12 +666,12 @@ def test_custom_label_placement(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote(resources={"CustomResource1": 1})
class ResourceActor1(object):
class ResourceActor1:
def get_location(self):
return ray.worker.global_worker.node.unique_id
@ray.remote(resources={"CustomResource2": 1})
class ResourceActor2(object):
class ResourceActor2:
def get_location(self):
return ray.worker.global_worker.node.unique_id
@ -692,12 +692,12 @@ def test_creating_more_actors_than_resources(shutdown_only):
ray.init(num_cpus=10, num_gpus=2, resources={"CustomResource1": 1})
@ray.remote(num_gpus=1)
class ResourceActor1(object):
class ResourceActor1:
def method(self):
return ray.get_gpu_ids()[0]
@ray.remote(resources={"CustomResource1": 1})
class ResourceActor2(object):
class ResourceActor2:
def method(self):
pass

View file

@ -373,7 +373,7 @@ def test_multithreading(ray_start_2_cpus):
"""Test using Ray api in multiple threads."""
@ray.remote
class Echo(object):
class Echo:
def echo(self, value):
return value
@ -433,7 +433,7 @@ def test_multithreading(ray_start_2_cpus):
# Test actor that runs background threads.
@ray.remote
class MultithreadedActor(object):
class MultithreadedActor:
def __init__(self):
self.lock = threading.Lock()
self.thread_results = []
@ -504,7 +504,7 @@ def test_free_objects_multi_node(ray_start_cluster):
_internal_config=config)
ray.init(address=cluster.address)
class RawActor(object):
class RawActor:
def get(self):
return ray.worker.global_worker.node.unique_id
@ -633,7 +633,7 @@ def test_local_mode(shutdown_only):
# Test actors in LOCAL_MODE.
@ray.remote
class LocalModeTestClass(object):
class LocalModeTestClass:
def __init__(self, array):
self.array = array
@ -718,7 +718,7 @@ def test_local_mode(shutdown_only):
# Check that Actors are not overwritten by remote calls from different
# classes.
@ray.remote
class RemoteActor1(object):
class RemoteActor1:
def __init__(self):
pass
@ -726,7 +726,7 @@ def test_local_mode(shutdown_only):
return 0
@ray.remote
class RemoteActor2(object):
class RemoteActor2:
def __init__(self):
pass
@ -756,7 +756,7 @@ def test_wait_makes_object_local(ray_start_cluster):
ray.init(address=cluster.address)
@ray.remote
class Foo(object):
class Foo:
def method(self):
return np.zeros(1024 * 1024)

View file

@ -191,7 +191,7 @@ def test_gpu_ids(shutdown_only):
# Test that actors have CUDA_VISIBLE_DEVICES set properly.
@ray.remote
class Actor0(object):
class Actor0:
def __init__(self):
gpu_ids = ray.get_gpu_ids()
assert len(gpu_ids) == 0
@ -208,7 +208,7 @@ def test_gpu_ids(shutdown_only):
return self.x
@ray.remote(num_gpus=1)
class Actor1(object):
class Actor1:
def __init__(self):
gpu_ids = ray.get_gpu_ids()
assert len(gpu_ids) == 1
@ -243,7 +243,7 @@ def test_zero_cpus(shutdown_only):
# We should be able to create an actor that requires 0 CPU resources.
@ray.remote(num_cpus=0)
class Actor(object):
class Actor:
def method(self):
pass
@ -261,7 +261,7 @@ def test_zero_cpus_actor(ray_start_cluster):
node_id = ray.worker.global_worker.node.unique_id
@ray.remote
class Foo(object):
class Foo:
def method(self):
return ray.worker.global_worker.node.unique_id
@ -274,7 +274,7 @@ def test_fractional_resources(shutdown_only):
ray.init(num_cpus=6, num_gpus=3, resources={"Custom": 1})
@ray.remote(num_gpus=0.5)
class Foo1(object):
class Foo1:
def method(self):
gpu_ids = ray.get_gpu_ids()
assert len(gpu_ids) == 1
@ -287,7 +287,7 @@ def test_fractional_resources(shutdown_only):
del foos
@ray.remote
class Foo2(object):
class Foo2:
def method(self):
pass

View file

@ -260,7 +260,7 @@ def test_global_state_task_object_api(shutdown_only):
# TODO(rkn): Pytest actually has tools for capturing stdout and stderr, so we
# should use those, but they seem to conflict with Ray's use of faulthandler.
class CaptureOutputAndError(object):
class CaptureOutputAndError:
"""Capture stdout and stderr of some span.
This can be used as follows.
@ -434,7 +434,7 @@ def test_wait_reconstruction(shutdown_only):
def test_ray_setproctitle(ray_start_2_cpus):
@ray.remote
class UniqueName(object):
class UniqueName:
def __init__(self):
assert setproctitle.getproctitle() == "ray::UniqueName.__init__()"
@ -667,7 +667,7 @@ def test_export_after_shutdown(ray_start_regular):
pass
@ray.remote
class Actor(object):
class Actor:
def method(self):
pass
@ -731,7 +731,7 @@ def test_move_log_files_to_old(shutdown_only):
logs_dir = os.path.join(info["session_dir"], "logs")
@ray.remote
class Actor(object):
class Actor:
def f(self):
print("function f finished")

View file

@ -21,7 +21,7 @@ from ray.test_utils import RayTestTimeoutException
import pytest
class MockNode(object):
class MockNode:
def __init__(self, node_id, tags):
self.node_id = node_id
self.state = "pending"
@ -36,7 +36,7 @@ class MockNode(object):
return True
class MockProcessRunner(object):
class MockProcessRunner:
def __init__(self, fail_cmds=[]):
self.calls = []
self.fail_cmds = fail_cmds

View file

@ -217,7 +217,7 @@ def complex_serialization(use_pickle):
},
]
class Foo(object):
class Foo:
def __init__(self, value=0):
self.value = value
@ -227,12 +227,12 @@ def complex_serialization(use_pickle):
def __eq__(self, other):
return other.value == self.value
class Bar(object):
class Bar:
def __init__(self):
for i, val in enumerate(PRIMITIVE_OBJECTS + COMPLEX_OBJECTS):
setattr(self, "field{}".format(i), val)
class Baz(object):
class Baz:
def __init__(self):
self.foo = Foo()
self.bar = Bar()
@ -240,7 +240,7 @@ def complex_serialization(use_pickle):
def method(self, arg):
pass
class Qux(object):
class Qux:
def __init__(self):
self.objs = [Foo(), Bar(), Baz()]
@ -273,7 +273,7 @@ def complex_serialization(use_pickle):
CUSTOM_OBJECTS.append(DataClass0(number=3))
class CustomClass(object):
class CustomClass:
def __init__(self, value):
self.value = value
@ -385,7 +385,7 @@ def test_nested_functions(ray_start_regular):
def test_ray_recursive_objects(ray_start_regular):
class ClassA(object):
class ClassA:
pass
# Make a list that contains itself.
@ -440,7 +440,7 @@ def test_passing_arguments_by_value_out_of_the_box(ray_start_regular):
assert ray.get(f.remote(float)) == float
assert ray.get(f.remote(str)) == str
class Foo(object):
class Foo:
def __init__(self):
pass
@ -453,7 +453,7 @@ def test_putting_object_that_closes_over_object_id(ray_start_regular):
# This test is here to prevent a regression of
# https://github.com/ray-project/ray/issues/1317.
class Foo(object):
class Foo:
def __init__(self):
self.val = ray.put(0)
@ -493,7 +493,7 @@ def test_put_get(shutdown_only):
def custom_serializers():
class Foo(object):
class Foo:
def __init__(self):
self.x = 3
@ -508,7 +508,7 @@ def custom_serializers():
assert ray.get(ray.put(Foo())) == ((3, "string1", Foo.__name__), "string2")
class Bar(object):
class Bar:
def __init__(self):
self.x = 3
@ -530,7 +530,7 @@ def test_custom_serializers_with_pickle(shutdown_only):
ray.init(use_pickle=True)
custom_serializers()
class Foo(object):
class Foo:
def __init__(self):
self.x = 4
@ -566,7 +566,7 @@ def test_serialization_final_fallback(ray_start_regular):
def test_register_class(ray_start_2_cpus):
# Check that putting an object of a class that has not been registered
# throws an exception.
class TempClass(object):
class TempClass:
pass
ray.get(ray.put(TempClass()))
@ -576,7 +576,7 @@ def test_register_class(ray_start_2_cpus):
def f(x):
return x
class Foo(object):
class Foo:
def __init__(self, value=0):
self.value = value
@ -597,14 +597,14 @@ def test_register_class(ray_start_2_cpus):
# Instead, we do this:
assert regex.pattern == new_regex.pattern
class TempClass1(object):
class TempClass1:
def __init__(self):
self.value = 1
# Test returning custom classes created on workers.
@ray.remote
def g():
class TempClass2(object):
class TempClass2:
def __init__(self):
self.value = 2
@ -616,7 +616,7 @@ def test_register_class(ray_start_2_cpus):
# Test exporting custom class definitions from one worker to another
# when the worker is blocked in a get.
class NewTempClass(object):
class NewTempClass:
def __init__(self, value):
self.value = value
@ -633,19 +633,19 @@ def test_register_class(ray_start_2_cpus):
# Test registering multiple classes with the same name.
@ray.remote(num_return_vals=3)
def j():
class Class0(object):
class Class0:
def method0(self):
pass
c0 = Class0()
class Class0(object):
class Class0:
def method1(self):
pass
c1 = Class0()
class Class0(object):
class Class0:
def method2(self):
pass
@ -672,19 +672,19 @@ def test_register_class(ray_start_2_cpus):
@ray.remote
def k():
class Class0(object):
class Class0:
def method0(self):
pass
c0 = Class0()
class Class0(object):
class Class0:
def method1(self):
pass
c1 = Class0()
class Class0(object):
class Class0:
def method2(self):
pass
@ -804,7 +804,7 @@ def test_args_starkwargs(ray_start_regular):
def starkwargs(a, b, **kwargs):
return a, b, kwargs
class TestActor(object):
class TestActor:
def starkwargs(self, a, b, **kwargs):
return a, b, kwargs
@ -841,7 +841,7 @@ def test_args_named_and_star(ray_start_regular):
def hello(a, x="hello", **kwargs):
return a, x, kwargs
class TestActor(object):
class TestActor:
def hello(self, a, x="hello", **kwargs):
return a, x, kwargs
@ -884,7 +884,7 @@ def test_args_stars_after(ray_start_regular):
def star_args_after(a="hello", b="heo", *args, **kwargs):
return a, b, args, kwargs
class TestActor(object):
class TestActor:
def star_args_after(self, a="hello", b="heo", *args, **kwargs):
return a, b, args, kwargs
@ -1089,7 +1089,7 @@ def test_submit_api(shutdown_only):
assert len(remaining_ids) == 1
@ray.remote
class Actor(object):
class Actor:
def __init__(self, x, y=0):
self.x = x
self.y = y
@ -1101,7 +1101,7 @@ def test_submit_api(shutdown_only):
return ray.get_gpu_ids()
@ray.remote
class Actor2(object):
class Actor2:
def __init__(self):
pass
@ -1250,7 +1250,7 @@ def test_direct_call_simple(ray_start_cluster):
# https://github.com/ray-project/ray/issues/6329
def test_call_actors_indirect_through_tasks(ray_start_regular):
@ray.remote
class Counter(object):
class Counter:
def __init__(self, value):
self.value = int(value)
@ -1302,7 +1302,7 @@ def test_direct_call_matrix(shutdown_only):
ray.init(object_store_memory=1000 * 1024 * 1024)
@ray.remote
class Actor(object):
class Actor:
def small_value(self):
return 0
@ -1390,7 +1390,7 @@ def test_direct_inline_arg_memory_corruption(ray_start_regular):
return np.zeros(1000, dtype=np.uint8)
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
self.z = []
@ -1407,7 +1407,7 @@ def test_direct_inline_arg_memory_corruption(ray_start_regular):
def test_direct_actor_enabled(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -1430,7 +1430,7 @@ def test_direct_actor_order(shutdown_only):
return 0
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
self.count = 0
@ -1448,7 +1448,7 @@ def test_direct_actor_order(shutdown_only):
def test_direct_actor_large_objects(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -1467,7 +1467,7 @@ def test_direct_actor_large_objects(ray_start_regular):
def test_direct_actor_pass_by_ref(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -1497,7 +1497,7 @@ def test_direct_actor_pass_by_ref_order_optimization(shutdown_only):
ray.init(num_cpus=4)
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -1532,7 +1532,7 @@ def test_direct_actor_pass_by_ref_order_optimization(shutdown_only):
def test_direct_actor_recursive(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self, delegate=None):
self.delegate = delegate
@ -1555,7 +1555,7 @@ def test_direct_actor_recursive(ray_start_regular):
def test_direct_actor_concurrent(ray_start_regular):
@ray.remote
class Batcher(object):
class Batcher:
def __init__(self):
self.batch = []
self.event = threading.Event()

View file

@ -25,7 +25,7 @@ def test_actor_creation_node_failure(ray_start_cluster):
cluster = ray_start_cluster
@ray.remote
class Child(object):
class Child:
def __init__(self, death_probability):
self.death_probability = death_probability

View file

@ -580,7 +580,7 @@ def test_release_cpus_when_actor_creation_task_blocking(shutdown_only):
return 100
@ray.remote(num_cpus=1)
class A(object):
class A:
def __init__(self):
self.num = ray.get(get_100.remote())

View file

@ -167,7 +167,7 @@ def temporary_helper_function():
# Define an actor that closes over this temporary module. This should
# fail when it is unpickled.
@ray.remote
class Foo(object):
class Foo:
def __init__(self, arg1, arg2=3):
self.x = module.temporary_python_file()
@ -213,7 +213,7 @@ def test_failed_actor_init(ray_start_regular):
error_message2 = "actor method failed"
@ray.remote
class FailedActor(object):
class FailedActor:
def __init__(self):
raise Exception(error_message1)
@ -240,7 +240,7 @@ def test_failed_actor_method(ray_start_regular):
error_message2 = "actor method failed"
@ray.remote
class FailedActor(object):
class FailedActor:
def __init__(self):
pass
@ -259,7 +259,7 @@ def test_failed_actor_method(ray_start_regular):
def test_incorrect_method_calls(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def __init__(self, missing_variable_name):
pass
@ -325,7 +325,7 @@ def test_worker_dying(ray_start_regular):
def test_actor_worker_dying(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
def kill(self):
eval("exit()")
@ -344,7 +344,7 @@ def test_actor_worker_dying(ray_start_regular):
def test_actor_worker_dying_future_tasks(ray_start_regular):
@ray.remote(max_reconstructions=0)
class Actor(object):
class Actor:
def getpid(self):
return os.getpid()
@ -366,7 +366,7 @@ def test_actor_worker_dying_future_tasks(ray_start_regular):
def test_actor_worker_dying_nothing_in_progress(ray_start_regular):
@ray.remote(max_reconstructions=0)
class Actor(object):
class Actor:
def getpid(self):
return os.getpid()
@ -381,7 +381,7 @@ def test_actor_worker_dying_nothing_in_progress(ray_start_regular):
def test_actor_scope_or_intentionally_killed_message(ray_start_regular):
@ray.remote
class Actor(object):
class Actor:
pass
a = Actor.remote()
@ -532,7 +532,7 @@ def test_export_large_objects(ray_start_regular):
wait_for_errors(ray_constants.PICKLING_LARGE_OBJECT_PUSH_ERROR, 1)
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
large_object
@ -548,7 +548,7 @@ def test_warning_for_resource_deadlock(shutdown_only):
ray.init(num_cpus=1)
@ray.remote(num_cpus=1)
class Foo(object):
class Foo:
def f(self):
return 0
@ -572,7 +572,7 @@ def test_warning_for_infeasible_tasks(ray_start_regular):
pass
@ray.remote(resources={"Custom": 1})
class Foo(object):
class Foo:
pass
# This task is infeasible.
@ -592,7 +592,7 @@ def test_warning_for_infeasible_zero_cpu_actor(shutdown_only):
ray.init(num_cpus=0)
@ray.remote
class Foo(object):
class Foo:
pass
# The actor creation should be infeasible.
@ -607,7 +607,7 @@ def test_warning_for_too_many_actors(shutdown_only):
ray.init(num_cpus=num_cpus)
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
time.sleep(1000)
@ -689,7 +689,7 @@ def test_warning_for_many_duplicate_remote_functions_and_actors(shutdown_only):
# Require a GPU so that the actor is never actually created and we
# don't spawn an unreasonable number of processes.
@ray.remote(num_gpus=1)
class Foo(object):
class Foo:
pass
Foo.remote()
@ -850,7 +850,7 @@ def test_connect_with_disconnected_node(shutdown_only):
@pytest.mark.parametrize("num_actors", [1, 2, 5])
def test_parallel_actor_fill_plasma_retry(ray_start_cluster_head, num_actors):
@ray.remote
class LargeMemoryActor(object):
class LargeMemoryActor:
def some_expensive_task(self):
return np.zeros(10**8 // 2, dtype=np.uint8)
@ -869,7 +869,7 @@ def test_parallel_actor_fill_plasma_retry(ray_start_cluster_head, num_actors):
indirect=True)
def test_fill_object_store_exception(ray_start_cluster_head):
@ray.remote
class LargeMemoryActor(object):
class LargeMemoryActor:
def some_expensive_task(self):
return np.zeros(10**8 + 2, dtype=np.uint8)

View file

@ -30,7 +30,7 @@ def test_basic_gc(shutdown_only):
return np.random.shuffle(input)
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
# Hold a long-lived reference to a ray.put object. This should not
# be garbage collected while the actor is alive.

View file

@ -10,7 +10,7 @@ OBJECT_TOO_LARGE = ray.exceptions.ObjectStoreFullError
@ray.remote
class LightActor(object):
class LightActor:
def __init__(self):
pass
@ -19,7 +19,7 @@ class LightActor(object):
@ray.remote
class GreedyActor(object):
class GreedyActor:
def __init__(self):
pass

View file

@ -9,7 +9,7 @@ MB = 1024 * 1024
@ray.remote(memory=100 * MB)
class Actor(object):
class Actor:
def __init__(self):
pass
@ -18,7 +18,7 @@ class Actor(object):
@ray.remote(object_store_memory=100 * MB)
class Actor2(object):
class Actor2:
def __init__(self):
pass

View file

@ -48,7 +48,7 @@ def test_worker_stats(shutdown_only):
return os.getpid()
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -118,7 +118,7 @@ def test_raylet_info_endpoint(shutdown_only):
addresses = ray.init(include_webui=True, num_cpus=6)
@ray.remote(num_cpus=1)
class ActorA(object):
class ActorA:
def __init__(self):
pass
@ -126,12 +126,12 @@ def test_raylet_info_endpoint(shutdown_only):
return os.getpid()
@ray.remote(resources={"CustomResource": 1})
class ActorB(object):
class ActorB:
def __init__(self):
pass
@ray.remote(num_cpus=2)
class ActorC(object):
class ActorC:
def __init__(self):
self.children = [ActorA.remote(), ActorB.remote()]

View file

@ -53,7 +53,7 @@ def test_put_api(ray_start_regular):
def test_actor_api(ray_start_regular):
@ray.remote
class Foo(object):
class Foo:
def __init__(self, val):
self.x = val

View file

@ -143,7 +143,7 @@ def test_driver_exiting_quickly(call_ray_start):
import ray
ray.init(address="{}")
@ray.remote
class Foo(object):
class Foo:
def __init__(self):
pass
Foo.remote()
@ -185,7 +185,7 @@ import ray
import time
ray.init(address="{}")
@ray.remote
class Counter(object):
class Counter:
def __init__(self):
self.count = 0
def increment(self):
@ -236,7 +236,7 @@ import time
log_message = "{}"
@ray.remote
class Actor(object):
class Actor:
def log(self):
print(log_message)
@ -278,7 +278,7 @@ def g(duration):
time.sleep(duration)
@ray.remote(num_gpus=1)
class Foo(object):
class Foo:
def __init__(self):
pass

View file

@ -138,7 +138,7 @@ def test_heartbeats_single(ray_start_cluster_head):
ray.get(work_handle)
@ray.remote
class Actor(object):
class Actor:
def work(self, timeout):
time.sleep(timeout)
return True

View file

@ -94,7 +94,7 @@ def test_actor_creation_node_failure(ray_start_cluster):
cluster = ray_start_cluster
@ray.remote
class Child(object):
class Child:
def __init__(self, death_probability):
self.death_probability = death_probability

View file

@ -133,7 +133,7 @@ def test_actor_broadcast(ray_start_cluster_with_resource):
cluster, num_nodes = ray_start_cluster_with_resource
@ray.remote
class Actor(object):
class Actor:
def ready(self):
pass

View file

@ -18,7 +18,7 @@ def password():
return random_bytes.encode("hex") # Python 2
class TestRedisPassword(object):
class TestRedisPassword:
@pytest.mark.skipif(
os.environ.get("RAY_USE_NEW_GCS") == "on",
reason="New GCS API doesn't support Redis authentication yet.")

View file

@ -42,7 +42,7 @@ def test_send_signal_from_actor_to_driver(ray_start_regular):
# Send several signals from an actor, and receive them in the driver.
@ray.remote
class ActorSendSignal(object):
class ActorSendSignal:
def __init__(self):
pass
@ -66,7 +66,7 @@ def test_send_signals_from_actor_to_driver(ray_start_regular):
# these signals in the driver.
@ray.remote
class ActorSendSignals(object):
class ActorSendSignals:
def __init__(self):
pass
@ -123,7 +123,7 @@ def test_actor_crash(ray_start_regular):
# of a method that failed.
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -145,7 +145,7 @@ def test_actor_crash_init(ray_start_regular):
# Get an error when an actor's __init__ failed.
@ray.remote
class ActorCrashInit(object):
class ActorCrashInit:
def __init__(self):
raise Exception("exception message")
@ -165,7 +165,7 @@ def test_actor_crash_init2(ray_start_regular):
# of the actor.
@ray.remote
class ActorCrashInit(object):
class ActorCrashInit:
def __init__(self):
raise Exception("exception message")
@ -188,7 +188,7 @@ def test_actor_crash_init3(ray_start_regular):
# another method of the actor is invoked.
@ray.remote
class ActorCrashInit(object):
class ActorCrashInit:
def __init__(self):
raise Exception("exception message")
@ -209,7 +209,7 @@ def test_send_signals_from_actor_to_actor(ray_start_regular):
# these signals in another actor.
@ray.remote
class ActorSendSignals(object):
class ActorSendSignals:
def __init__(self):
pass
@ -218,7 +218,7 @@ def test_send_signals_from_actor_to_actor(ray_start_regular):
signal.send(UserSignal(value + str(i)))
@ray.remote
class ActorGetSignalsAll(object):
class ActorGetSignalsAll:
def __init__(self):
self.received_signals = []
@ -257,7 +257,7 @@ def test_forget(ray_start_regular):
# actor. Then show that the driver only gets the last "count" signals.
@ray.remote
class ActorSendSignals(object):
class ActorSendSignals:
def __init__(self):
pass
@ -278,7 +278,7 @@ def test_forget(ray_start_regular):
def test_signal_on_node_failure(two_node_cluster):
"""Test actor checkpointing on a remote node."""
class ActorSignal(object):
class ActorSignal:
def __init__(self):
pass

View file

@ -48,7 +48,7 @@ def test_submitting_many_tasks(ray_start_sharded):
def test_submitting_many_actors_to_one(ray_start_sharded):
@ray.remote
class Actor(object):
class Actor:
def __init__(self):
pass
@ -56,7 +56,7 @@ def test_submitting_many_actors_to_one(ray_start_sharded):
return
@ray.remote
class Worker(object):
class Worker:
def __init__(self, actor):
self.actor = actor

View file

@ -22,7 +22,7 @@ def make_linear_network(w_name=None, b_name=None):
tf.global_variables_initializer(), x_data, y_data)
class LossActor(object):
class LossActor:
def __init__(self, use_loss=True):
# Uses a separate graph for each network.
with tf.Graph().as_default():
@ -45,7 +45,7 @@ class LossActor(object):
return self.values[0].get_weights()
class NetActor(object):
class NetActor:
def __init__(self):
# Uses a separate graph for each network.
with tf.Graph().as_default():
@ -67,7 +67,7 @@ class NetActor(object):
return self.values[0].get_weights()
class TrainActor(object):
class TrainActor:
def __init__(self):
# Almost the same as above, but now returns the placeholders and
# gradient.

View file

@ -17,7 +17,7 @@ from ray.tune.result import EXPR_PROGRESS_FILE, EXPR_PARAM_FILE, CONFIG_PREFIX
logger = logging.getLogger(__name__)
class Analysis(object):
class Analysis:
"""Analyze all results from a directory of experiments."""
def __init__(self, experiment_dir):

View file

@ -11,7 +11,7 @@ from ray.tune import grid_search
logger = logging.getLogger(__name__)
class ParameterSpace(object):
class ParameterSpace:
"""Base class of a single parameter's search space.
"""
@ -116,7 +116,7 @@ class ContinuousSpace(ParameterSpace):
self.end)
class SearchSpace(object):
class SearchSpace:
"""Collection of ``ParameterSpace``, a.k.a <name, space> pair.
It's supposed to be used with a fixed experiment config, which

View file

@ -17,7 +17,7 @@ from ray.tune.result import DEFAULT_RESULTS_DIR, JOB_META_FILE, \
EXPR_PARAM_FILE, EXPR_RESULT_FILE, EXPR_META_FILE
class CollectorService(object):
class CollectorService:
"""Server implementation to monitor the log directory.
The service will save the information of job and

View file

@ -16,7 +16,7 @@ except NameError:
logger = logging.getLogger(__name__)
class Checkpoint(object):
class Checkpoint:
"""Describes a checkpoint of trial state.
Checkpoint may be saved in different storage.
@ -54,7 +54,7 @@ class Checkpoint(object):
return Checkpoint(Checkpoint.MEMORY, value)
class QueueItem(object):
class QueueItem:
def __init__(self, priority, value):
self.priority = priority
self.value = value
@ -69,7 +69,7 @@ class QueueItem(object):
return self.priority < other.priority
class CheckpointManager(object):
class CheckpointManager:
"""Manages checkpoints on the driver for a trial."""
def __init__(self, keep_checkpoints_num, checkpoint_score_attr):

View file

@ -34,7 +34,7 @@ def _raise_deprecation_note(deprecated, replacement, soft=False):
raise DeprecationWarning(error_msg)
class Experiment(object):
class Experiment:
"""Tracks experiment specifications.
Implicitly registers the Trainable if needed.

View file

@ -24,7 +24,7 @@ ERROR_REPORT_TIMEOUT = 10
ERROR_FETCH_TIMEOUT = 1
class StatusReporter(object):
class StatusReporter:
"""Object passed into your function that you can report status through.
Example:

View file

@ -26,7 +26,7 @@ tf = None
VALID_SUMMARY_TYPES = [int, float, np.float32, np.float64, np.int32]
class Logger(object):
class Logger:
"""Logging interface for ray.tune.
By default, the UnifiedLogger implementation is used which logs results in

View file

@ -26,7 +26,7 @@ REPORTED_REPRESENTATIONS = {
}
class ProgressReporter(object):
class ProgressReporter:
# TODO(ujvl): Expose ProgressReporter in tune.run for custom reporting.
def report(self, trial_runner):

View file

@ -30,7 +30,7 @@ DEFAULT_GET_TIMEOUT = 30.0 # seconds
TRIAL_START_ATTEMPTS = 3
class _LocalWrapper(object):
class _LocalWrapper:
def __init__(self, result):
self._result = result

View file

@ -98,7 +98,7 @@ def _make_key(category, key):
key.encode("ascii"))
class _Registry(object):
class _Registry:
def __init__(self):
self._to_flush = {}

View file

@ -8,7 +8,7 @@ import numpy as np
logger = logging.getLogger(__name__)
class sample_from(object):
class sample_from:
"""Specify that tune should sample configuration values from this function.
Arguments:

View file

@ -294,7 +294,7 @@ class HyperBandScheduler(FIFOScheduler):
trial_runner.trial_executor.unpause_trial(trial)
class Bracket(object):
class Bracket:
"""Logical object for tracking Hyperband bracket progress. Keeps track
of proper parameters as designated by HyperBand.

View file

@ -21,7 +21,7 @@ from ray.tune.trial import Trial, Checkpoint
logger = logging.getLogger(__name__)
class PBTTrialState(object):
class PBTTrialState:
"""Internal PBT state tracked per-trial."""
def __init__(self, trial):

View file

@ -5,7 +5,7 @@ from __future__ import print_function
from ray.tune.trial import Trial
class TrialScheduler(object):
class TrialScheduler:
"""Interface for implementing a Trial Scheduler class."""
CONTINUE = "CONTINUE" #: Status for continuing trial execution

View file

@ -3,7 +3,7 @@ from __future__ import division
from __future__ import print_function
class SearchAlgorithm(object):
class SearchAlgorithm:
"""Interface of an event handler API for hyperparameter search.
Unlike TrialSchedulers, SearchAlgorithms will not have the ability

View file

@ -76,7 +76,7 @@ def get_cloud_sync_client(remote_path):
return CommandBasedClient(template, template)
class SyncClient(object):
class SyncClient:
"""Client interface for interacting with remote storage options."""
def sync_up(self, source, target):

View file

@ -60,7 +60,7 @@ def log_sync_template(options=""):
return template.format(options=options, rsh=quote(rsh))
class Syncer(object):
class Syncer:
def __init__(self, local_dir, remote_dir, sync_client=NOOP):
"""Syncs between two directories with the sync_function.

View file

@ -192,7 +192,7 @@ class TrainableFunctionApiTest(unittest.TestCase):
def train(config, reporter):
pass
class A(object):
class A:
pass
class B(Trainable):

View file

@ -20,7 +20,7 @@ from ray.tune import commands
from ray.tune.result import CONFIG_PREFIX
class Capturing(object):
class Capturing:
def __enter__(self):
self._stdout = sys.stdout
sys.stdout = self._stringio = StringIO()

View file

@ -116,7 +116,7 @@ class AutoInitTest(unittest.TestCase):
_register_all()
class AbstractWarmStartTest(object):
class AbstractWarmStartTest:
def setUp(self):
ray.init(local_mode=True)
self.tmpdir = tempfile.mkdtemp()

View file

@ -18,7 +18,7 @@ class _ReporterHook(Logger):
return self.tune_reporter(**metrics)
class TrackSession(object):
class TrackSession:
"""Manages results for a single session.
Represents a single Trial in an experiment.

View file

@ -29,7 +29,7 @@ logger = logging.getLogger(__name__)
SETUP_TIME_THRESHOLD = 10
class Trainable(object):
class Trainable:
"""Abstract class for trainable models, functions, etc.
A call to ``train()`` on a trainable will execute one logical iteration of

View file

@ -32,7 +32,7 @@ def date_str():
return datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
class Location(object):
class Location:
"""Describes the location at which Trial is placed to run."""
def __init__(self, hostname=None, pid=None):
@ -48,7 +48,7 @@ class Location(object):
return "{}:{}".format(self.hostname, self.pid)
class ExportFormat(object):
class ExportFormat:
"""Describes the format to export the trial Trainable.
This may correspond to different file formats based on the
@ -73,7 +73,7 @@ class ExportFormat(object):
export_formats[i])
class Trial(object):
class Trial:
"""A trial object holds the state for one model training run.
Trials are themselves managed by the TrialRunner class, which implements

View file

@ -11,7 +11,7 @@ from ray.tune.error import TuneError
logger = logging.getLogger(__name__)
class TrialExecutor(object):
class TrialExecutor:
"""Manages platform-specific details such as resource handling
and starting/stopping trials.
"""

View file

@ -77,7 +77,7 @@ class _TuneFunctionDecoder(json.JSONDecoder):
return cloudpickle.loads(hex_to_binary(obj["value"]))
class TrialRunner(object):
class TrialRunner:
"""A TrialRunner implements the event loop for scheduling trials on Ray.
Example:

View file

@ -111,7 +111,7 @@ def get_pinned_object(pinned_id):
return ray.get(pinned_id)
class warn_if_slow(object):
class warn_if_slow:
"""Prints a warning if a given operation is slower than 100ms.
Example:

View file

@ -24,7 +24,7 @@ except ImportError:
"Be sure to install it on the client side.")
class TuneClient(object):
class TuneClient:
"""Client to interact with an ongoing Tune experiment.
Requires a TuneServer to have started running.

View file

@ -72,7 +72,7 @@ except ImportError:
setproctitle = None
class ActorCheckpointInfo(object):
class ActorCheckpointInfo:
"""Information used to maintain actor checkpoints."""
__slots__ = [
@ -91,7 +91,7 @@ class ActorCheckpointInfo(object):
self.checkpoint_ids = checkpoint_ids
class Worker(object):
class Worker:
"""A class used to define the control flow of a worker process.
Note:
@ -1707,7 +1707,7 @@ def remote(*args, **kwargs):
return 1
@ray.remote
class Foo(object):
class Foo:
def method(self):
return 1
@ -1743,7 +1743,7 @@ def remote(*args, **kwargs):
return 1, 2
@ray.remote(num_cpus=2, resources={"CustomResource": 1})
class Foo(object):
class Foo:
def method(self):
return 1
@ -1759,7 +1759,7 @@ def remote(*args, **kwargs):
g = f.options(num_gpus=2, max_calls=None)
@ray.remote(num_cpus=2, resources={"CustomResource": 1})
class Foo(object):
class Foo:
def method(self):
return 1
Bar = Foo.options(num_cpus=1, resources=None)

View file

@ -17,7 +17,7 @@ from ray.rllib.utils import try_import_tf
tf = try_import_tf()
class A3CLoss(object):
class A3CLoss:
def __init__(self,
action_dist,
actions,
@ -73,7 +73,7 @@ def add_value_function_fetch(policy):
return {SampleBatch.VF_PREDS: policy.model.value_function()}
class ValueNetworkMixin(object):
class ValueNetworkMixin:
def __init__(self):
@make_tf_callable(self.get_session())
def value(ob, prev_action, prev_reward, *state):
@ -94,8 +94,7 @@ def stats(policy, train_batch):
"cur_lr": tf.cast(policy.cur_lr, tf.float64),
"policy_loss": policy.loss.pi_loss,
"policy_entropy": policy.loss.entropy,
"var_gnorm": tf.global_norm(
list(policy.model.trainable_variables())),
"var_gnorm": tf.global_norm(list(policy.model.trainable_variables())),
"vf_loss": policy.loss.vf_loss,
}

View file

@ -69,7 +69,7 @@ def torch_optimizer(policy, config):
return torch.optim.Adam(policy.model.parameters(), lr=config["lr"])
class ValueNetworkMixin(object):
class ValueNetworkMixin:
def _value(self, obs):
obs = torch.from_numpy(obs).float().unsqueeze(0).to(self.device)
_ = self.model({"obs": obs}, [], [1])

View file

@ -55,7 +55,7 @@ def create_shared_noise(count):
return noise
class SharedNoiseTable(object):
class SharedNoiseTable:
def __init__(self, noise):
self.noise = noise
assert self.noise.dtype == np.float32
@ -72,7 +72,7 @@ class SharedNoiseTable(object):
@ray.remote
class Worker(object):
class Worker:
def __init__(self, config, env_creator, noise, min_task_runtime=0.2):
self.min_task_runtime = min_task_runtime
self.config = config

View file

@ -8,7 +8,7 @@ from __future__ import print_function
import numpy as np
class Optimizer(object):
class Optimizer:
def __init__(self, policy):
self.policy = policy
self.dim = policy.num_params

View file

@ -56,7 +56,7 @@ def rollout(policy, env, timestep_limit=None, add_noise=False, offset=0):
return rews, t
class GenericPolicy(object):
class GenericPolicy:
def __init__(self,
sess,
action_space,

View file

@ -32,7 +32,7 @@ TWIN_Q_TARGET_SCOPE = "twin_target_critic"
PRIO_WEIGHTS = "weights"
class DDPGPostprocessing(object):
class DDPGPostprocessing:
"""Implements n-step learning and param noise adjustments."""
@override(Policy)

Some files were not shown because too many files have changed in this diff Show more