Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify workflow success in CI on Airflow (#48)
* Adding airflow status checker * Adding airflow status checker * Adding airflow package to requirement * Adding the dag run status via API route * Adding the dag run status via API route * Adding the dag auth as user and pass * Adding final kill in case of long running DAG * Added few lines and changed code as requested
- Loading branch information
1 parent
13742c8
commit 34d29d5
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
import time | ||
import requests | ||
|
||
|
||
def get_latest_state(): | ||
url = 'http://localhost:8080/api/v1/dags/lakeFS_workflow/dagRuns' | ||
username = 'admin' | ||
password = 'admin' | ||
response = requests.get(url, auth=(username, password)) | ||
dag_details = {} | ||
latest = max(response.json()['dag_runs'], key=lambda k: \ | ||
k['execution_date']) | ||
state = latest['state'] | ||
return state | ||
|
||
|
||
def dag_state(): | ||
state = get_latest_state() | ||
timeout = time.time() + 60 * 5 # 5 minutes from now | ||
while state != 'success' and state != 'failed' and state \ | ||
!= 'skipped': | ||
time.sleep(5) | ||
if time.time() > timeout: | ||
return 1 | ||
state = get_latest_state() | ||
continue | ||
if state == 'success': | ||
return 0 | ||
else: | ||
return 1 | ||
|
||
|
||
sys.exit(dag_state()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
lakefs_client~=0.91.0 | ||
setuptools~=56.0.0 | ||
requests~=2.28.2 |