Skip to content

Commit ab9193e

Browse files
committed
Add wait() method for job run.
1 parent 5013703 commit ab9193e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ads/jobs/builders/infrastructure/dsc_job.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,22 @@ def _check_and_print_status(self, prev_status) -> str:
655655
print(f"{timestamp} - {status}")
656656
return status
657657

658+
def wait(self, interval: float = SLEEP_INTERVAL):
659+
"""Waits for the job run until if finishes.
660+
661+
Parameters
662+
----------
663+
interval : float
664+
Time interval in seconds between each request to update the logs.
665+
Defaults to 3 (seconds).
666+
667+
"""
668+
self.sync()
669+
while self.status not in self.TERMINAL_STATES:
670+
time.sleep(interval)
671+
self.sync()
672+
return self
673+
658674
def watch(
659675
self,
660676
interval: float = SLEEP_INTERVAL,

0 commit comments

Comments
 (0)