From 0a1cebefc80ee52072f638a93e7e2ba854f2e843 Mon Sep 17 00:00:00 2001 From: Fernando Brito Date: Wed, 30 Aug 2023 11:10:42 +0200 Subject: [PATCH] fix: handle cancelled jobs (#2) * fix: handle cancelled jobs --- .../dbt_cloud/clients/dbt_cloud_client.py | 1 + .../actions/test_retrieve_most_recent_artifact.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/dbttoolkit/dbt_cloud/clients/dbt_cloud_client.py b/src/dbttoolkit/dbt_cloud/clients/dbt_cloud_client.py index 3073c0e..20456f0 100644 --- a/src/dbttoolkit/dbt_cloud/clients/dbt_cloud_client.py +++ b/src/dbttoolkit/dbt_cloud/clients/dbt_cloud_client.py @@ -144,6 +144,7 @@ def retrieve_completed_runs( run for run in runs if run["is_complete"] + and not run["is_cancelled"] and run["project_id"] == self.project_id and run["environment_id"] == self.environment_id ] diff --git a/tests/dbt_cloud/actions/test_retrieve_most_recent_artifact.py b/tests/dbt_cloud/actions/test_retrieve_most_recent_artifact.py index 8c19b5d..429ec4d 100644 --- a/tests/dbt_cloud/actions/test_retrieve_most_recent_artifact.py +++ b/tests/dbt_cloud/actions/test_retrieve_most_recent_artifact.py @@ -59,6 +59,16 @@ def rest_api_run_result(job_id, dbt_cloud_ids): "id": 2, "is_complete": True, "is_success": False, + "is_cancelled": False, + "created_at": "2022-06-10 11:30:00.321339+00:00", + **common, + } + + cancelled = { + "id": 3, + "is_complete": True, + "is_success": False, + "is_cancelled": True, "created_at": "2022-06-10 11:30:00.321339+00:00", **common, } @@ -67,11 +77,12 @@ def rest_api_run_result(job_id, dbt_cloud_ids): "id": 1, "is_complete": True, "is_success": True, + "is_cancelled": False, "created_at": "2022-06-09 11:30:00.321339+00:00", **common, } - return {"data": [failure, success]} + return {"data": [failure, cancelled, success]} @fixture