From c4cba98c7531d99bd97070cccd797ad74a8ceccb Mon Sep 17 00:00:00 2001 From: Alexey Tumanov Date: Tue, 18 Dec 2018 17:04:51 -0800 Subject: [PATCH] Remove deprecation warnings when running actor tests (#3563) * remove deprecation warnings when running actor tests * replacing logger.warn with logger.warning * Update worker.py * Update policy_client.py * Update compression.py --- python/ray/actor.py | 6 +++--- python/ray/experimental/sgd/sgd.py | 2 +- python/ray/remote_function.py | 2 +- python/ray/rllib/agents/ppo/ppo.py | 4 ++-- python/ray/rllib/evaluation/metrics.py | 2 +- python/ray/rllib/evaluation/policy_evaluator.py | 2 +- python/ray/rllib/evaluation/sampler.py | 2 +- python/ray/rllib/offline/json_reader.py | 2 +- python/ray/rllib/utils/compression.py | 6 +++--- python/ray/rllib/utils/policy_client.py | 5 +++-- python/ray/tune/suggest/variant_generator.py | 2 +- python/ray/worker.py | 9 +++++---- 12 files changed, 23 insertions(+), 21 deletions(-) diff --git a/python/ray/actor.py b/python/ray/actor.py index 1bac7a137..99def23e8 100644 --- a/python/ray/actor.py +++ b/python/ray/actor.py @@ -216,7 +216,7 @@ class ActorMethod(object): return self._remote(args, kwargs) def _submit(self, args, kwargs, num_return_vals=None): - logger.warn( + logger.warning( "WARNING: _submit() is being deprecated. Please use _remote().") return self._remote( args=args, kwargs=kwargs, num_return_vals=num_return_vals) @@ -338,7 +338,7 @@ class ActorClass(object): num_cpus=None, num_gpus=None, resources=None): - logger.warn( + logger.warning( "WARNING: _submit() is being deprecated. Please use _remote().") return self._remote( args=args, @@ -679,7 +679,7 @@ class ActorHandle(object): # If the worker is a driver and driver id has changed because # Ray was shut down re-initialized, the actor is already cleaned up # and we don't need to send `__ray_terminate__` again. - logger.warn( + logger.warning( "Actor is garbage collected in the wrong driver." + " Actor id = %s, class name = %s.", self._ray_actor_id, self._ray_class_name) diff --git a/python/ray/experimental/sgd/sgd.py b/python/ray/experimental/sgd/sgd.py index 4aa452976..9ce087a6a 100644 --- a/python/ray/experimental/sgd/sgd.py +++ b/python/ray/experimental/sgd/sgd.py @@ -69,7 +69,7 @@ class DistributedSGD(object): all_reduce_alg="simple"): if num_workers == 1 and strategy == "ps": - logger.warn( + logger.warning( "The parameter server strategy does not make sense for single " "worker operation, falling back to simple mode.") strategy = "simple" diff --git a/python/ray/remote_function.py b/python/ray/remote_function.py index b634451df..144fbbc44 100644 --- a/python/ray/remote_function.py +++ b/python/ray/remote_function.py @@ -77,7 +77,7 @@ class RemoteFunction(object): num_cpus=None, num_gpus=None, resources=None): - logger.warn( + logger.warning( "WARNING: _submit() is being deprecated. Please use _remote().") return self._remote( args=args, diff --git a/python/ray/rllib/agents/ppo/ppo.py b/python/ray/rllib/agents/ppo/ppo.py index 0c10b279a..620ef5314 100644 --- a/python/ray/rllib/agents/ppo/ppo.py +++ b/python/ray/rllib/agents/ppo/ppo.py @@ -118,7 +118,7 @@ class PPOAgent(Agent): if waste_ratio > 1.5: raise ValueError(msg) else: - logger.warn(msg) + logger.warning(msg) if self.config["sgd_minibatch_size"] > self.config["train_batch_size"]: raise ValueError( "Minibatch size {} must be <= train batch size {}.".format( @@ -136,6 +136,6 @@ class PPOAgent(Agent): "simple_optimizer=True if this doesn't work for you.") if self.config["observation_filter"] != "NoFilter": # TODO(ekl): consider setting the default to be NoFilter - logger.warn( + logger.warning( "By default, observations will be normalized with {}".format( self.config["observation_filter"])) diff --git a/python/ray/rllib/evaluation/metrics.py b/python/ray/rllib/evaluation/metrics.py index 92c357d11..1b270be37 100644 --- a/python/ray/rllib/evaluation/metrics.py +++ b/python/ray/rllib/evaluation/metrics.py @@ -53,7 +53,7 @@ def summarize_episodes(episodes, new_episodes, num_dropped): """ if num_dropped > 0: - logger.warn("WARNING: {} workers have NOT returned metrics".format( + logger.warning("WARNING: {} workers have NOT returned metrics".format( num_dropped)) episode_rewards = [] diff --git a/python/ray/rllib/evaluation/policy_evaluator.py b/python/ray/rllib/evaluation/policy_evaluator.py index 3946de5b0..e51f0912e 100644 --- a/python/ray/rllib/evaluation/policy_evaluator.py +++ b/python/ray/rllib/evaluation/policy_evaluator.py @@ -300,7 +300,7 @@ class PolicyEvaluator(EvaluatorInterface): self.batch_mode)) if input_evaluation_method == "simulation": - logger.warn( + logger.warning( "Requested 'simulation' input evaluation method: " "will discard all sampler outputs and keep only metrics.") sample_async = True diff --git a/python/ray/rllib/evaluation/sampler.py b/python/ray/rllib/evaluation/sampler.py index 858cd066c..d19530707 100644 --- a/python/ray/rllib/evaluation/sampler.py +++ b/python/ray/rllib/evaluation/sampler.py @@ -311,7 +311,7 @@ def _process_observations(async_vector_env, policies, batch_builder_pool, if (not _large_batch_warned and episode.batch_builder.total() > max(1000, unroll_length * 10)): _large_batch_warned = True - logger.warn( + logger.warning( "More than {} observations for {} env steps ".format( episode.batch_builder.total(), episode.batch_builder.count) + "are buffered in " diff --git a/python/ray/rllib/offline/json_reader.py b/python/ray/rllib/offline/json_reader.py index 958bc86da..61dadfc4c 100644 --- a/python/ray/rllib/offline/json_reader.py +++ b/python/ray/rllib/offline/json_reader.py @@ -42,7 +42,7 @@ class JsonReader(InputReader): if isinstance(inputs, six.string_types): if os.path.isdir(inputs): inputs = os.path.join(inputs, "*.json") - logger.warn( + logger.warning( "Treating input directory as glob pattern: {}".format( inputs)) if urlparse(inputs).scheme: diff --git a/python/ray/rllib/utils/compression.py b/python/ray/rllib/utils/compression.py index 324839da3..8fc7d5890 100644 --- a/python/ray/rllib/utils/compression.py +++ b/python/ray/rllib/utils/compression.py @@ -15,9 +15,9 @@ try: import lz4.frame LZ4_ENABLED = True except ImportError: - logger.warn("lz4 not available, disabling sample compression. " - "This will significantly impact RLlib performance. " - "To install lz4, run `pip install lz4`.") + logger.warning("lz4 not available, disabling sample compression. " + "This will significantly impact RLlib performance. " + "To install lz4, run `pip install lz4`.") LZ4_ENABLED = False diff --git a/python/ray/rllib/utils/policy_client.py b/python/ray/rllib/utils/policy_client.py index 1bb4b5e13..ad1334886 100644 --- a/python/ray/rllib/utils/policy_client.py +++ b/python/ray/rllib/utils/policy_client.py @@ -11,8 +11,9 @@ try: import requests # `requests` is not part of stdlib. except ImportError: requests = None - logger.warn("Couldn't import `requests` library. Be sure to install it on" - " the client side.") + logger.warning( + "Couldn't import `requests` library. Be sure to install it on" + " the client side.") class PolicyClient(object): diff --git a/python/ray/tune/suggest/variant_generator.py b/python/ray/tune/suggest/variant_generator.py index d57b586c0..b59ba2fe9 100644 --- a/python/ray/tune/suggest/variant_generator.py +++ b/python/ray/tune/suggest/variant_generator.py @@ -227,7 +227,7 @@ def _is_resolved(v): def _try_resolve(v): if isinstance(v, types.FunctionType): - logger.warn( + logger.warning( "Deprecation warning: Function values are ambiguous in Tune " "configuations. Either wrap the function with " "`tune.function(func)` to specify a function literal, or " diff --git a/python/ray/worker.py b/python/ray/worker.py index 06f774959..9cdf3bbc9 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -1381,8 +1381,9 @@ def _init(address_info=None, driver_mode = SCRIPT_MODE if redis_max_memory and collect_profiling_data: - logger.warn("Profiling data cannot be LRU evicted, so it is disabled " - "when redis_max_memory is set.") + logger.warning( + "Profiling data cannot be LRU evicted, so it is disabled " + "when redis_max_memory is set.") collect_profiling_data = False # Get addresses of existing services. @@ -1646,8 +1647,8 @@ def init(redis_address=None, # Add the use_raylet option for backwards compatibility. if use_raylet is not None: if use_raylet: - logger.warn("WARNING: The use_raylet argument has been " - "deprecated. Please remove it.") + logger.warning("WARNING: The use_raylet argument has been " + "deprecated. Please remove it.") else: raise DeprecationWarning("The use_raylet argument is deprecated. " "Please remove it.")