@@ -387,6 +387,7 @@ class Remote:
387
387
388
388
def __attrs_post_init__ (self ) -> None :
389
389
self .log_start_time = None
390
+ self .last_status = None
390
391
self .info (f"Request ID is { self .request_uid } " )
391
392
392
393
@property
@@ -466,7 +467,12 @@ def status(self) -> str:
466
467
"""
467
468
reply = self .json
468
469
self ._log_metadata (reply .get ("metadata" , {}))
469
- return str (reply ["status" ])
470
+
471
+ status = reply ["status" ]
472
+ if self .last_status != status :
473
+ self .info (f"status has been updated to { status } " )
474
+ self .last_status = status
475
+ return str (status )
470
476
471
477
@property
472
478
def creation_datetime (self ) -> datetime .datetime :
@@ -502,23 +508,30 @@ def end_datetime(self) -> datetime.datetime | None:
502
508
503
509
def _wait_on_results (self ) -> None :
504
510
sleep = 1.0
505
- status = None
506
- while True :
507
- if status != (status := self .status ):
508
- self .info (f"status has been updated to { status } " )
509
- if status == "successful" :
510
- break
511
- elif status == "failed" :
512
- results = self .make_results (wait = False )
513
- raise ProcessingFailedError (error_json_to_message (results .json ))
514
- elif status in ("accepted" , "running" ):
515
- sleep = min (sleep * 1.5 , self .sleep_max )
516
- elif status in ("dismissed" , "deleted" ):
517
- raise ProcessingFailedError (f"API state { status !r} " )
518
- else :
519
- raise ProcessingFailedError (f"Unknown API state { status !r} " )
511
+ while not self .results_ready :
520
512
self .debug (f"results not ready, waiting for { sleep } seconds" )
521
513
time .sleep (sleep )
514
+ sleep = min (sleep * 1.5 , self .sleep_max )
515
+
516
+ @property
517
+ def results_ready (self ) -> bool :
518
+ """Check if results are ready.
519
+
520
+ Returns
521
+ -------
522
+ bool
523
+ """
524
+ status = self .status
525
+ if status == "successful" :
526
+ return True
527
+ if status in ("accepted" , "running" ):
528
+ return False
529
+ if status == "failed" :
530
+ results = self .make_results (wait = False )
531
+ raise ProcessingFailedError (error_json_to_message (results .json ))
532
+ if status in ("dismissed" , "deleted" ):
533
+ raise ProcessingFailedError (f"API state { status !r} " )
534
+ raise ProcessingFailedError (f"Unknown API state { status !r} " )
522
535
523
536
def make_results (self , wait : bool = True ) -> Results :
524
537
if wait :
0 commit comments