Skip to content

Commit

Permalink
switch to use_float
Browse files Browse the repository at this point in the history
  • Loading branch information
ijrsvt committed Aug 11, 2020
1 parent 762e21c commit 62661b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/ray/state.py
Expand Up @@ -688,7 +688,7 @@ def cluster_resources(self):
for key, value in client["Resources"].items():
resources[key] += value
for k, v in resources.items():
resources[k] = format_resource(k, v)
resources[k] = format_resource(k, v, use_float=True)
return dict(resources)

def _live_client_ids(self):
Expand Down Expand Up @@ -757,7 +757,7 @@ def available_resources(self):
subscribe_client.close()

for k, v in total_available_resources.items():
total_available_resources[k] = format_resource(k, v)
total_available_resources[k] = format_resource(k, v, use_float=True)
return dict(total_available_resources)

def _error_messages(self, job_id):
Expand Down
6 changes: 3 additions & 3 deletions python/ray/utils.py
Expand Up @@ -373,10 +373,10 @@ def resources_from_resource_arguments(
return resources


def format_resource(resource_name, quantity):
def format_resource(resource_name, quantity, use_float=False):
if resource_name in ["object_store_memory", "memory"]:
return "{} GiB".format(
round(ray_constants.from_memory_units(quantity) / (1024**3), 2))
value = round(ray_constants.from_memory_units(quantity) / (1024**3), 2)
return value if use_float else "{} GiB".format(value)
if isinstance(quantity, float) and quantity.is_integer():
quantity = int(quantity)
return round(quantity, 2)
Expand Down

0 comments on commit 62661b9

Please sign in to comment.