astahlman commented on a change in pull request #4396: [AIRFLOW-3585] - Add 
edges to database
URL: https://github.com/apache/airflow/pull/4396#discussion_r257096012
 
 

 ##########
 File path: airflow/www/views.py
 ##########
 @@ -1293,24 +1303,30 @@ def set_duration(tid):
     def graph(self, session=None):
         dag_id = request.args.get('dag_id')
         blur = conf.getboolean('webserver', 'demo_mode')
-        dag = dagbag.get_dag(dag_id)
-        if dag_id not in dagbag.dags:
-            flash('DAG "{0}" seems to be missing.'.format(dag_id), "error")
-            return redirect('/')
-
         root = request.args.get('root')
         if root:
-            dag = dag.sub_dag(
-                task_regex=root,
-                include_upstream=True,
-                include_downstream=False)
+            show_dag_id = root
+        else:
+            show_dag_id = dag_id
+        dag = session.query(models.DagModel).filter(models.DagModel.dag_id == 
show_dag_id).first()
+        if not dag:
+            flash('DAG "{0}" seems to be missing.'.format(show_dag_id), 
"error")
+            return redirect('/admin/')
 
-        arrange = request.args.get('arrange', dag.orientation)
+        arrange = request.args.get('arrange', 
configuration.conf.get('webserver', 'dag_orientation'))
+        dt_nr_dr_data = get_date_time_num_runs_dag_runs_form_data(request, 
session, dag)
+        dt_nr_dr_data['arrange'] = arrange
+        dttm = dt_nr_dr_data['dttm']
 
-        nodes = []
-        edges = []
-        for task in dag.tasks:
-            nodes.append({
+        dag_run = session.query(models.DagRun) \
+            .filter(models.DagRun.dag_id == show_dag_id) \
+            .filter(models.DagRun.execution_date == dttm).one()
 
 Review comment:
   This results in an "Oooops" page if you try to view any DAG that has no 
DagRuns yet, e.g., `/graph?dag_id=example_branch_operator`
   
   ```
     File "/Users/andrewstahlman/src/incubator-airflow/airflow/www/views.py", 
line 1323, in graph
       .filter(models.DagRun.execution_date == dttm).one()
     File 
"/Users/andrewstahlman/.virtualenvs/airflow3/lib/python3.7/site-packages/sqlalchemy/orm/query.py",
 line 3046, in one
       raise orm_exc.NoResultFound("No row was found for one()")
   sqlalchemy.orm.exc.NoResultFound: No row was found for one()
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to