pateash commented on a change in pull request #16931:
URL: https://github.com/apache/airflow/pull/16931#discussion_r729780395
##########
File path: airflow/models/dag.py
##########
@@ -2521,6 +2521,10 @@ def __init__(self, concurrency=None, **kwargs):
def __repr__(self):
return f"<DAG: {self.dag_id}>"
+ @cached_property
+ def timetable(self) -> Timetable:
+ return create_timetable(self.schedule_interval, self.timezone)
Review comment:
Ok got it,
So going forward **schedule_interval** will not be available and this is now
just for backward compatibility.
##########
File path: airflow/www/templates/airflow/dag.html
##########
@@ -91,11 +91,15 @@ <h4 class="pull-right" style="user-select:
none;-moz-user-select: auto;">
<a class="label label-default" href="{{ url_for('DagRunModelView.list')
}}?_flt_3_dag_id={{ dag.dag_id }}">
Schedule: {{ dag.schedule_interval }}
</a>
+ {% if dag.timetable.interval_description is not none %}
+ <span id="schedule-description-{{ dag.safe_dag_id }}"
class="material-icons text-muted js-tooltip" aria-hidden="true"
data-original-title="Runs: {{ dag.timetable.interval_description|string
}}">info</span>
+ {% endif %}
Review comment:
> There are a few parts in views.py that you can see we sometimes need
to access both a DAG and DagModel.
>
>
https://www.airbnb.com/rooms/52733416?adults=3&check_in=2021-10-24&check_out=2021-10-30&translate_ugc=false&federated_search_id=13dcea61-24c4-4e9d-863b-dea85dd715fa&source_impression_id=p3_1634179624_IoBtfeVEwh%2FrxoQL
@bbovenzi, I do not any plans to visit Mexico but thanks for the invite.
:rofl:
##########
File path: airflow/www/templates/airflow/dag.html
##########
@@ -91,11 +91,15 @@ <h4 class="pull-right" style="user-select:
none;-moz-user-select: auto;">
<a class="label label-default" href="{{ url_for('DagRunModelView.list')
}}?_flt_3_dag_id={{ dag.dag_id }}">
Schedule: {{ dag.schedule_interval }}
</a>
+ {% if dag.timetable.interval_description is not none %}
+ <span id="schedule-description-{{ dag.safe_dag_id }}"
class="material-icons text-muted js-tooltip" aria-hidden="true"
data-original-title="Runs: {{ dag.timetable.interval_description|string
}}">info</span>
+ {% endif %}
Review comment:
> There are a few parts in views.py that you can see we sometimes need
to access both a DAG and DagModel.
>
>
https://www.airbnb.com/rooms/52733416?adults=3&check_in=2021-10-24&check_out=2021-10-30&translate_ugc=false&federated_search_id=13dcea61-24c4-4e9d-863b-dea85dd715fa&source_impression_id=p3_1634179624_IoBtfeVEwh%2FrxoQL
@bbovenzi, I do not any plans to visit Mexico but thanks for the invite.
:rofl:
##########
File path: airflow/timetables/base.py
##########
@@ -94,6 +95,15 @@ def logical_date(self) -> DateTime:
class Timetable(Protocol):
"""Protocol that all Timetable classes are expected to implement."""
+ @cached_property
+ def interval_description(self) -> Optional[str]:
+ """Override to describe the interval.
+
+ For cron ``'30 21 * * 5'``, description could be like ``'At 09:30 PM,
only on Friday'``.
+ This is used in the web UI.
+ """
+ return None
Review comment:
implemented
##########
File path: airflow/timetables/interval.py
##########
@@ -221,6 +223,20 @@ def infer_manual_data_interval(self, *, run_after:
DateTime) -> DataInterval:
end = self._get_prev(self._align(run_after))
return DataInterval(start=self._get_prev(end), end=end)
+ @cached_property
+ def interval_description(self) -> Optional[str]:
Review comment:
Caching disabled,
I am checking for none in jinja, it there is no description I will not show
info at all.
##########
File path: airflow/www/templates/airflow/dag.html
##########
@@ -91,11 +91,15 @@ <h4 class="pull-right" style="user-select:
none;-moz-user-select: auto;">
<a class="label label-default" href="{{ url_for('DagRunModelView.list')
}}?_flt_3_dag_id={{ dag.dag_id }}">
Schedule: {{ dag.schedule_interval }}
</a>
+ {% if dag.timetable.interval_description is not none %}
+ <span id="schedule-description-{{ dag.safe_dag_id }}"
class="material-icons text-muted js-tooltip" aria-hidden="true"
data-original-title="Runs: {{ dag.timetable.interval_description|string
}}">info</span>
+ {% endif %}
Review comment:
Thanks, I can use dag_model object here as well similar to what
@bbovenzi used for **next_dagrun**,
let me know your thoughts.
##########
File path: airflow/www/templates/airflow/dag.html
##########
@@ -91,11 +91,15 @@ <h4 class="pull-right" style="user-select:
none;-moz-user-select: auto;">
<a class="label label-default" href="{{ url_for('DagRunModelView.list')
}}?_flt_3_dag_id={{ dag.dag_id }}">
Schedule: {{ dag.schedule_interval }}
</a>
+ {% if dag.timetable.interval_description is not none %}
+ <span id="schedule-description-{{ dag.safe_dag_id }}"
class="material-icons text-muted js-tooltip" aria-hidden="true"
data-original-title="Runs: {{ dag.timetable.interval_description|string
}}">info</span>
+ {% endif %}
Review comment:
Thanks, I am using dag_model object here as well similar to what
@bbovenzi used for **next_dagrun**,
let me know your thoughts.
##########
File path: airflow/www/templates/airflow/dags.html
##########
@@ -190,6 +190,11 @@ <h2>{{ page_title }}</h2>
<a class="label label-default schedule" href="{{
url_for('DagRunModelView.list') }}?_flt_3_dag_id={{ dag.dag_id }}"
data-dag-id="{{ dag.dag_id }}">
{{ dag.schedule_interval }}
</a>
+
+ {% if dag.timetable_description is not none %}
+ <span id="schedule-description-{{ dag.safe_dag_id }}"
class="material-icons text-muted js-tooltip" aria-hidden="true"
data-original-title="Schedule: {{ dag.timetable_description|string
}}">info</span>
+ {% endif %}
+
Review comment:
removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]