Skip to content

Commit

Permalink
Merge pull request #15 from richardliaw/htop
Browse files Browse the repository at this point in the history
Fetch mem table
  • Loading branch information
krfricke authored Mar 25, 2021
2 parents 5b2c41b + 472b7ad commit 2bb7577
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion python/ray/autoscaler/_private/htop.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def __init__(self, url: str, redis_address="127.0.0.1:6379"):
self.mock = os.path.expanduser(mock) if mock else None

self.mock_cache = None
self.mock_memory_cache = None
if self.mock:
with open(self.mock, "rt") as f:
self.mock_cache = json.load(f)
Expand Down Expand Up @@ -283,6 +284,11 @@ def _create_redis_client(
self.redis_client = redis_client

def update(self):
self._load_nodes()
self._load_autoscaler_state()
self._load_memory_info()

def _load_nodes(self):
if self.mock_cache:
resp_json = self.mock_cache
else:
Expand All @@ -293,7 +299,15 @@ def update(self):

self.nodes = [Node(node_dict) for node_dict in resp_data["clients"]]

self._load_autoscaler_state()
def _load_memory_info(self):
# Fetch core memory worker stats, store as a dictionary
if self.mock_memory_cache:
resp_json = self.mock_memory_cache
else:
resp = requests.get(f"{self.url}/memory/memory_table")
resp_json = resp.json()
resp_data = resp_json["data"]
self.memory_table = resp_data

def _load_autoscaler_state(self):
as_dict = None
Expand Down

0 comments on commit 2bb7577

Please sign in to comment.