Skip to content

Commit

Permalink
Add DagModel attributes before dumping DagDetailSchema for get_dag_de…
Browse files Browse the repository at this point in the history
…tails API endpoint (#34947)

* Add DagModel attributes before dumping DagDetailSchema

* fix tests

* fix tests

* missed an f-string :(

* apply dag attributes to dag model instead of other way around

* pass session to
  • Loading branch information
RNHTTR committed Nov 24, 2023
1 parent 0e157b3 commit e8f62e8
Show file tree
Hide file tree
Showing 7 changed files with 1,135 additions and 1,081 deletions.
10 changes: 8 additions & 2 deletions airflow/api_connexion/endpoints/dag_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ def get_dag(*, dag_id: str, session: Session = NEW_SESSION) -> APIResponse:


@security.requires_access_dag("GET")
def get_dag_details(*, dag_id: str) -> APIResponse:
@provide_session
def get_dag_details(*, dag_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Get details of DAG."""
dag: DAG = get_airflow_app().dag_bag.get_dag(dag_id)
if not dag:
raise NotFound("DAG not found", detail=f"The DAG with dag_id: {dag_id} was not found")
return dag_detail_schema.dump(dag)
dag_model: DagModel = session.get(DagModel, dag_id)
for key, value in dag.__dict__.items():
if not key.startswith("_") and not hasattr(dag_model, key):
setattr(dag_model, key, value)

return dag_detail_schema.dump(dag_model)


@security.requires_access_dag("GET")
Expand Down
Loading

0 comments on commit e8f62e8

Please sign in to comment.