Skip to content

Commit

Permalink
[core] fix worker launch time formatting (ray-project#43516)
Browse files Browse the repository at this point in the history
Signed-off-by: hongchaodeng <[email protected]>
  • Loading branch information
hongchaodeng committed Jul 18, 2024
1 parent 2e69285 commit 7044dce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions python/ray/util/state/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Humanify:
convert units into a human readable string."""

def timestamp(x: float):
"""Converts miliseconds to a datetime object."""
"""Converts milliseconds to a datetime object."""
return str(datetime.datetime.fromtimestamp(x / 1000))

def memory(x: int):
Expand All @@ -104,7 +104,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 Expand Up @@ -630,12 +630,16 @@ class WorkerState(StateSchema):
#: -> start_time_ms (worker is ready to be used).
#: -> end_time_ms (worker is destroyed).
worker_launch_time_ms: Optional[int] = state_column(
filterable=False, detail=True, format_fn=Humanify.timestamp
filterable=False,
detail=True,
format_fn=lambda x: "" if x == -1 else Humanify.timestamp(x),
)
#: The time worker is succesfully launched
#: -1 if the value doesn't exist.
worker_launched_time_ms: Optional[int] = state_column(
filterable=False, detail=True, format_fn=Humanify.timestamp
filterable=False,
detail=True,
format_fn=lambda x: "" if x == -1 else Humanify.timestamp(x),
)
#: The time when the worker is started and initialized.
#: 0 if the value doesn't exist.
Expand Down

0 comments on commit 7044dce

Please sign in to comment.