Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] fix worker launch time formatting #43516

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do it on the caller side as the caller knows what special value can be so that this method doesn't need to handle -1, None or some other special values

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

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