Skip to content

Commit

Permalink
[Core] Fix null start_time for ray list jobs --detail (ray-project#47828
Browse files Browse the repository at this point in the history
)

Signed-off-by: Jiajun Yao <[email protected]>
jjyao authored Sep 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a157bd8 commit 0fd0437
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions python/ray/tests/test_minimal_install.py
Original file line number Diff line number Diff line change
@@ -35,6 +35,8 @@ def test_correct_python_version():


class MockBaseModel:
model_fields = {}

def __init__(self, *args, **kwargs):
pass

7 changes: 5 additions & 2 deletions python/ray/tests/test_state_api.py
Original file line number Diff line number Diff line change
@@ -2232,11 +2232,13 @@ def test_list_get_jobs(shutdown_only):
)

def verify():
job_data = list_jobs()[0]
job_data = list_jobs(detail=True)[0]
print(job_data)
job_id_from_api = job_data["submission_id"]
assert job_data["status"] == "SUCCEEDED"
assert job_id == job_id_from_api
assert job_data["start_time"] > 0
assert job_data["end_time"] > 0
return True

wait_for_condition(verify)
@@ -2257,10 +2259,11 @@ def f():
run_string_as_driver(script)

def verify():
jobs = list_jobs(filters=[("type", "=", "DRIVER")])
jobs = list_jobs(filters=[("type", "=", "DRIVER")], detail=True)
assert len(jobs) == 2, "1 test driver + 1 script run above"
for driver_job in jobs:
assert driver_job["driver_info"] is not None
assert driver_job["start_time"] > 0

sub_jobs = list_jobs(filters=[("type", "=", "SUBMISSION")])
assert len(sub_jobs) == 1
10 changes: 5 additions & 5 deletions python/ray/util/state/common.py
Original file line number Diff line number Diff line change
@@ -282,7 +282,7 @@ def list_columns(cls, detail: bool = True) -> List[str]:
@classmethod
def columns(cls) -> Set[str]:
"""Return a set of all columns."""
return set(cls.list_columns())
return set(cls.list_columns(detail=True))

@classmethod
def filterable_columns(cls) -> Set[str]:
@@ -556,7 +556,7 @@ def humanify(cls, state: dict) -> dict:
return state

@classmethod
def list_columns(cls, detail: bool = False) -> List[str]:
def list_columns(cls, detail: bool = True) -> List[str]:
if not detail:
return [
"job_id",
@@ -568,7 +568,7 @@ def list_columns(cls, detail: bool = False) -> List[str]:
"error_type",
"driver_info",
]
if isinstance(JobDetails, object):
if JobDetails is None:
# We don't have pydantic in the dashboard. This is because
# we call this method at module import time, so we need to
# check if the class is a pydantic model.
@@ -577,9 +577,9 @@ def list_columns(cls, detail: bool = False) -> List[str]:
# TODO(aguo): Once we only support pydantic 2, we can remove this if check.
# In pydantic 2.0, `__fields__` has been renamed to `model_fields`.
return (
JobDetails.model_fields
list(JobDetails.model_fields.keys())
if hasattr(JobDetails, "model_fields")
else JobDetails.__fields__
else list(JobDetails.__fields__.keys())
)

def asdict(self):

0 comments on commit 0fd0437

Please sign in to comment.