diff --git a/python/ray/actor.py b/python/ray/actor.py index 0d22ed9f5..49b928f58 100644 --- a/python/ray/actor.py +++ b/python/ray/actor.py @@ -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 diff --git a/python/ray/autoscaler/autoscaler.py b/python/ray/autoscaler/autoscaler.py index e6b9e5c68..dd399b721 100644 --- a/python/ray/autoscaler/autoscaler.py +++ b/python/ray/autoscaler/autoscaler.py @@ -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 diff --git a/python/ray/autoscaler/local/node_provider.py b/python/ray/autoscaler/local/node_provider.py index 5996c0ca9..e4f9fc8bc 100644 --- a/python/ray/autoscaler/local/node_provider.py +++ b/python/ray/autoscaler/local/node_provider.py @@ -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) diff --git a/python/ray/autoscaler/log_timer.py b/python/ray/autoscaler/log_timer.py index 7506257d5..723d7a71c 100644 --- a/python/ray/autoscaler/log_timer.py +++ b/python/ray/autoscaler/log_timer.py @@ -8,7 +8,7 @@ import logging logger = logging.getLogger(__name__) -class LogTimer(object): +class LogTimer: def __init__(self, message): self._message = message diff --git a/python/ray/autoscaler/node_provider.py b/python/ray/autoscaler/node_provider.py index c9b0c9164..d8953e530 100644 --- a/python/ray/autoscaler/node_provider.py +++ b/python/ray/autoscaler/node_provider.py @@ -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 diff --git a/python/ray/autoscaler/updater.py b/python/ray/autoscaler/updater.py index ee93f9734..f200fe1f8 100644 --- a/python/ray/autoscaler/updater.py +++ b/python/ray/autoscaler/updater.py @@ -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, diff --git a/python/ray/cluster_utils.py b/python/ray/cluster_utils.py index 2a7cc0580..0c7988f80 100644 --- a/python/ray/cluster_utils.py +++ b/python/ray/cluster_utils.py @@ -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, diff --git a/python/ray/dashboard/dashboard.py b/python/ray/dashboard/dashboard.py index c7deba529..c43ac3400 100644 --- a/python/ray/dashboard/dashboard.py +++ b/python/ray/dashboard/dashboard.py @@ -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 diff --git a/python/ray/experimental/actor_pool.py b/python/ray/experimental/actor_pool.py index 34a97ba0b..4deef58f5 100644 --- a/python/ray/experimental/actor_pool.py +++ b/python/ray/experimental/actor_pool.py @@ -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: diff --git a/python/ray/experimental/array/distributed/core.py b/python/ray/experimental/array/distributed/core.py index 992d4375c..af758d528 100644 --- a/python/ray/experimental/array/distributed/core.py +++ b/python/ray/experimental/array/distributed/core.py @@ -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) diff --git a/python/ray/experimental/async_api.py b/python/ray/experimental/async_api.py index 2a3a6fad2..5cbbc929e 100644 --- a/python/ray/experimental/async_api.py +++ b/python/ray/experimental/async_api.py @@ -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. diff --git a/python/ray/experimental/gcs_flush_policy.py b/python/ray/experimental/gcs_flush_policy.py index 1d1717f03..36e5ae701 100644 --- a/python/ray/experimental/gcs_flush_policy.py +++ b/python/ray/experimental/gcs_flush_policy.py @@ -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. diff --git a/python/ray/experimental/multiprocessing/pool.py b/python/ray/experimental/multiprocessing/pool.py index f9184c1b6..e0e6b06ec 100644 --- a/python/ray/experimental/multiprocessing/pool.py +++ b/python/ray/experimental/multiprocessing/pool.py @@ -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: diff --git a/python/ray/experimental/no_return.py b/python/ray/experimental/no_return.py index 8903942d9..e9dc0e754 100644 --- a/python/ray/experimental/no_return.py +++ b/python/ray/experimental/no_return.py @@ -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 diff --git a/python/ray/experimental/queue.py b/python/ray/experimental/queue.py index d2cc9f434..0102e36d9 100644 --- a/python/ray/experimental/queue.py +++ b/python/ray/experimental/queue.py @@ -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) diff --git a/python/ray/experimental/serve/tests/test_metric.py b/python/ray/experimental/serve/tests/test_metric.py index fde360d00..54e0ac6db 100644 --- a/python/ray/experimental/serve/tests/test_metric.py +++ b/python/ray/experimental/serve/tests/test_metric.py @@ -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 diff --git a/python/ray/experimental/sgd/pytorch/pytorch_runner.py b/python/ray/experimental/sgd/pytorch/pytorch_runner.py index bee87d516..4f3db0e22 100644 --- a/python/ray/experimental/sgd/pytorch/pytorch_runner.py +++ b/python/ray/experimental/sgd/pytorch/pytorch_runner.py @@ -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, diff --git a/python/ray/experimental/sgd/pytorch/pytorch_trainer.py b/python/ray/experimental/sgd/pytorch/pytorch_trainer.py index c73636f81..1eda6e56f 100644 --- a/python/ray/experimental/sgd/pytorch/pytorch_trainer.py +++ b/python/ray/experimental/sgd/pytorch/pytorch_trainer.py @@ -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 diff --git a/python/ray/experimental/sgd/pytorch/utils.py b/python/ray/experimental/sgd/pytorch/utils.py index 22c98d0bf..4e60df2a4 100644 --- a/python/ray/experimental/sgd/pytorch/utils.py +++ b/python/ray/experimental/sgd/pytorch/utils.py @@ -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): diff --git a/python/ray/experimental/sgd/tf/tf_runner.py b/python/ray/experimental/sgd/tf/tf_runner.py index 3e9d2b9b9..13903c073 100644 --- a/python/ray/experimental/sgd/tf/tf_runner.py +++ b/python/ray/experimental/sgd/tf/tf_runner.py @@ -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, diff --git a/python/ray/experimental/sgd/tf/tf_trainer.py b/python/ray/experimental/sgd/tf/tf_trainer.py index 28cb831b7..eed8f7f72 100644 --- a/python/ray/experimental/sgd/tf/tf_trainer.py +++ b/python/ray/experimental/sgd/tf/tf_trainer.py @@ -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, diff --git a/python/ray/experimental/sgd/utils.py b/python/ray/experimental/sgd/utils.py index 005f80e4c..ce6ab7c6f 100644 --- a/python/ray/experimental/sgd/utils.py +++ b/python/ray/experimental/sgd/utils.py @@ -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): diff --git a/python/ray/experimental/signal.py b/python/ray/experimental/signal.py index 147af8a0a..d7d4ef56b 100644 --- a/python/ray/experimental/signal.py +++ b/python/ray/experimental/signal.py @@ -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 diff --git a/python/ray/experimental/tf_utils.py b/python/ray/experimental/tf_utils.py index 900cc948b..99c657562 100644 --- a/python/ray/experimental/tf_utils.py +++ b/python/ray/experimental/tf_utils.py @@ -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: diff --git a/python/ray/function_manager.py b/python/ray/function_manager.py index bd9b2bf8c..ece7ccf96 100644 --- a/python/ray/function_manager.py +++ b/python/ray/function_manager.py @@ -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): diff --git a/python/ray/import_thread.py b/python/ray/import_thread.py index 0e564bc66..364982cf2 100644 --- a/python/ray/import_thread.py +++ b/python/ray/import_thread.py @@ -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 diff --git a/python/ray/local_mode_manager.py b/python/ray/local_mode_manager.py index 11d74784a..d86e75237 100644 --- a/python/ray/local_mode_manager.py +++ b/python/ray/local_mode_manager.py @@ -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): diff --git a/python/ray/log_monitor.py b/python/ray/log_monitor.py index 37239950e..645200e93 100644 --- a/python/ray/log_monitor.py +++ b/python/ray/log_monitor.py @@ -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 diff --git a/python/ray/memory_monitor.py b/python/ray/memory_monitor.py index a6eabf667..3928ecb8e 100644 --- a/python/ray/memory_monitor.py +++ b/python/ray/memory_monitor.py @@ -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 diff --git a/python/ray/monitor.py b/python/ray/monitor.py index caa02a82c..6658a708a 100644 --- a/python/ray/monitor.py +++ b/python/ray/monitor.py @@ -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 diff --git a/python/ray/node.py b/python/ray/node.py index 811709048..4b7838730 100644 --- a/python/ray/node.py +++ b/python/ray/node.py @@ -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): diff --git a/python/ray/parameter.py b/python/ray/parameter.py index 65d02805f..e88cacc60 100644 --- a/python/ray/parameter.py +++ b/python/ray/parameter.py @@ -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: diff --git a/python/ray/profiling.py b/python/ray/profiling.py index e6e36f953..b39410df5 100644 --- a/python/ray/profiling.py +++ b/python/ray/profiling.py @@ -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): diff --git a/python/ray/projects/scripts.py b/python/ray/projects/scripts.py index 028f1ac6f..bd36a79bb 100644 --- a/python/ray/projects/scripts.py +++ b/python/ray/projects/scripts.py @@ -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): diff --git a/python/ray/ray_perf.py b/python/ray/ray_perf.py index 99ca4d886..bcda18792 100644 --- a/python/ray/ray_perf.py +++ b/python/ray/ray_perf.py @@ -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] diff --git a/python/ray/remote_function.py b/python/ray/remote_function.py index bb869d4ee..c6ff8b276 100644 --- a/python/ray/remote_function.py +++ b/python/ray/remote_function.py @@ -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) diff --git a/python/ray/reporter.py b/python/ray/reporter.py index be009172a..65c44d617 100644 --- a/python/ray/reporter.py +++ b/python/ray/reporter.py @@ -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: diff --git a/python/ray/runtime_context.py b/python/ray/runtime_context.py index 0c1c88e00..dec103ca9 100644 --- a/python/ray/runtime_context.py +++ b/python/ray/runtime_context.py @@ -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): diff --git a/python/ray/serialization.py b/python/ray/serialization.py index 7e0c07ea0..2fbe13683 100644 --- a/python/ray/serialization.py +++ b/python/ray/serialization.py @@ -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 diff --git a/python/ray/state.py b/python/ray/state.py index ad56392e6..8f6e50688 100644 --- a/python/ray/state.py +++ b/python/ray/state.py @@ -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 diff --git a/python/ray/tests/py3_test.py b/python/ray/tests/py3_test.py index abc547b72..3a7cd864f 100644 --- a/python/ray/tests/py3_test.py +++ b/python/ray/tests/py3_test.py @@ -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() diff --git a/python/ray/tests/test_actor.py b/python/ray/tests/test_actor.py index 77a9b900f..9c43c65fc 100644 --- a/python/ray/tests/test_actor.py +++ b/python/ray/tests/test_actor.py @@ -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 diff --git a/python/ray/tests/test_actor_failures.py b/python/ray/tests/test_actor_failures.py index a0d07b6f8..67dc2cecf 100644 --- a/python/ray/tests/test_actor_failures.py +++ b/python/ray/tests/test_actor_failures.py @@ -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 diff --git a/python/ray/tests/test_actor_pool.py b/python/ray/tests/test_actor_pool.py index a45e15a10..1822991a3 100644 --- a/python/ray/tests/test_actor_pool.py +++ b/python/ray/tests/test_actor_pool.py @@ -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 diff --git a/python/ray/tests/test_actor_resources.py b/python/ray/tests/test_actor_resources.py index 2ea3bac8a..e919d6832 100644 --- a/python/ray/tests/test_actor_resources.py +++ b/python/ray/tests/test_actor_resources.py @@ -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 diff --git a/python/ray/tests/test_advanced.py b/python/ray/tests/test_advanced.py index 43074c60d..262c6f8a4 100644 --- a/python/ray/tests/test_advanced.py +++ b/python/ray/tests/test_advanced.py @@ -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) diff --git a/python/ray/tests/test_advanced_2.py b/python/ray/tests/test_advanced_2.py index 03c0b11a8..a9e50bd1f 100644 --- a/python/ray/tests/test_advanced_2.py +++ b/python/ray/tests/test_advanced_2.py @@ -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 diff --git a/python/ray/tests/test_advanced_3.py b/python/ray/tests/test_advanced_3.py index 52089844c..f7d56f735 100644 --- a/python/ray/tests/test_advanced_3.py +++ b/python/ray/tests/test_advanced_3.py @@ -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") diff --git a/python/ray/tests/test_autoscaler.py b/python/ray/tests/test_autoscaler.py index 46108f645..ff23e70f9 100644 --- a/python/ray/tests/test_autoscaler.py +++ b/python/ray/tests/test_autoscaler.py @@ -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 diff --git a/python/ray/tests/test_basic.py b/python/ray/tests/test_basic.py index 8a875209b..bc190cb78 100644 --- a/python/ray/tests/test_basic.py +++ b/python/ray/tests/test_basic.py @@ -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() diff --git a/python/ray/tests/test_component_failures_3.py b/python/ray/tests/test_component_failures_3.py index 029fdcd2d..e8164881b 100644 --- a/python/ray/tests/test_component_failures_3.py +++ b/python/ray/tests/test_component_failures_3.py @@ -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 diff --git a/python/ray/tests/test_dynres.py b/python/ray/tests/test_dynres.py index 50d782c37..3dbdc0594 100644 --- a/python/ray/tests/test_dynres.py +++ b/python/ray/tests/test_dynres.py @@ -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()) diff --git a/python/ray/tests/test_failure.py b/python/ray/tests/test_failure.py index 680d27ed8..0669e0a98 100644 --- a/python/ray/tests/test_failure.py +++ b/python/ray/tests/test_failure.py @@ -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) diff --git a/python/ray/tests/test_garbage_collection.py b/python/ray/tests/test_garbage_collection.py index bc2e20565..b6ce12501 100644 --- a/python/ray/tests/test_garbage_collection.py +++ b/python/ray/tests/test_garbage_collection.py @@ -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. diff --git a/python/ray/tests/test_memory_limits.py b/python/ray/tests/test_memory_limits.py index c19021a6a..03a1c3861 100644 --- a/python/ray/tests/test_memory_limits.py +++ b/python/ray/tests/test_memory_limits.py @@ -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 diff --git a/python/ray/tests/test_memory_scheduling.py b/python/ray/tests/test_memory_scheduling.py index ebcebd54b..7e067cb32 100644 --- a/python/ray/tests/test_memory_scheduling.py +++ b/python/ray/tests/test_memory_scheduling.py @@ -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 diff --git a/python/ray/tests/test_metrics.py b/python/ray/tests/test_metrics.py index 473a41fb4..46c33917d 100644 --- a/python/ray/tests/test_metrics.py +++ b/python/ray/tests/test_metrics.py @@ -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()] diff --git a/python/ray/tests/test_mini.py b/python/ray/tests/test_mini.py index b4e630080..605b91056 100644 --- a/python/ray/tests/test_mini.py +++ b/python/ray/tests/test_mini.py @@ -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 diff --git a/python/ray/tests/test_multi_node.py b/python/ray/tests/test_multi_node.py index 65506d664..4eb83a529 100644 --- a/python/ray/tests/test_multi_node.py +++ b/python/ray/tests/test_multi_node.py @@ -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 diff --git a/python/ray/tests/test_multi_node_2.py b/python/ray/tests/test_multi_node_2.py index 4608e490b..fa986e1d8 100644 --- a/python/ray/tests/test_multi_node_2.py +++ b/python/ray/tests/test_multi_node_2.py @@ -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 diff --git a/python/ray/tests/test_multinode_failures_2.py b/python/ray/tests/test_multinode_failures_2.py index 879aa9231..f03fee580 100644 --- a/python/ray/tests/test_multinode_failures_2.py +++ b/python/ray/tests/test_multinode_failures_2.py @@ -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 diff --git a/python/ray/tests/test_object_manager.py b/python/ray/tests/test_object_manager.py index f6eee16e1..186189f20 100644 --- a/python/ray/tests/test_object_manager.py +++ b/python/ray/tests/test_object_manager.py @@ -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 diff --git a/python/ray/tests/test_ray_init.py b/python/ray/tests/test_ray_init.py index 8ce3f07d8..cf3ecf4cd 100644 --- a/python/ray/tests/test_ray_init.py +++ b/python/ray/tests/test_ray_init.py @@ -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.") diff --git a/python/ray/tests/test_signal.py b/python/ray/tests/test_signal.py index 078fe5a3f..af41c5126 100644 --- a/python/ray/tests/test_signal.py +++ b/python/ray/tests/test_signal.py @@ -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 diff --git a/python/ray/tests/test_stress_sharded.py b/python/ray/tests/test_stress_sharded.py index ec738a385..a55ba2503 100644 --- a/python/ray/tests/test_stress_sharded.py +++ b/python/ray/tests/test_stress_sharded.py @@ -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 diff --git a/python/ray/tests/test_tensorflow.py b/python/ray/tests/test_tensorflow.py index 9e15f8616..56f02fcc4 100644 --- a/python/ray/tests/test_tensorflow.py +++ b/python/ray/tests/test_tensorflow.py @@ -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. diff --git a/python/ray/tune/analysis/experiment_analysis.py b/python/ray/tune/analysis/experiment_analysis.py index 0ebe99192..794bd5d64 100644 --- a/python/ray/tune/analysis/experiment_analysis.py +++ b/python/ray/tune/analysis/experiment_analysis.py @@ -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): diff --git a/python/ray/tune/automl/search_space.py b/python/ray/tune/automl/search_space.py index 65db657e8..2f7743c69 100644 --- a/python/ray/tune/automl/search_space.py +++ b/python/ray/tune/automl/search_space.py @@ -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 pair. It's supposed to be used with a fixed experiment config, which diff --git a/python/ray/tune/automlboard/backend/collector.py b/python/ray/tune/automlboard/backend/collector.py index dd87df1a4..f9b1bd488 100644 --- a/python/ray/tune/automlboard/backend/collector.py +++ b/python/ray/tune/automlboard/backend/collector.py @@ -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 diff --git a/python/ray/tune/checkpoint_manager.py b/python/ray/tune/checkpoint_manager.py index 1ef0f6e20..c386d34d3 100644 --- a/python/ray/tune/checkpoint_manager.py +++ b/python/ray/tune/checkpoint_manager.py @@ -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): diff --git a/python/ray/tune/experiment.py b/python/ray/tune/experiment.py index cff078b43..422769018 100644 --- a/python/ray/tune/experiment.py +++ b/python/ray/tune/experiment.py @@ -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. diff --git a/python/ray/tune/function_runner.py b/python/ray/tune/function_runner.py index 6787ad6cf..ddbb85b95 100644 --- a/python/ray/tune/function_runner.py +++ b/python/ray/tune/function_runner.py @@ -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: diff --git a/python/ray/tune/logger.py b/python/ray/tune/logger.py index 5ee4ea3f5..1fd8dc0e1 100644 --- a/python/ray/tune/logger.py +++ b/python/ray/tune/logger.py @@ -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 diff --git a/python/ray/tune/progress_reporter.py b/python/ray/tune/progress_reporter.py index 3d6d86b55..34a1de5fe 100644 --- a/python/ray/tune/progress_reporter.py +++ b/python/ray/tune/progress_reporter.py @@ -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): diff --git a/python/ray/tune/ray_trial_executor.py b/python/ray/tune/ray_trial_executor.py index 86cb6d5a7..1c763f37b 100644 --- a/python/ray/tune/ray_trial_executor.py +++ b/python/ray/tune/ray_trial_executor.py @@ -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 diff --git a/python/ray/tune/registry.py b/python/ray/tune/registry.py index 80d78e70f..9b5b178c9 100644 --- a/python/ray/tune/registry.py +++ b/python/ray/tune/registry.py @@ -98,7 +98,7 @@ def _make_key(category, key): key.encode("ascii")) -class _Registry(object): +class _Registry: def __init__(self): self._to_flush = {} diff --git a/python/ray/tune/sample.py b/python/ray/tune/sample.py index ae457f374..5cfb11c7f 100644 --- a/python/ray/tune/sample.py +++ b/python/ray/tune/sample.py @@ -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: diff --git a/python/ray/tune/schedulers/hyperband.py b/python/ray/tune/schedulers/hyperband.py index 2ed6ecfdf..66188028f 100644 --- a/python/ray/tune/schedulers/hyperband.py +++ b/python/ray/tune/schedulers/hyperband.py @@ -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. diff --git a/python/ray/tune/schedulers/pbt.py b/python/ray/tune/schedulers/pbt.py index 67aab6b33..fa0f8c416 100644 --- a/python/ray/tune/schedulers/pbt.py +++ b/python/ray/tune/schedulers/pbt.py @@ -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): diff --git a/python/ray/tune/schedulers/trial_scheduler.py b/python/ray/tune/schedulers/trial_scheduler.py index 15fa3cb4c..2e85ac90f 100644 --- a/python/ray/tune/schedulers/trial_scheduler.py +++ b/python/ray/tune/schedulers/trial_scheduler.py @@ -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 diff --git a/python/ray/tune/suggest/search.py b/python/ray/tune/suggest/search.py index 89c0d26f9..f18f7e3ac 100644 --- a/python/ray/tune/suggest/search.py +++ b/python/ray/tune/suggest/search.py @@ -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 diff --git a/python/ray/tune/sync_client.py b/python/ray/tune/sync_client.py index 9579af836..a6a1ef144 100644 --- a/python/ray/tune/sync_client.py +++ b/python/ray/tune/sync_client.py @@ -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): diff --git a/python/ray/tune/syncer.py b/python/ray/tune/syncer.py index 80d482b60..a4c69fc2b 100644 --- a/python/ray/tune/syncer.py +++ b/python/ray/tune/syncer.py @@ -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. diff --git a/python/ray/tune/tests/test_api.py b/python/ray/tune/tests/test_api.py index f7d34d662..8b0ed184e 100644 --- a/python/ray/tune/tests/test_api.py +++ b/python/ray/tune/tests/test_api.py @@ -192,7 +192,7 @@ class TrainableFunctionApiTest(unittest.TestCase): def train(config, reporter): pass - class A(object): + class A: pass class B(Trainable): diff --git a/python/ray/tune/tests/test_commands.py b/python/ray/tune/tests/test_commands.py index e82f21d34..6ce21dd77 100644 --- a/python/ray/tune/tests/test_commands.py +++ b/python/ray/tune/tests/test_commands.py @@ -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() diff --git a/python/ray/tune/tests/test_tune_restore.py b/python/ray/tune/tests/test_tune_restore.py index b24a755a5..fb8218fc7 100644 --- a/python/ray/tune/tests/test_tune_restore.py +++ b/python/ray/tune/tests/test_tune_restore.py @@ -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() diff --git a/python/ray/tune/track/session.py b/python/ray/tune/track/session.py index 6f02c14cd..af9600729 100644 --- a/python/ray/tune/track/session.py +++ b/python/ray/tune/track/session.py @@ -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. diff --git a/python/ray/tune/trainable.py b/python/ray/tune/trainable.py index 98d529945..ae9c45df6 100644 --- a/python/ray/tune/trainable.py +++ b/python/ray/tune/trainable.py @@ -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 diff --git a/python/ray/tune/trial.py b/python/ray/tune/trial.py index 7ee547921..055352f0c 100644 --- a/python/ray/tune/trial.py +++ b/python/ray/tune/trial.py @@ -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 diff --git a/python/ray/tune/trial_executor.py b/python/ray/tune/trial_executor.py index 859cb23eb..3230d5089 100644 --- a/python/ray/tune/trial_executor.py +++ b/python/ray/tune/trial_executor.py @@ -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. """ diff --git a/python/ray/tune/trial_runner.py b/python/ray/tune/trial_runner.py index 80bbcbe57..f78bdc8ac 100644 --- a/python/ray/tune/trial_runner.py +++ b/python/ray/tune/trial_runner.py @@ -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: diff --git a/python/ray/tune/util.py b/python/ray/tune/util.py index 99c1eace7..0a9dec3f6 100644 --- a/python/ray/tune/util.py +++ b/python/ray/tune/util.py @@ -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: diff --git a/python/ray/tune/web_server.py b/python/ray/tune/web_server.py index b7e8783f2..9b9da1946 100644 --- a/python/ray/tune/web_server.py +++ b/python/ray/tune/web_server.py @@ -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. diff --git a/python/ray/worker.py b/python/ray/worker.py index 13a2593a7..0ab13218a 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -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) diff --git a/rllib/agents/a3c/a3c_tf_policy.py b/rllib/agents/a3c/a3c_tf_policy.py index 2bb5d8bae..6aed17c0a 100644 --- a/rllib/agents/a3c/a3c_tf_policy.py +++ b/rllib/agents/a3c/a3c_tf_policy.py @@ -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, } diff --git a/rllib/agents/a3c/a3c_torch_policy.py b/rllib/agents/a3c/a3c_torch_policy.py index f12e817e0..e69b13a14 100644 --- a/rllib/agents/a3c/a3c_torch_policy.py +++ b/rllib/agents/a3c/a3c_torch_policy.py @@ -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]) diff --git a/rllib/agents/ars/ars.py b/rllib/agents/ars/ars.py index 4330f0d90..f461e24c5 100644 --- a/rllib/agents/ars/ars.py +++ b/rllib/agents/ars/ars.py @@ -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 diff --git a/rllib/agents/ars/optimizers.py b/rllib/agents/ars/optimizers.py index 0e6420bb2..5297c1ad7 100644 --- a/rllib/agents/ars/optimizers.py +++ b/rllib/agents/ars/optimizers.py @@ -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 diff --git a/rllib/agents/ars/policies.py b/rllib/agents/ars/policies.py index ce3e837a3..1ce059410 100644 --- a/rllib/agents/ars/policies.py +++ b/rllib/agents/ars/policies.py @@ -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, diff --git a/rllib/agents/ddpg/ddpg_policy.py b/rllib/agents/ddpg/ddpg_policy.py index 95e4bd121..caf2754ef 100644 --- a/rllib/agents/ddpg/ddpg_policy.py +++ b/rllib/agents/ddpg/ddpg_policy.py @@ -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) diff --git a/rllib/agents/dqn/dqn_policy.py b/rllib/agents/dqn/dqn_policy.py index dbfb6488f..044eb9cd2 100644 --- a/rllib/agents/dqn/dqn_policy.py +++ b/rllib/agents/dqn/dqn_policy.py @@ -30,7 +30,7 @@ Q_TARGET_SCOPE = "target_q_func" PRIO_WEIGHTS = "weights" -class QLoss(object): +class QLoss: def __init__(self, q_t_selected, q_logits_t_selected, @@ -107,7 +107,7 @@ class QLoss(object): } -class QValuePolicy(object): +class QValuePolicy: def __init__(self, q_values, observations, num_actions, cur_epsilon, softmax, softmax_temp, model_config): if softmax: @@ -135,7 +135,7 @@ class QValuePolicy(object): self.action_prob = None -class ComputeTDErrorMixin(object): +class ComputeTDErrorMixin: def __init__(self): @make_tf_callable(self.get_session(), dynamic_shape=True) def compute_td_error(obs_t, act_t, rew_t, obs_tp1, done_mask, diff --git a/rllib/agents/dqn/simple_q_policy.py b/rllib/agents/dqn/simple_q_policy.py index 996a62786..ee8dfe24c 100644 --- a/rllib/agents/dqn/simple_q_policy.py +++ b/rllib/agents/dqn/simple_q_policy.py @@ -25,7 +25,7 @@ Q_SCOPE = "q_func" Q_TARGET_SCOPE = "target_q_func" -class ExplorationStateMixin(object): +class ExplorationStateMixin: def __init__(self, obs_space, action_space, config): # Python value, should always be same as the TF variable self.cur_epsilon_value = 1.0 @@ -55,7 +55,7 @@ class ExplorationStateMixin(object): self.set_epsilon(state[1]) -class TargetNetworkMixin(object): +class TargetNetworkMixin: def __init__(self, obs_space, action_space, config): @make_tf_callable(self.get_session()) def do_update(): diff --git a/rllib/agents/es/es.py b/rllib/agents/es/es.py index f5338a632..e4c8ddc2b 100644 --- a/rllib/agents/es/es.py +++ b/rllib/agents/es/es.py @@ -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 @@ -68,7 +68,7 @@ class SharedNoiseTable(object): @ray.remote -class Worker(object): +class Worker: def __init__(self, config, policy_params, diff --git a/rllib/agents/es/optimizers.py b/rllib/agents/es/optimizers.py index 3b48f7393..726a90635 100644 --- a/rllib/agents/es/optimizers.py +++ b/rllib/agents/es/optimizers.py @@ -8,7 +8,7 @@ from __future__ import print_function import numpy as np -class Optimizer(object): +class Optimizer: def __init__(self, pi): self.pi = pi self.dim = pi.num_params diff --git a/rllib/agents/es/policies.py b/rllib/agents/es/policies.py index 3ddb4dbed..8184bab5b 100644 --- a/rllib/agents/es/policies.py +++ b/rllib/agents/es/policies.py @@ -41,7 +41,7 @@ def rollout(policy, env, timestep_limit=None, add_noise=False): return rews, t -class GenericPolicy(object): +class GenericPolicy: def __init__(self, sess, action_space, obs_space, preprocessor, observation_filter, model_options, action_noise_std): self.sess = sess diff --git a/rllib/agents/impala/impala.py b/rllib/agents/impala/impala.py index e83c4ca65..6b3ef79e1 100644 --- a/rllib/agents/impala/impala.py +++ b/rllib/agents/impala/impala.py @@ -139,7 +139,7 @@ def make_aggregators_and_optimizer(workers, config): return optimizer -class OverrideDefaultResourceRequest(object): +class OverrideDefaultResourceRequest: @classmethod @override(Trainable) def default_resource_request(cls, config): diff --git a/rllib/agents/impala/vtrace_policy.py b/rllib/agents/impala/vtrace_policy.py index 7e51a9959..17212aff4 100644 --- a/rllib/agents/impala/vtrace_policy.py +++ b/rllib/agents/impala/vtrace_policy.py @@ -27,7 +27,7 @@ logger = logging.getLogger(__name__) BEHAVIOUR_LOGITS = "behaviour_logits" -class VTraceLoss(object): +class VTraceLoss: def __init__(self, actions, actions_logp, diff --git a/rllib/agents/marwil/marwil_policy.py b/rllib/agents/marwil/marwil_policy.py index 72b8a2393..f271b78d2 100644 --- a/rllib/agents/marwil/marwil_policy.py +++ b/rllib/agents/marwil/marwil_policy.py @@ -21,13 +21,13 @@ POLICY_SCOPE = "p_func" VALUE_SCOPE = "v_func" -class ValueLoss(object): +class ValueLoss: def __init__(self, state_values, cumulative_rewards): self.loss = 0.5 * tf.reduce_mean( tf.square(state_values - cumulative_rewards)) -class ReweightedImitationLoss(object): +class ReweightedImitationLoss: def __init__(self, state_values, cumulative_rewards, logits, actions, action_space, beta, model): ma_adv_norm = tf.get_variable( @@ -56,7 +56,7 @@ class ReweightedImitationLoss(object): tf.stop_gradient(exp_advs) * logprobs) -class MARWILPostprocessing(object): +class MARWILPostprocessing: """Adds the advantages field to the trajectory.""" @override(Policy) diff --git a/rllib/agents/ppo/appo_policy.py b/rllib/agents/ppo/appo_policy.py index ce439a99e..1d2f899e5 100644 --- a/rllib/agents/ppo/appo_policy.py +++ b/rllib/agents/ppo/appo_policy.py @@ -34,7 +34,7 @@ TARGET_POLICY_SCOPE = "target_func" logger = logging.getLogger(__name__) -class PPOSurrogateLoss(object): +class PPOSurrogateLoss: """Loss used when V-trace is disabled. Arguments: @@ -97,7 +97,7 @@ class PPOSurrogateLoss(object): self.total_loss += cur_kl_coeff * self.mean_kl -class VTraceSurrogateLoss(object): +class VTraceSurrogateLoss: def __init__(self, actions, prev_actions_logp, @@ -407,7 +407,7 @@ def add_values_and_logits(policy): return out -class TargetNetworkMixin(object): +class TargetNetworkMixin: def __init__(self, obs_space, action_space, config): """Target Network is updated by the master learner every trainer.update_target_frequency steps. All worker batches diff --git a/rllib/agents/ppo/ppo_policy.py b/rllib/agents/ppo/ppo_policy.py index 16bb7dbd0..4821c97db 100644 --- a/rllib/agents/ppo/ppo_policy.py +++ b/rllib/agents/ppo/ppo_policy.py @@ -23,7 +23,7 @@ logger = logging.getLogger(__name__) BEHAVIOUR_LOGITS = "behaviour_logits" -class PPOLoss(object): +class PPOLoss: def __init__(self, action_space, dist_class, @@ -211,7 +211,7 @@ def clip_gradients(policy, optimizer, loss): return optimizer.compute_gradients(loss, variables) -class KLCoeffMixin(object): +class KLCoeffMixin: def __init__(self, config): # KL Coefficient self.kl_coeff_val = config["kl_coeff"] @@ -232,7 +232,7 @@ class KLCoeffMixin(object): return self.kl_coeff_val -class ValueNetworkMixin(object): +class ValueNetworkMixin: def __init__(self, obs_space, action_space, config): if config["use_gae"]: diff --git a/rllib/agents/sac/sac_policy.py b/rllib/agents/sac/sac_policy.py index da5cc14d1..99357b7a7 100644 --- a/rllib/agents/sac/sac_policy.py +++ b/rllib/agents/sac/sac_policy.py @@ -320,7 +320,7 @@ def stats(policy, train_batch): } -class ExplorationStateMixin(object): +class ExplorationStateMixin: def __init__(self, obs_space, action_space, config): self.stochastic = tf.get_variable( initializer=tf.constant_initializer(config["exploration_enabled"]), @@ -333,7 +333,7 @@ class ExplorationStateMixin(object): pass -class ActorCriticOptimizerMixin(object): +class ActorCriticOptimizerMixin: def __init__(self, config): # create global step for counting the number of update operations self.global_step = tf.train.get_or_create_global_step() @@ -353,7 +353,7 @@ class ActorCriticOptimizerMixin(object): learning_rate=config["optimization"]["entropy_learning_rate"]) -class ComputeTDErrorMixin(object): +class ComputeTDErrorMixin: def __init__(self): @make_tf_callable(self.get_session(), dynamic_shape=True) def compute_td_error(obs_t, act_t, rew_t, obs_tp1, done_mask, @@ -374,7 +374,7 @@ class ComputeTDErrorMixin(object): self.compute_td_error = compute_td_error -class TargetNetworkMixin(object): +class TargetNetworkMixin: def __init__(self, config): @make_tf_callable(self.get_session()) def update_target_fn(tau): diff --git a/rllib/contrib/alpha_zero/core/mcts.py b/rllib/contrib/alpha_zero/core/mcts.py index c31538236..fd5ce71a0 100644 --- a/rllib/contrib/alpha_zero/core/mcts.py +++ b/rllib/contrib/alpha_zero/core/mcts.py @@ -100,7 +100,7 @@ class Node: current = current.parent -class RootParentNode(object): +class RootParentNode: def __init__(self, env): self.parent = None self.child_total_value = collections.defaultdict(float) diff --git a/rllib/contrib/maddpg/maddpg_policy.py b/rllib/contrib/maddpg/maddpg_policy.py index d0acdaa7c..60befde05 100644 --- a/rllib/contrib/maddpg/maddpg_policy.py +++ b/rllib/contrib/maddpg/maddpg_policy.py @@ -23,7 +23,7 @@ tf = try_import_tf() tfp = try_import_tfp() -class MADDPGPostprocessing(object): +class MADDPGPostprocessing: """Implements agentwise termination signal and n-step learning.""" @override(Policy) diff --git a/rllib/env/base_env.py b/rllib/env/base_env.py index a36c3e228..f862e5c2a 100644 --- a/rllib/env/base_env.py +++ b/rllib/env/base_env.py @@ -12,7 +12,7 @@ ASYNC_RESET_RETURN = "async_reset_return" @PublicAPI -class BaseEnv(object): +class BaseEnv: """The lowest-level env interface used by RLlib for sampling. BaseEnv models multiple agents executing asynchronously in multiple @@ -412,7 +412,7 @@ class _MultiAgentEnvToBaseEnv(BaseEnv): return [state.env for state in self.env_states] -class _MultiAgentEnvState(object): +class _MultiAgentEnvState: def __init__(self, env): assert isinstance(env, MultiAgentEnv) self.env = env diff --git a/rllib/env/external_env.py b/rllib/env/external_env.py index 46d15a2de..562b87418 100644 --- a/rllib/env/external_env.py +++ b/rllib/env/external_env.py @@ -181,7 +181,7 @@ class ExternalEnv(threading.Thread): return self._episodes[episode_id] -class _ExternalEnvEpisode(object): +class _ExternalEnvEpisode: """Tracked state for each active episode.""" def __init__(self, diff --git a/rllib/env/multi_agent_env.py b/rllib/env/multi_agent_env.py index d770215be..7b1f5ce5d 100644 --- a/rllib/env/multi_agent_env.py +++ b/rllib/env/multi_agent_env.py @@ -6,7 +6,7 @@ from ray.rllib.utils.annotations import PublicAPI @PublicAPI -class MultiAgentEnv(object): +class MultiAgentEnv: """An environment that hosts multiple independent agents. Agents are identified by (string) agent ids. Note that these "agents" here diff --git a/rllib/env/remote_vector_env.py b/rllib/env/remote_vector_env.py index 7c891cf3c..d6d6da154 100644 --- a/rllib/env/remote_vector_env.py +++ b/rllib/env/remote_vector_env.py @@ -89,7 +89,7 @@ class RemoteVectorEnv(BaseEnv): @ray.remote(num_cpus=0) -class _RemoteMultiAgentEnv(object): +class _RemoteMultiAgentEnv: """Wrapper class for making a multi-agent env a remote actor.""" def __init__(self, make_env, i): @@ -108,7 +108,7 @@ class _RemoteMultiAgentEnv(object): @ray.remote(num_cpus=0) -class _RemoteSingleAgentEnv(object): +class _RemoteSingleAgentEnv: """Wrapper class for making a gym env a remote actor.""" def __init__(self, make_env, i): diff --git a/rllib/env/vector_env.py b/rllib/env/vector_env.py index d0df24177..66bd8e737 100644 --- a/rllib/env/vector_env.py +++ b/rllib/env/vector_env.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) @PublicAPI -class VectorEnv(object): +class VectorEnv: """An environment that supports batch evaluation. Subclasses must define the following attributes: diff --git a/rllib/evaluation/episode.py b/rllib/evaluation/episode.py index 2ee1d58ee..ab4746b79 100644 --- a/rllib/evaluation/episode.py +++ b/rllib/evaluation/episode.py @@ -12,7 +12,7 @@ from ray.rllib.utils.annotations import DeveloperAPI @DeveloperAPI -class MultiAgentEpisode(object): +class MultiAgentEpisode: """Tracks the current state of a (possibly multi-agent) episode. Attributes: diff --git a/rllib/evaluation/interface.py b/rllib/evaluation/interface.py index 06fa9f94e..739aa55b1 100644 --- a/rllib/evaluation/interface.py +++ b/rllib/evaluation/interface.py @@ -8,7 +8,7 @@ from ray.rllib.utils.annotations import DeveloperAPI @DeveloperAPI -class EvaluatorInterface(object): +class EvaluatorInterface: """This is the interface between policy optimizers and policy evaluation. See also: RolloutWorker diff --git a/rllib/evaluation/postprocessing.py b/rllib/evaluation/postprocessing.py index 6ca49f228..46a19b929 100644 --- a/rllib/evaluation/postprocessing.py +++ b/rllib/evaluation/postprocessing.py @@ -12,7 +12,7 @@ def discount(x, gamma): return scipy.signal.lfilter([1], [1, -gamma], x[::-1], axis=0)[::-1] -class Postprocessing(object): +class Postprocessing: """Constant definitions for postprocessing.""" ADVANTAGES = "advantages" diff --git a/rllib/evaluation/sample_batch_builder.py b/rllib/evaluation/sample_batch_builder.py index 987fb521d..85e608c31 100644 --- a/rllib/evaluation/sample_batch_builder.py +++ b/rllib/evaluation/sample_batch_builder.py @@ -21,7 +21,7 @@ def to_float_array(v): @PublicAPI -class SampleBatchBuilder(object): +class SampleBatchBuilder: """Util to build a SampleBatch incrementally. For efficiency, SampleBatches hold values in column form (as arrays). @@ -66,7 +66,7 @@ class SampleBatchBuilder(object): @DeveloperAPI -class MultiAgentSampleBatchBuilder(object): +class MultiAgentSampleBatchBuilder: """Util to build SampleBatches for each policy in a multi-agent env. Input data is per-agent, while output data is per-policy. There is an M:N diff --git a/rllib/evaluation/sampler.py b/rllib/evaluation/sampler.py index 41a1b4389..5917397ad 100644 --- a/rllib/evaluation/sampler.py +++ b/rllib/evaluation/sampler.py @@ -31,7 +31,7 @@ PolicyEvalData = namedtuple("PolicyEvalData", [ ]) -class PerfStats(object): +class PerfStats: """Sampler perf stats that will be included in rollout metrics.""" def __init__(self): diff --git a/rllib/evaluation/worker_set.py b/rllib/evaluation/worker_set.py index 7a23caa08..e3c39c48e 100644 --- a/rllib/evaluation/worker_set.py +++ b/rllib/evaluation/worker_set.py @@ -19,7 +19,7 @@ logger = logging.getLogger(__name__) @DeveloperAPI -class WorkerSet(object): +class WorkerSet: """Represents a set of RolloutWorkers. There must be one local worker copy, and zero or more remote workers. diff --git a/rllib/examples/centralized_critic.py b/rllib/examples/centralized_critic.py index 90f704046..a9aa5fc23 100644 --- a/rllib/examples/centralized_critic.py +++ b/rllib/examples/centralized_critic.py @@ -84,7 +84,7 @@ class CentralizedCriticModel(TFModelV2): return self.model.value_function() # not used -class CentralizedValueMixin(object): +class CentralizedValueMixin: """Add method to evaluate the central value function from the model.""" def __init__(self): diff --git a/rllib/models/action_dist.py b/rllib/models/action_dist.py index f5a5f1e3c..0b88547d2 100644 --- a/rllib/models/action_dist.py +++ b/rllib/models/action_dist.py @@ -6,7 +6,7 @@ from ray.rllib.utils.annotations import DeveloperAPI @DeveloperAPI -class ActionDistribution(object): +class ActionDistribution: """The policy action distribution of an agent. Attributes: diff --git a/rllib/models/catalog.py b/rllib/models/catalog.py index a43c7e372..c8f1711ff 100644 --- a/rllib/models/catalog.py +++ b/rllib/models/catalog.py @@ -92,7 +92,7 @@ MODEL_DEFAULTS = { @PublicAPI -class ModelCatalog(object): +class ModelCatalog: """Registry of models, preprocessors, and action distributions for envs. Examples: diff --git a/rllib/models/model.py b/rllib/models/model.py index 996179630..bfc2e7a65 100644 --- a/rllib/models/model.py +++ b/rllib/models/model.py @@ -17,7 +17,7 @@ torch, _ = try_import_torch() logger = logging.getLogger(__name__) -class Model(object): +class Model: """This class is deprecated, please use TFModelV2 instead.""" def __init__(self, diff --git a/rllib/models/modelv2.py b/rllib/models/modelv2.py index 568963da0..14165607f 100644 --- a/rllib/models/modelv2.py +++ b/rllib/models/modelv2.py @@ -8,7 +8,7 @@ from ray.rllib.utils.annotations import PublicAPI @PublicAPI -class ModelV2(object): +class ModelV2: """Defines a Keras-style abstract network model for use with RLlib. Custom models should extend either TFModelV2 or TorchModelV2 instead of @@ -205,7 +205,7 @@ class ModelV2(object): return NullContextManager() -class NullContextManager(object): +class NullContextManager: """No-op context manager""" def __init__(self): diff --git a/rllib/models/preprocessors.py b/rllib/models/preprocessors.py index e0a33d9b7..2bf567963 100644 --- a/rllib/models/preprocessors.py +++ b/rllib/models/preprocessors.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) @PublicAPI -class Preprocessor(object): +class Preprocessor: """Defines an abstract observation preprocessor function. Attributes: diff --git a/rllib/offline/input_reader.py b/rllib/offline/input_reader.py index 163a15e1b..240c4b3b1 100644 --- a/rllib/offline/input_reader.py +++ b/rllib/offline/input_reader.py @@ -16,7 +16,7 @@ logger = logging.getLogger(__name__) @PublicAPI -class InputReader(object): +class InputReader: """Input object for loading experiences in policy evaluation.""" @PublicAPI diff --git a/rllib/offline/io_context.py b/rllib/offline/io_context.py index 58f7f03c5..183bd5994 100644 --- a/rllib/offline/io_context.py +++ b/rllib/offline/io_context.py @@ -8,7 +8,7 @@ from ray.rllib.utils.annotations import PublicAPI @PublicAPI -class IOContext(object): +class IOContext: """Attributes to pass to input / output class constructors. RLlib auto-sets these attributes when constructing input / output classes. diff --git a/rllib/offline/off_policy_estimator.py b/rllib/offline/off_policy_estimator.py index 9d369f715..c90bcaec9 100644 --- a/rllib/offline/off_policy_estimator.py +++ b/rllib/offline/off_policy_estimator.py @@ -15,7 +15,7 @@ OffPolicyEstimate = namedtuple("OffPolicyEstimate", @DeveloperAPI -class OffPolicyEstimator(object): +class OffPolicyEstimator: """Interface for an off policy reward estimator.""" @DeveloperAPI diff --git a/rllib/offline/output_writer.py b/rllib/offline/output_writer.py index 003f073ec..13033b240 100644 --- a/rllib/offline/output_writer.py +++ b/rllib/offline/output_writer.py @@ -7,7 +7,7 @@ from ray.rllib.utils.annotations import PublicAPI @PublicAPI -class OutputWriter(object): +class OutputWriter: """Writer object for saving experiences from policy evaluation.""" @PublicAPI diff --git a/rllib/optimizers/aso_aggregator.py b/rllib/optimizers/aso_aggregator.py index fc6d64071..7c5452bf0 100644 --- a/rllib/optimizers/aso_aggregator.py +++ b/rllib/optimizers/aso_aggregator.py @@ -13,7 +13,7 @@ from ray.rllib.utils.annotations import override from ray.rllib.utils.memory import ray_get_and_free -class Aggregator(object): +class Aggregator: """An aggregator collects and processes samples from workers. This class is used to abstract away the strategy for sample collection. @@ -52,7 +52,7 @@ class Aggregator(object): raise NotImplementedError -class AggregationWorkerBase(object): +class AggregationWorkerBase: """Aggregators should extend from this class.""" def __init__(self, initial_weights_obj_id, remote_workers, diff --git a/rllib/optimizers/aso_minibatch_buffer.py b/rllib/optimizers/aso_minibatch_buffer.py index b196f8aca..d9fe447de 100644 --- a/rllib/optimizers/aso_minibatch_buffer.py +++ b/rllib/optimizers/aso_minibatch_buffer.py @@ -5,7 +5,7 @@ from __future__ import division from __future__ import print_function -class MinibatchBuffer(object): +class MinibatchBuffer: """Ring buffer of recent data batches for minibatch SGD. This is for use with AsyncSamplesOptimizer. diff --git a/rllib/optimizers/async_replay_optimizer.py b/rllib/optimizers/async_replay_optimizer.py index 199f66086..1ba650de5 100644 --- a/rllib/optimizers/async_replay_optimizer.py +++ b/rllib/optimizers/async_replay_optimizer.py @@ -256,7 +256,7 @@ class AsyncReplayOptimizer(PolicyOptimizer): @ray.remote(num_cpus=0) -class ReplayActor(object): +class ReplayActor: """A replay buffer shard. Ray actors are single-threaded, so for scalability multiple replay actors @@ -344,7 +344,7 @@ class ReplayActor(object): # note: we set num_cpus=0 to avoid failing to create replay actors when # resources are fragmented. This isn't ideal. @ray.remote(num_cpus=0) -class BatchReplayActor(object): +class BatchReplayActor: """The batch replay version of the replay actor. This allows for RNN models, but ignores prioritization params. diff --git a/rllib/optimizers/multi_gpu_impl.py b/rllib/optimizers/multi_gpu_impl.py index aa7340ab8..3d27d6dbc 100644 --- a/rllib/optimizers/multi_gpu_impl.py +++ b/rllib/optimizers/multi_gpu_impl.py @@ -16,7 +16,7 @@ TOWER_SCOPE_NAME = "tower" logger = logging.getLogger(__name__) -class LocalSyncParallelOptimizer(object): +class LocalSyncParallelOptimizer: """Optimizer that runs in parallel across multiple local devices. LocalSyncParallelOptimizer automatically splits up and loads training data diff --git a/rllib/optimizers/policy_optimizer.py b/rllib/optimizers/policy_optimizer.py index 3d0190dcc..d46f6e9a6 100644 --- a/rllib/optimizers/policy_optimizer.py +++ b/rllib/optimizers/policy_optimizer.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) @DeveloperAPI -class PolicyOptimizer(object): +class PolicyOptimizer: """Policy optimizers encapsulate distributed RL optimization strategies. Policy optimizers serve as the "control plane" of algorithms. diff --git a/rllib/optimizers/replay_buffer.py b/rllib/optimizers/replay_buffer.py index 90e1f87e3..0b7f0979b 100644 --- a/rllib/optimizers/replay_buffer.py +++ b/rllib/optimizers/replay_buffer.py @@ -13,7 +13,7 @@ from ray.rllib.utils.window_stat import WindowStat @DeveloperAPI -class ReplayBuffer(object): +class ReplayBuffer: @DeveloperAPI def __init__(self, size): """Create Prioritized Replay buffer. diff --git a/rllib/optimizers/segment_tree.py b/rllib/optimizers/segment_tree.py index 8f0a0b5a5..271965bac 100644 --- a/rllib/optimizers/segment_tree.py +++ b/rllib/optimizers/segment_tree.py @@ -5,7 +5,7 @@ from __future__ import print_function import operator -class SegmentTree(object): +class SegmentTree: def __init__(self, capacity, operation, neutral_element): """Build a Segment Tree data structure. diff --git a/rllib/policy/eager_tf_policy.py b/rllib/policy/eager_tf_policy.py index 3cb58ec46..461dde7e8 100644 --- a/rllib/policy/eager_tf_policy.py +++ b/rllib/policy/eager_tf_policy.py @@ -409,7 +409,7 @@ def build_eager_tf_policy(name, if gradients_fn: - class OptimizerWrapper(object): + class OptimizerWrapper: def __init__(self, tape): self.tape = tape diff --git a/rllib/policy/policy.py b/rllib/policy/policy.py index 2458ce5b0..0593d5c6a 100644 --- a/rllib/policy/policy.py +++ b/rllib/policy/policy.py @@ -24,7 +24,7 @@ class TupleActions(namedtuple("TupleActions", ["batches"])): @DeveloperAPI -class Policy(object): +class Policy: """An agent policy and loss, i.e., a TFPolicy or other subclass. This object defines how to act in the environment, and also losses used to diff --git a/rllib/policy/sample_batch.py b/rllib/policy/sample_batch.py index fbd4b7e37..8e177e42d 100644 --- a/rllib/policy/sample_batch.py +++ b/rllib/policy/sample_batch.py @@ -15,7 +15,7 @@ DEFAULT_POLICY_ID = "default_policy" @PublicAPI -class SampleBatch(object): +class SampleBatch: """Wrapper around a dictionary with string keys and array-like values. For example, {"obs": [1, 2, 3], "reward": [0, -1, 1]} is a batch of three @@ -231,7 +231,7 @@ class SampleBatch(object): @PublicAPI -class MultiAgentBatch(object): +class MultiAgentBatch: """A batch of experiences from multiple policies in the environment. Attributes: diff --git a/rllib/policy/tf_policy.py b/rllib/policy/tf_policy.py index 67d51a42b..e8c654e4c 100644 --- a/rllib/policy/tf_policy.py +++ b/rllib/policy/tf_policy.py @@ -564,7 +564,7 @@ class TFPolicy(Policy): @DeveloperAPI -class LearningRateSchedule(object): +class LearningRateSchedule: """Mixin for TFPolicy that adds a learning rate schedule.""" @DeveloperAPI @@ -589,7 +589,7 @@ class LearningRateSchedule(object): @DeveloperAPI -class EntropyCoeffSchedule(object): +class EntropyCoeffSchedule: """Mixin for TFPolicy that adds entropy coeff decay.""" @DeveloperAPI diff --git a/rllib/tests/mock_worker.py b/rllib/tests/mock_worker.py index b6b2e9773..9f34e3b7e 100644 --- a/rllib/tests/mock_worker.py +++ b/rllib/tests/mock_worker.py @@ -8,7 +8,7 @@ from ray.rllib.evaluation import SampleBatch from ray.rllib.utils.filter import MeanStdFilter -class _MockWorker(object): +class _MockWorker: def __init__(self, sample_count=10): self._weights = np.array([-10, -10, -10, -10]) self._grad = np.array([1, 1, 1, 1]) diff --git a/rllib/tests/test_catalog.py b/rllib/tests/test_catalog.py index 6fc7505ab..b8287ad65 100644 --- a/rllib/tests/test_catalog.py +++ b/rllib/tests/test_catalog.py @@ -65,7 +65,7 @@ class ModelCatalogTest(unittest.TestCase): def testTuplePreprocessor(self): ray.init(object_store_memory=1000 * 1024 * 1024) - class TupleEnv(object): + class TupleEnv: def __init__(self): self.observation_space = Tuple( [Discrete(5), diff --git a/rllib/utils/actors.py b/rllib/utils/actors.py index 70026d38f..92c7799ac 100644 --- a/rllib/utils/actors.py +++ b/rllib/utils/actors.py @@ -9,7 +9,7 @@ import ray logger = logging.getLogger(__name__) -class TaskPool(object): +class TaskPool: """Helper class for tracking the status of many in-flight actor tasks.""" def __init__(self): diff --git a/rllib/utils/debug.py b/rllib/utils/debug.py index 2903d83c6..c38b466b4 100644 --- a/rllib/utils/debug.py +++ b/rllib/utils/debug.py @@ -106,7 +106,7 @@ def _summarize(obj): return obj -class _StringValue(object): +class _StringValue: def __init__(self, value): self.value = value diff --git a/rllib/utils/filter.py b/rllib/utils/filter.py index b0b27706a..f1b5ee081 100644 --- a/rllib/utils/filter.py +++ b/rllib/utils/filter.py @@ -9,7 +9,7 @@ import threading logger = logging.getLogger(__name__) -class Filter(object): +class Filter: """Processes input, possibly statefully.""" def apply_changes(self, other, *args, **kwargs): @@ -65,7 +65,7 @@ class NoFilter(Filter): # http://www.johndcook.com/blog/standard_deviation/ -class RunningStat(object): +class RunningStat: def __init__(self, shape=None): self._n = 0 self._M = np.zeros(shape) diff --git a/rllib/utils/filter_manager.py b/rllib/utils/filter_manager.py index d2362979a..1c7cc81c4 100644 --- a/rllib/utils/filter_manager.py +++ b/rllib/utils/filter_manager.py @@ -8,7 +8,7 @@ from ray.rllib.utils.memory import ray_get_and_free @DeveloperAPI -class FilterManager(object): +class FilterManager: """Manages filters and coordination across remote evaluators that expose `get_filters` and `sync_filters`. """ diff --git a/rllib/utils/policy_client.py b/rllib/utils/policy_client.py index 3bfe73ff9..017f4fb39 100644 --- a/rllib/utils/policy_client.py +++ b/rllib/utils/policy_client.py @@ -19,7 +19,7 @@ except ImportError: @PublicAPI -class PolicyClient(object): +class PolicyClient: """REST client to interact with a RLlib policy server.""" START_EPISODE = "START_EPISODE" diff --git a/rllib/utils/schedules.py b/rllib/utils/schedules.py index 12efda661..149402a2e 100644 --- a/rllib/utils/schedules.py +++ b/rllib/utils/schedules.py @@ -12,13 +12,13 @@ from __future__ import division from __future__ import print_function -class Schedule(object): +class Schedule: def value(self, t): """Value of the schedule at time t""" raise NotImplementedError() -class ConstantSchedule(object): +class ConstantSchedule: def __init__(self, value): """Value remains constant over time. @@ -38,7 +38,7 @@ def linear_interpolation(l, r, alpha): return l + alpha * (r - l) -class PiecewiseSchedule(object): +class PiecewiseSchedule: def __init__(self, endpoints, interpolation=linear_interpolation, @@ -82,7 +82,7 @@ class PiecewiseSchedule(object): return self._outside_value -class LinearSchedule(object): +class LinearSchedule: def __init__(self, schedule_timesteps, final_p, initial_p=1.0): """Linear interpolation between initial_p and final_p over schedule_timesteps. After this many timesteps pass final_p is diff --git a/rllib/utils/tf_run_builder.py b/rllib/utils/tf_run_builder.py index ed4525ddf..5521f364e 100644 --- a/rllib/utils/tf_run_builder.py +++ b/rllib/utils/tf_run_builder.py @@ -13,7 +13,7 @@ tf = try_import_tf() logger = logging.getLogger(__name__) -class TFRunBuilder(object): +class TFRunBuilder: """Used to incrementally build up a TensorFlow run. This is particularly useful for batching ops from multiple different diff --git a/rllib/utils/timer.py b/rllib/utils/timer.py index bfad20aab..e4be372b6 100644 --- a/rllib/utils/timer.py +++ b/rllib/utils/timer.py @@ -6,7 +6,7 @@ import numpy as np import time -class TimerStat(object): +class TimerStat: """A running stat for conveniently logging the duration of a code block. Example: diff --git a/rllib/utils/window_stat.py b/rllib/utils/window_stat.py index 21c93069a..a6277540b 100644 --- a/rllib/utils/window_stat.py +++ b/rllib/utils/window_stat.py @@ -5,7 +5,7 @@ from __future__ import print_function import numpy as np -class WindowStat(object): +class WindowStat: def __init__(self, name, n): self.name = name self.items = [None] * n diff --git a/streaming/python/communication.py b/streaming/python/communication.py index a5990165e..4aa2b32fe 100644 --- a/streaming/python/communication.py +++ b/streaming/python/communication.py @@ -31,7 +31,7 @@ def _hash(value): return int(hashlib.sha1(value).hexdigest(), 16) -class DataChannel(object): +class DataChannel: """A data channel for actor-to-actor communication. Attributes: @@ -62,7 +62,7 @@ _CLOSE_FLAG = b" " # Pulls and merges data from multiple input channels -class DataInput(object): +class DataInput: """An input gate of an operator instance. The input gate pulls records from all input channels in a round-robin @@ -124,7 +124,7 @@ class DataInput(object): # Selects output channel(s) and pushes data -class DataOutput(object): +class DataOutput: """An output gate of an operator instance. The output gate pushes records to output channels according to the diff --git a/streaming/python/examples/key_selectors.py b/streaming/python/examples/key_selectors.py index 4b1d2e7a3..6533d49b0 100644 --- a/streaming/python/examples/key_selectors.py +++ b/streaming/python/examples/key_selectors.py @@ -17,7 +17,7 @@ parser.add_argument("--input-file", required=True, help="the input text file") # A class used to check attribute-based key selection -class Record(object): +class Record: def __init__(self, record): k, _ = record self.word = k diff --git a/streaming/python/examples/wordcount.py b/streaming/python/examples/wordcount.py index 2062f2b7f..acf363f77 100644 --- a/streaming/python/examples/wordcount.py +++ b/streaming/python/examples/wordcount.py @@ -23,7 +23,7 @@ parser.add_argument( # A custom data source that reads articles from wikipedia # Custom data sources need to implement a get_next() method # that returns the next data element, in this case sentences -class Wikipedia(object): +class Wikipedia: def __init__(self, title_file): # Titles in this file will be as queries self.title_file = title_file diff --git a/streaming/python/jobworker.py b/streaming/python/jobworker.py index 03bfa1f97..b75e43420 100644 --- a/streaming/python/jobworker.py +++ b/streaming/python/jobworker.py @@ -16,7 +16,7 @@ logger = logging.getLogger(__name__) @ray.remote -class JobWorker(object): +class JobWorker: """A streaming job worker. Attributes: diff --git a/streaming/python/operator.py b/streaming/python/operator.py index cb698ff9a..ad2594f06 100644 --- a/streaming/python/operator.py +++ b/streaming/python/operator.py @@ -12,7 +12,7 @@ logger.setLevel("DEBUG") # Stream partitioning schemes -class PScheme(object): +class PScheme: def __init__(self, strategy, partition_fn=None): self.strategy = strategy self.partition_fn = partition_fn @@ -51,7 +51,7 @@ class OpType(enum.Enum): # A logical dataflow operator -class Operator(object): +class Operator: def __init__(self, id, op_type, diff --git a/streaming/python/streaming.py b/streaming/python/streaming.py index 6f93322bf..32d2d1a02 100644 --- a/streaming/python/streaming.py +++ b/streaming/python/streaming.py @@ -34,7 +34,7 @@ all_to_all_strategies = [ # Environment configuration -class Conf(object): +class Conf: """Environment configuration. This class includes all information about the configuration of the @@ -253,7 +253,7 @@ class ExecutionGraph: # The execution environment for a streaming job -class Environment(object): +class Environment: """A streaming environment. This class is responsible for constructing the logical and the @@ -394,7 +394,7 @@ class Environment(object): # A DataStream corresponds to an edge in the logical dataflow -class DataStream(object): +class DataStream: """A data stream. This class contains all information about a logical stream, i.e. an edge