@@ -362,17 +362,14 @@ def _get_jobs_by_ids(job_ids: List[int]) -> List[Dict[str, Any]]:
362
362
def update_job_status (job_owner : str ,
363
363
job_ids : List [int ],
364
364
silent : bool = False ) -> List [JobStatus ]:
365
- """Updates and returns the job statuses matching our `JobStatus` semantics
365
+ """Updates and returns the job statuses matching our `JobStatus` semantics.
366
366
367
- "True" statuses: this function queries `ray job status` and processes
368
- those results to match our semantics.
367
+ This function queries `ray job status` and processes those results to match
368
+ our semantics.
369
369
370
- This function queries `ray job status` and processes those results to
371
- match our semantics.
372
-
373
- Though we update job status actively in ray program and job cancelling,
374
- we still need this to handle staleness problem, caused by instance
375
- restarting and other corner cases (if any).
370
+ Though we update job status actively in the generated ray program and
371
+ during job cancelling, we still need this to handle the staleness problem,
372
+ caused by instance restarting and other corner cases (if any).
376
373
377
374
This function should only be run on the remote instance with ray==2.0.1.
378
375
"""
@@ -413,7 +410,8 @@ def update_job_status(job_owner: str,
413
410
if status is None :
414
411
original_status = get_status_no_lock (job_id )
415
412
status = original_status
416
- if not original_status .is_terminal ():
413
+ if (original_status is not None and
414
+ not original_status .is_terminal ()):
417
415
# The job may be stale, when the instance is restarted
418
416
# (the ray redis is volatile). We need to reset the
419
417
# status of the task to FAILED if its original status
@@ -665,14 +663,12 @@ def tail_logs(cls,
665
663
job_id : Optional [int ],
666
664
spot_job_id : Optional [int ],
667
665
follow : bool = True ) -> str :
666
+ # pylint: disable=line-too-long
668
667
code = [
669
- f'job_id = { job_id } if { job_id } is not None '
670
- 'else job_lib.get_latest_job_id()' ,
668
+ f'job_id = { job_id } if { job_id } is not None else job_lib.get_latest_job_id()' ,
671
669
'run_timestamp = job_lib.get_run_timestamp(job_id)' ,
672
- (f'log_dir = os.path.join({ constants .SKY_LOGS_DIRECTORY !r} , '
673
- 'run_timestamp)' ),
674
- (f'log_lib.tail_logs({ job_owner !r} ,'
675
- f'job_id, log_dir, { spot_job_id !r} , follow={ follow } )' ),
670
+ f'log_dir = None if run_timestamp is None else os.path.join({ constants .SKY_LOGS_DIRECTORY !r} , run_timestamp)' ,
671
+ f'log_lib.tail_logs({ job_owner !r} , job_id, log_dir, { spot_job_id !r} , follow={ follow } )' ,
676
672
]
677
673
return cls ._build (code )
678
674
0 commit comments