From 13547f6372e06cf5b73c6bfe19787af308855de7 Mon Sep 17 00:00:00 2001 From: Pablo Pardo Garcia Date: Tue, 7 Oct 2025 17:29:13 +0200 Subject: [PATCH] remove pause --- README.md | 31 +++++++++++++++++----------- src/glassflow/etl/models/pipeline.py | 2 -- src/glassflow/etl/pipeline.py | 31 +++++++--------------------- tests/test_pipeline.py | 7 +++---- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 518958b..517ae4f 100644 --- a/README.md +++ b/README.md @@ -170,35 +170,42 @@ for pipeline in pipelines: print(f"State: {pipeline['state']}") ``` -### Pause / Resume Pipeline +### Stop / Terminate / Resume Pipeline ```python pipeline = client.get_pipeline("my-pipeline-id") -pipeline.pause() +pipeline.stop() print(pipeline.status) ``` +``` +STOPPING +``` + ```python -pipeline = client.get_pipeline("my-pipeline-id") -pipeline.resume() +# Stop a pipeline ungracefully (terminate) +client.stop_pipeline("my-pipeline-id", terminate=True) print(pipeline.status) ``` -### Stop pipeline +``` +TERMINATING +``` ```python -# Stop a pipeline gracefully -client.stop_pipeline("my-pipeline-id") - -# Stop a pipeline ungracefully (terminate) -client.stop_pipeline("my-pipeline-id", terminate=True) +pipeline = client.get_pipeline("my-pipeline-id") +pipeline.resume() +print(pipeline.status) +``` -# Or stop via pipeline instance -pipeline.stop() +``` +RESUMING ``` ### Delete pipeline +Only stopped or terminated pipelines can be deleted. + ```python # Delete a pipeline client.delete_pipeline("my-pipeline-id") diff --git a/src/glassflow/etl/models/pipeline.py b/src/glassflow/etl/models/pipeline.py index 82496ed..2f188ee 100644 --- a/src/glassflow/etl/models/pipeline.py +++ b/src/glassflow/etl/models/pipeline.py @@ -14,8 +14,6 @@ class PipelineStatus(CaseInsensitiveStrEnum): CREATED = "Created" RUNNING = "Running" - PAUSING = "Pausing" - PAUSED = "Paused" RESUMING = "Resuming" STOPPING = "Stopping" STOPPED = "Stopped" diff --git a/src/glassflow/etl/pipeline.py b/src/glassflow/etl/pipeline.py index 93edd6f..5d0bb62 100644 --- a/src/glassflow/etl/pipeline.py +++ b/src/glassflow/etl/pipeline.py @@ -148,11 +148,11 @@ def update( def delete(self) -> None: """ Deletes the pipeline from the database. Only pipelines that are stopped or - terminating can be deleted. + terminated can be deleted. Raises: PipelineDeletionStateViolationError: If pipeline is not stopped or - terminating + terminated PipelineNotFoundError: If pipeline is not found APIError: If the API request fails """ @@ -162,9 +162,8 @@ def delete(self) -> None: def stop(self, terminate: bool = False) -> Pipeline: """ - Stops the pipeline. Gracefully by default, ungracefully if terminate is True. - Ungracefully means deleting all the pipeline components without waiting for the - events in the pipeline to be processed. + Stops the pipeline, waiting for all the events in the pipeline to be processed. + If terminate is True, the pipeline will be terminated instead. Args: terminate: Whether to terminate the pipeline (i.e. delete all the pipeline @@ -192,26 +191,10 @@ def stop(self, terminate: bool = False) -> Pipeline: self.status = next_status return self - def pause(self) -> Pipeline: - """Pauses the pipeline with the given ID. - - Returns: - Pipeline: A Pipeline instance for the paused pipeline - - Raises: - PipelineInTransitionError: If pipeline is in transition - PipelineNotFoundError: If pipeline is not found - InvalidStatusTransitionError: If pipeline is not in a state that can be - paused - APIError: If the API request fails - """ - endpoint = f"{self.ENDPOINT}/{self.pipeline_id}/pause" - self._request("POST", endpoint, event_name="PipelinePaused") - self.status = models.PipelineStatus.PAUSING - return self - def resume(self) -> Pipeline: - """Resumes the pipeline with the given ID. + """ + Resumes the pipeline with the given ID. + Only stopped or terminated pipelines can be resumed. Returns: Pipeline: A Pipeline instance for the resumed pipeline diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 8240580..87155f1 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -75,13 +75,12 @@ def test_create_http_error_scenarios(self, pipeline, scenario): class TestPipelineLifecycle: - """Tests for pause, resume, stop, terminate, delete operations.""" + """Tests for resume, stop, terminate, delete operations.""" @pytest.mark.parametrize( "operation,method,endpoint,params,status", [ ("get", "GET", "", {}, models.PipelineStatus.RUNNING), - ("pause", "POST", "/pause", {}, models.PipelineStatus.PAUSING), ("resume", "POST", "/resume", {}, models.PipelineStatus.RESUMING), ("delete", "DELETE", "", {}, models.PipelineStatus.DELETED), ( @@ -126,14 +125,14 @@ def test_lifecycle_operations( assert result == pipeline assert pipeline.status == status - @pytest.mark.parametrize("operation", ["get", "delete", "pause", "resume", "stop"]) + @pytest.mark.parametrize("operation", ["get", "delete", "resume", "stop"]) def test_lifecycle_not_found(self, pipeline, mock_not_found_response, operation): """Test lifecycle operations when pipeline is not found.""" with patch("httpx.Client.request", return_value=mock_not_found_response): with pytest.raises(errors.PipelineNotFoundError): getattr(pipeline, operation)() - @pytest.mark.parametrize("operation", ["get", "delete", "pause", "resume", "stop"]) + @pytest.mark.parametrize("operation", ["get", "delete", "resume", "stop"]) def test_lifecycle_connection_error( self, pipeline, mock_connection_error, operation ):