[autoscaler] Cleanup Logging (#2709)

Moves Autoscaler onto Python `logging` module.
This commit is contained in:
Richard Liaw
2018-08-25 17:08:45 -07:00
committed by GitHub
parent 982cde664f
commit dbba7f2a53
9 changed files with 120 additions and 96 deletions
+6 -3
View File
@@ -6,10 +6,13 @@ from filelock import FileLock
import json
import os
import socket
import logging
from ray.autoscaler.node_provider import NodeProvider
from ray.autoscaler.tags import TAG_RAY_NODE_TYPE
logger = logging.getLogger(__name__)
class ClusterState(object):
def __init__(self, lock_path, save_path, provider_config):
@@ -21,7 +24,7 @@ class ClusterState(object):
workers = json.loads(open(self.save_path).read())
else:
workers = {}
print("Loaded cluster state", workers)
logger.info("Loaded cluster state: {}".format(workers))
for worker_ip in provider_config["worker_ips"]:
if worker_ip not in workers:
workers[worker_ip] = {
@@ -45,7 +48,7 @@ class ClusterState(object):
TAG_RAY_NODE_TYPE] == "head"
assert len(workers) == len(provider_config["worker_ips"]) + 1
with open(self.save_path, "w") as f:
print("Writing cluster state", workers)
logger.info("Writing cluster state: {}".format(workers))
f.write(json.dumps(workers))
def get(self):
@@ -60,7 +63,7 @@ class ClusterState(object):
workers = self.get()
workers[worker_id] = info
with open(self.save_path, "w") as f:
print("Writing cluster state", workers)
logger.info("Writing cluster state: {}".format(workers))
f.write(json.dumps(workers))