From c507859a83eedcf6ef469bc82b35fc2dfa941339 Mon Sep 17 00:00:00 2001 From: Yunzhi Zhang <35828389+zzyunzhi@users.noreply.github.com> Date: Wed, 18 Dec 2019 12:07:37 -0800 Subject: [PATCH] [Dashboard] Node resource display fix (#6521) --- python/ray/dashboard/dashboard.py | 13 +++++++------ src/ray/common/task/scheduling_resources.cc | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/python/ray/dashboard/dashboard.py b/python/ray/dashboard/dashboard.py index 0130513aa..a345e7748 100644 --- a/python/ray/dashboard/dashboard.py +++ b/python/ray/dashboard/dashboard.py @@ -52,10 +52,10 @@ def round_resource_value(quantity): def format_resource(resource_name, quantity): if resource_name == "object_store_memory" or resource_name == "memory": - # Convert to 100MiB chunks and then to GiB + # Convert to 50MiB chunks and then to GiB quantity = quantity * (50 * 1024 * 1024) / (1024 * 1024 * 1024) - return f"{round_resource_value(quantity)} GiB" - return f"{round_resource_value(quantity)}" + return "{} GiB".format(round_resource_value(quantity)) + return "{}".format(round_resource_value(quantity)) class Dashboard(object): @@ -162,14 +162,15 @@ class Dashboard(object): for address, data in D.items(): available_resources = data["availableResources"] total_resources = data["totalResources"] - extra_info = "" + extra_info = [] for resource_name in sorted(available_resources.keys()): total = total_resources[resource_name] occupied = total - available_resources[resource_name] total = format_resource(resource_name, total) occupied = format_resource(resource_name, occupied) - extra_info += f"{resource_name}: {occupied} / {total}, " - data["extraInfo"] = extra_info[:-2] + extra_info.append("{}: {} / {}".format( + resource_name, occupied, total)) + data["extraInfo"] = ", ".join(extra_info) return await json_response(result=D) async def logs(req) -> aiohttp.web.Response: diff --git a/src/ray/common/task/scheduling_resources.cc b/src/ray/common/task/scheduling_resources.cc index cc8dc1d95..8836a5494 100644 --- a/src/ray/common/task/scheduling_resources.cc +++ b/src/ray/common/task/scheduling_resources.cc @@ -246,7 +246,7 @@ const ResourceSet ResourceSet::GetNumCpus() const { const std::string format_resource(std::string resource_name, double quantity) { if (resource_name == "object_store_memory" || resource_name == "memory") { - // Convert to 100MiB chunks and then to GiB + // Convert to 50MiB chunks and then to GiB return std::to_string(quantity * (50 * 1024 * 1024) / (1024 * 1024 * 1024)) + " GiB"; } return std::to_string(quantity);