mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[job submission] Remove DOES_NOT_EXIST status (#20354)
This commit is contained in:
parent
1dd8b3d2bc
commit
48bc1af2da
3 changed files with 6 additions and 8 deletions
|
@ -20,7 +20,6 @@ class JobStatus(str, Enum):
|
|||
def __str__(self):
|
||||
return f"{self.value}"
|
||||
|
||||
DOES_NOT_EXIST = "DOES_NOT_EXIST"
|
||||
PENDING = "PENDING"
|
||||
RUNNING = "RUNNING"
|
||||
STOPPED = "STOPPED"
|
||||
|
@ -44,12 +43,12 @@ class JobStatusStorageClient:
|
|||
pickle.dumps(status),
|
||||
namespace=ray_constants.KV_NAMESPACE_JOB)
|
||||
|
||||
def get_status(self, job_id: str) -> JobStatus:
|
||||
def get_status(self, job_id: str) -> Optional[JobStatus]:
|
||||
pickled_status = _internal_kv_get(
|
||||
self.JOB_STATUS_KEY.format(job_id=job_id),
|
||||
namespace=ray_constants.KV_NAMESPACE_JOB)
|
||||
if pickled_status is None:
|
||||
return JobStatus.DOES_NOT_EXIST
|
||||
return None
|
||||
else:
|
||||
return pickle.loads(pickled_status)
|
||||
|
||||
|
|
|
@ -66,8 +66,8 @@ class JobHead(dashboard_utils.DashboardHeadModule):
|
|||
status=aiohttp.web.HTTPBadRequest.status_code)
|
||||
|
||||
def job_exists(self, job_id: str) -> bool:
|
||||
status: JobStatus = self._job_manager.get_job_status(job_id)
|
||||
return status != JobStatus.DOES_NOT_EXIST
|
||||
status = self._job_manager.get_job_status(job_id)
|
||||
return status is not None
|
||||
|
||||
@routes.get("/api/packages/{protocol}/{package_name}")
|
||||
@_init_ray_and_catch_exceptions
|
||||
|
|
|
@ -207,7 +207,7 @@ class JobSupervisor:
|
|||
# clean up actor after tasks are finished
|
||||
ray.actor.exit_actor()
|
||||
|
||||
def _get_status(self) -> JobStatus:
|
||||
def _get_status(self) -> Optional[JobStatus]:
|
||||
return self._status_client.get_status(self._job_id)
|
||||
|
||||
def stop(self):
|
||||
|
@ -290,8 +290,7 @@ class JobManager:
|
|||
"""
|
||||
if job_id is None:
|
||||
job_id = str(uuid4())
|
||||
elif self._status_client.get_status(
|
||||
job_id) != JobStatus.DOES_NOT_EXIST:
|
||||
elif self._status_client.get_status(job_id) is not None:
|
||||
raise RuntimeError(f"Job {job_id} already exists.")
|
||||
|
||||
self._status_client.put_status(job_id, JobStatus.PENDING)
|
||||
|
|
Loading…
Add table
Reference in a new issue