Skip to content

Commit

Permalink
fix: handle cancelled jobs (#2)
Browse files Browse the repository at this point in the history
* fix: handle cancelled jobs
  • Loading branch information
fernandobrito authored Aug 30, 2023
1 parent 5721ee5 commit 0a1cebe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/dbttoolkit/dbt_cloud/clients/dbt_cloud_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
13 changes: 12 additions & 1 deletion tests/dbt_cloud/actions/test_retrieve_most_recent_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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
Expand Down

0 comments on commit 0a1cebe

Please sign in to comment.