@@ -678,27 +678,16 @@ def stop_run(
678678 If False, forces immediate termination. Default is False.
679679
680680 Raises:
681- NotImplementedError: If any orchestrator inheriting from the base
682- class does not implement this logic.
683681 IllegalOperationError: If the run has no orchestrator run id yet.
684682 """
685- # Check if the orchestrator supports cancellation
686- if (
687- getattr (self ._stop_run , "__func__" , None )
688- is BaseOrchestrator ._stop_run
689- ):
690- raise NotImplementedError (
691- f"The '{ self .__class__ .__name__ } ' orchestrator does not "
692- "support stopping pipeline runs."
693- )
694-
695683 if not run .orchestrator_run_id :
696684 raise IllegalOperationError (
697685 "Cannot stop a pipeline run that has no orchestrator run id "
698686 "yet."
699687 )
700688
701689 # Update pipeline status to STOPPING before calling concrete implementation
690+ # Initiates graceful termination.
702691 publish_pipeline_run_status_update (
703692 pipeline_run_id = run .id ,
704693 status = ExecutionStatus .STOPPING ,
@@ -720,13 +709,24 @@ def _stop_run(
720709 run: A pipeline run response to stop (already updated to STOPPING status).
721710 graceful: If True, allows for graceful shutdown where possible.
722711 If False, forces immediate termination. Default is True.
723-
724- Raises:
725- NotImplementedError: If any orchestrator inheriting from the base
726- class does not implement this logic.
727712 """
713+ if graceful :
714+ # This should work out of the box for HeartBeat step termination.
715+ # Orchestrators should extend the functionality to cover other scenarios.
716+ self ._stop_run_gracefully (pipeline_run = run )
717+ else :
718+ self ._stop_run_forcefully (pipeline_run = run )
719+
720+ def _stop_run_gracefully (
721+ self , pipeline_run : "PipelineRunResponse"
722+ ) -> None :
723+ pass
724+
725+ def _stop_run_forcefully (
726+ self , pipeline_run : "PipelineRunResponse"
727+ ) -> None :
728728 raise NotImplementedError (
729- "The stop run functionality is not implemented for the "
729+ "The forceful stop run functionality is not implemented for the "
730730 f"'{ self .__class__ .__name__ } ' orchestrator."
731731 )
732732
0 commit comments