Skip to content

Commit

Permalink
[core] fix worker launch time formatting
Browse files Browse the repository at this point in the history
Signed-off-by: hongchaodeng <[email protected]>
  • Loading branch information
hongchaodeng committed Jul 17, 2024
1 parent 8999fd5 commit 8e55004
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions python/ray/util/state/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ class Humanify:
"""A class containing default methods to
convert units into a human readable string."""

def timestamp(x: float):
"""Converts miliseconds to a datetime object."""
def timestamp(x):
"""
Converts milliseconds to a datetime object.
If the input is -1, return an empty string.
If the input is not an int or float, raise a ValueError.
"""
if x == -1:
return ""
return str(datetime.datetime.fromtimestamp(x / 1000))

def memory(x: int):
Expand All @@ -104,7 +110,7 @@ def memory(x: int):
return str(format(x, ".3f")) + " B"

def duration(x: int):
"""Converts miliseconds to a human readable duration."""
"""Converts milliseconds to a human readable duration."""
return str(datetime.timedelta(milliseconds=x))

def events(events: List[dict]):
Expand Down

0 comments on commit 8e55004

Please sign in to comment.