You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ds...@apache.org on 2022/07/13 19:40:22 UTC

[airflow] branch main updated: Show 'Dataset' as schedule interval for dataset-triggered dags (#25013)

This is an automated email from the ASF dual-hosted git repository.

dstandish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 40e02ed7af Show 'Dataset' as schedule interval for dataset-triggered dags (#25013)
40e02ed7af is described below

commit 40e02ed7afcc67fb99dcfc7d0192f952fca40c65
Author: Daniel Standish <15...@users.noreply.github.com>
AuthorDate: Wed Jul 13 12:40:15 2022 -0700

    Show 'Dataset' as schedule interval for dataset-triggered dags (#25013)
    
    In the DAGs page, in place of schedule interval, show `Dataset` to indicate there is no "schedule interval" per se but this is what will determine the next run.  Update tooltip also (derived from dag_model.timetable_description). And, in the dag detail page, suppress the next run text entirely because it's not possible to say.
---
 airflow/models/dag.py                  | 8 ++++++--
 airflow/www/templates/airflow/dag.html | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/airflow/models/dag.py b/airflow/models/dag.py
index 4cef709b16..48da0a8b77 100644
--- a/airflow/models/dag.py
+++ b/airflow/models/dag.py
@@ -2495,11 +2495,15 @@ class DAG(LoggingMixin):
             orm_dag.last_parsed_time = timezone.utcnow()
             orm_dag.default_view = dag.default_view
             orm_dag.description = dag.description
-            orm_dag.schedule_interval = dag.schedule_interval
             orm_dag.max_active_tasks = dag.max_active_tasks
             orm_dag.max_active_runs = dag.max_active_runs
             orm_dag.has_task_concurrency_limits = any(t.max_active_tis_per_dag is not None for t in dag.tasks)
-            orm_dag.timetable_description = dag.timetable.description
+            if dag.schedule_on:
+                orm_dag.schedule_interval = 'Dataset'
+                orm_dag.timetable_description = 'Triggered by datasets.'
+            else:
+                orm_dag.schedule_interval = dag.schedule_interval
+                orm_dag.timetable_description = dag.timetable.description
 
             run: Optional[DagRun] = most_recent_runs.get(dag.dag_id)
             if run is None:
diff --git a/airflow/www/templates/airflow/dag.html b/airflow/www/templates/airflow/dag.html
index 82a58a69dd..afed473689 100644
--- a/airflow/www/templates/airflow/dag.html
+++ b/airflow/www/templates/airflow/dag.html
@@ -123,12 +123,12 @@
         {{ state_token }}
       {% endif %}
       <a class="label label-default" href="{{ url_for('DagRunModelView.list') }}?_flt_3_dag_id={{ dag.dag_id }}">
-        Schedule: {{ dag.schedule_interval }}
+        Schedule: {{ dag_model is defined and dag_model and dag_model.schedule_interval }}
       </a>
       {% if dag_model is defined and dag_model and dag_model.timetable_description %}
           <span class="material-icons text-muted js-tooltip" aria-hidden="true" data-original-title="Schedule: {{ dag_model.timetable_description|string }}">info</span>
       {% endif %}
-      {% if dag_model is defined and dag_model.next_dagrun is defined %}
+      {% if dag_model is defined and dag_model.next_dagrun is defined and dag_model.schedule_interval != 'dataset-triggered' %}
         <p class="label label-default js-tooltip" style="margin-left: 5px" id="next-run" data-html="true" data-placement="bottom">
           Next Run: <time datetime="{{ dag_model.next_dagrun }}">{{ dag_model.next_dagrun }}</time>
         </p>