From 0292f99e6c0dd6f19088956b66ba56ed522d37f4 Mon Sep 17 00:00:00 2001 From: Si-Yuan Date: Sun, 1 Sep 2019 15:21:32 -0700 Subject: [PATCH] Fix DeprecationWarning (#5608) --- python/ray/experimental/sgd/pytorch/pytorch_trainer.py | 2 +- python/ray/memory_monitor.py | 2 +- python/ray/projects/scripts.py | 4 ++-- python/ray/tune/ray_trial_executor.py | 2 +- python/ray/tune/sample.py | 5 +++-- python/ray/worker.py | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/python/ray/experimental/sgd/pytorch/pytorch_trainer.py b/python/ray/experimental/sgd/pytorch/pytorch_trainer.py index 39fafdcfa..cf1422beb 100644 --- a/python/ray/experimental/sgd/pytorch/pytorch_trainer.py +++ b/python/ray/experimental/sgd/pytorch/pytorch_trainer.py @@ -91,7 +91,7 @@ class PyTorchTrainer(object): batch_size_per_replica = batch_size // num_replicas if batch_size % num_replicas > 0: new_batch_size = batch_size_per_replica * num_replicas - logger.warn( + logger.warning( ("Changing batch size from {old_batch_size} to " "{new_batch_size} to evenly distribute batches across " "{num_replicas} replicas.").format( diff --git a/python/ray/memory_monitor.py b/python/ray/memory_monitor.py index 8feca07f5..3772e2a92 100644 --- a/python/ray/memory_monitor.py +++ b/python/ray/memory_monitor.py @@ -141,7 +141,7 @@ class MemoryMonitor(object): self.worker_name, round(heap_size / (1024**3), 4), round(self.heap_limit / (1024**3), 4))) elif heap_size > 0.8 * self.heap_limit: - logger.warn( + logger.warning( "Heap memory usage for {} is {} / {} GiB limit".format( self.worker_name, round(heap_size / (1024**3), 4), round(self.heap_limit / (1024**3), 4))) diff --git a/python/ray/projects/scripts.py b/python/ray/projects/scripts.py index ef8a63a52..72a4572dd 100644 --- a/python/ray/projects/scripts.py +++ b/python/ray/projects/scripts.py @@ -84,7 +84,7 @@ def create(project_name, cluster_yaml, requirements): os.makedirs(PROJECT_DIR) if cluster_yaml is None: - logger.warn("Using default autoscaler yaml") + logger.warning("Using default autoscaler yaml") with open(CLUSTER_TEMPLATE) as f: template = f.read().replace(r"{{name}}", project_name) @@ -94,7 +94,7 @@ def create(project_name, cluster_yaml, requirements): cluster_yaml = CLUSTER_YAML if requirements is None: - logger.warn("Using default requirements.txt") + logger.warning("Using default requirements.txt") # no templating required, just copy the file copyfile(REQUIREMENTS_TXT_TEMPLATE, REQUIREMENTS_TXT) diff --git a/python/ray/tune/ray_trial_executor.py b/python/ray/tune/ray_trial_executor.py index 42903309b..d5868560e 100644 --- a/python/ray/tune/ray_trial_executor.py +++ b/python/ray/tune/ray_trial_executor.py @@ -325,7 +325,7 @@ class RayTrialExecutor(TrialExecutor): if wait_time > NONTRIVIAL_WAIT_TIME_THRESHOLD_S: self._last_nontrivial_wait = time.time() if time.time() - self._last_nontrivial_wait > BOTTLENECK_WARN_PERIOD_S: - logger.warn( + logger.warning( "Over the last {} seconds, the Tune event loop has been " "backlogged processing new results. Consider increasing your " "period of result reporting to improve performance.".format( diff --git a/python/ray/tune/sample.py b/python/ray/tune/sample.py index ec632e8c1..b919f264c 100644 --- a/python/ray/tune/sample.py +++ b/python/ray/tune/sample.py @@ -26,8 +26,9 @@ class sample_from(object): def function(func): - logger.warn("DeprecationWarning: wrapping {} with tune.function() is no " - "longer needed".format(func)) + logger.warning( + "DeprecationWarning: wrapping {} with tune.function() is no " + "longer needed".format(func)) return func diff --git a/python/ray/worker.py b/python/ray/worker.py index 7ba86c7d2..73a046e50 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -1794,7 +1794,7 @@ def listen_error_messages_raylet(worker, task_error_queue, threads_stopped): # Delay it a bit to see if we can suppress it task_error_queue.put((error_message, time.time())) else: - logger.warn(error_message) + logger.warning(error_message) except (OSError, redis.exceptions.ConnectionError) as e: logger.error("listen_error_messages_raylet: {}".format(e)) finally: