You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by da...@apache.org on 2016/12/07 21:37:26 UTC
incubator-airflow git commit: [AIRFLOW-674] Ability to add
descriptions for DAGs
Repository: incubator-airflow
Updated Branches:
refs/heads/master 37a324ae4 -> b67465631
[AIRFLOW-674] Ability to add descriptions for DAGs
Please accept this PR that addresses the following
issues:
-
https://issues.apache.org/jira/browse/AIRFLOW-674
Descriptions are rendered in two places right now,
as a tooltip on the DAGs page for each DAG, and
after the DAG name in the various individual DAG
views (see screenshots below).
Testing Done:
- Spun up local webserver, tried empty
description, normal description, very long
description.
Screenshots:
https://cloud.githubusercontent.com/asset
s/1592778/20906424/dbf2885e-bafc-11e6-8eeb-
78302e87d25a.png
https://cloud.githubusercontent.com/asset
s/1592778/20906420/d651ccfc-bafc-
11e6-9893-ef677be50bf0.png
Closes #1920 from aoen/ddavydov/dag_desc
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/b6746563
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/b6746563
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/b6746563
Branch: refs/heads/master
Commit: b674656312d3ed785d86472a956bb477b5977f97
Parents: 37a324a
Author: Dan Davydov <da...@airbnb.com>
Authored: Wed Dec 7 13:36:52 2016 -0800
Committer: Dan Davydov <da...@airbnb.com>
Committed: Wed Dec 7 13:36:57 2016 -0800
----------------------------------------------------------------------
airflow/example_dags/tutorial.py | 6 +++++-
airflow/models.py | 8 ++++++++
airflow/www/templates/airflow/dag.html | 2 +-
airflow/www/templates/airflow/dags.html | 2 +-
4 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/b6746563/airflow/example_dags/tutorial.py
----------------------------------------------------------------------
diff --git a/airflow/example_dags/tutorial.py b/airflow/example_dags/tutorial.py
index 5621a7c..c7b2e0f 100644
--- a/airflow/example_dags/tutorial.py
+++ b/airflow/example_dags/tutorial.py
@@ -50,7 +50,11 @@ default_args = {
# 'trigger_rule': u'all_success'
}
-dag = DAG('tutorial', default_args=default_args, schedule_interval=timedelta(days=1))
+dag = DAG(
+ 'tutorial',
+ default_args=default_args,
+ description='A simple tutorial DAG',
+ schedule_interval=timedelta(days=1))
# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/b6746563/airflow/models.py
----------------------------------------------------------------------
diff --git a/airflow/models.py b/airflow/models.py
index 02e4046..5763b96 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -2483,6 +2483,8 @@ class DAG(BaseDag, LoggingMixin):
:param dag_id: The id of the DAG
:type dag_id: string
+ :param description: The description for the DAG to e.g. be shown on the webserver
+ :type description: string
:param schedule_interval: Defines how often that DAG runs, this
timedelta object gets added to your latest task instance's
execution_date to figure out the next schedule
@@ -2536,6 +2538,7 @@ class DAG(BaseDag, LoggingMixin):
def __init__(
self, dag_id,
+ description='',
schedule_interval=timedelta(days=1),
start_date=None, end_date=None,
full_filepath=None,
@@ -2567,6 +2570,7 @@ class DAG(BaseDag, LoggingMixin):
self._concurrency = concurrency
self._pickle_id = None
+ self._description = description
self.task_dict = dict()
self.start_date = start_date
self.end_date = end_date
@@ -2726,6 +2730,10 @@ class DAG(BaseDag, LoggingMixin):
self._concurrency = value
@property
+ def description(self):
+ return self._description
+
+ @property
def pickle_id(self):
return self._pickle_id
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/b6746563/airflow/www/templates/airflow/dag.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/airflow/dag.html b/airflow/www/templates/airflow/dag.html
index e9c1940..b9b1afa 100644
--- a/airflow/www/templates/airflow/dag.html
+++ b/airflow/www/templates/airflow/dag.html
@@ -33,7 +33,7 @@
<span style='color:#AAA;'>SUBDAG: </span> <span> {{ dag.dag_id }}</span>
{% else %}
<input id="pause_resume" dag_id="{{ dag.dag_id }}" type="checkbox" {{ "checked" if not dag.is_paused else "" }} data-toggle="toggle" data-size="mini">
- <span style='color:#AAA;'>DAG: </span> <span> {{ dag.dag_id }}</span>
+ <span style='color:#AAA;'>DAG: </span> <span> {{ dag.dag_id }}</span> <small class="text-muted"> {{ dag.description }} </small>
{% endif %}
{% if root %}
<span style='color:#AAA;'>ROOT: </span> <span> {{ root }}</span>
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/b6746563/airflow/www/templates/airflow/dags.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/airflow/dags.html b/airflow/www/templates/airflow/dags.html
index 347015d..2cbd12e 100644
--- a/airflow/www/templates/airflow/dags.html
+++ b/airflow/www/templates/airflow/dags.html
@@ -73,7 +73,7 @@
<!-- Column 3: Name -->
<td>
{% if dag_id in webserver_dags %}
- <a href="{{ url_for('airflow.tree', dag_id=dag.dag_id) }}">
+ <a href="{{ url_for('airflow.tree', dag_id=dag.dag_id) }}" title="{{ dag.description }}">
{{ dag_id }}
</a>
{% else %}