64
64
DELETE_WORKFLOW_STEPS = 2
65
65
DEACTIVATE_WORKFLOW_STEPS = 2
66
66
DEFAULT_RETRYING_REQUEST_ATTEMPTS = 3
67
- TERMINAL_STATES = [State .ACTIVE , State .FAILED , State .DELETED , State .INACTIVE ]
68
- WATCH_TERMINAL_STATES = [State .FAILED , State .DELETED , State .INACTIVE ]
69
67
70
68
MODEL_DEPLOYMENT_KIND = "deployment"
71
69
MODEL_DEPLOYMENT_TYPE = "modelDeployment"
@@ -749,7 +747,7 @@ def watch(
749
747
The instance of ModelDeployment.
750
748
"""
751
749
status = ""
752
- while self . state not in TERMINAL_STATES :
750
+ while not self . _stop_condition () :
753
751
status = self ._check_and_print_status (status )
754
752
time .sleep (interval )
755
753
@@ -758,7 +756,7 @@ def watch(
758
756
count = self .logs (log_type ).stream (
759
757
source = self .model_deployment_id ,
760
758
interval = interval ,
761
- stop_condition = self ._stop_condition ,
759
+ stop_condition = self ._stream_stop_condition ,
762
760
time_start = time_start ,
763
761
log_filter = log_filter ,
764
762
)
@@ -773,8 +771,12 @@ def watch(
773
771
pass
774
772
775
773
def _stop_condition (self ):
776
- """Stops the watch sync once the model deployment is in a terminal state."""
777
- return self .state in WATCH_TERMINAL_STATES
774
+ """Stops the sync once the model deployment is in a terminal state."""
775
+ return self .state in [State .ACTIVE , State .FAILED , State .DELETED , State .INACTIVE ]
776
+
777
+ def _stream_stop_condition (self ):
778
+ """Stops the stream sync once the model deployment is in a terminal state."""
779
+ return self .state in [State .FAILED , State .DELETED , State .INACTIVE ]
778
780
779
781
def _check_and_print_status (self , prev_status ) -> str :
780
782
"""Check and print the next status.
0 commit comments