mirror of
https://github.com/wassname/ray.git
synced 2026-07-22 13:00:49 +08:00
[autoscaler] Cleanup Logging (#2709)
Moves Autoscaler onto Python `logging` module.
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user