Skip to content

Commit 89b9afa

Browse files
committed
Fix: do not throw error if airflow api failed
1 parent 8f0af76 commit 89b9afa

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

ckanext/aircan/logic/action.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,25 @@ def aircan_submit(context, data_dict: Dict[str, Any]) -> Dict[str, Any]:
4444
client = AirflowClient()
4545
try:
4646
dag_run = client.trigger_dag(conf=payload)
47+
context.update({"session": context["model"].meta.create_local_session()})
48+
tk.get_action("aircan_status_update")(
49+
context,
50+
{
51+
"resource_id": data_dict.get("id"),
52+
"dag_run_id": dag_run.get("dag_run_id"),
53+
"state": "queued",
54+
"message": f"Added to the queue to be processed with '{dag_run.get("dag_run_id")}'.",
55+
"clear_logs": True,
56+
},
57+
)
58+
return {
59+
"dag_run": dag_run,
60+
"dag_run_id": dag_run.get("dag_run_id"),
61+
}
4762
except requests.HTTPError as e:
4863
log.error(tk._("Failed to trigger Airflow DAG '%s': %s"), client.dag_id, str(e))
4964

50-
context.update({"session": context["model"].meta.create_local_session()})
51-
tk.get_action("aircan_status_update")(
52-
context,
53-
{
54-
"resource_id": data_dict.get("id"),
55-
"dag_run_id": dag_run.get("dag_run_id"),
56-
"state": "queued",
57-
"message": f"Added to the queue to be processed with '{dag_run.get("dag_run_id")}'.",
58-
"clear_logs": True,
59-
},
60-
)
61-
return {
62-
"dag_run": dag_run,
63-
"dag_run_id": dag_run.get("dag_run_id"),
64-
}
65+
6566

6667

6768
def aircan_status(context, data_dict: Dict[str, Any]) -> Dict[str, Any]:

0 commit comments

Comments
 (0)