Repository: incubator-airflow Updated Branches: refs/heads/master 09bbe2477 -> ed9329017
[AIRFLOW-2208][Airflow-22208] Link to same DagRun graph from TaskInstance view Allow graph view to accept blank execution_date and pass it through when it's available. Closes #3132 from iansuvak/persistent_graph Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/ed932901 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/ed932901 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/ed932901 Branch: refs/heads/master Commit: ed932901757a9e38049ef77e8b02c8bb8a9452c7 Parents: 09bbe24 Author: Ian Suvak <[email protected]> Authored: Mon Apr 23 18:59:58 2018 +0200 Committer: Bolke de Bruin <[email protected]> Committed: Mon Apr 23 18:59:58 2018 +0200 ---------------------------------------------------------------------- airflow/www/templates/airflow/dag.html | 2 +- airflow/www/utils.py | 2 +- tests/core.py | 40 +++++++++++++++++------------ 3 files changed, 25 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/ed932901/airflow/www/templates/airflow/dag.html ---------------------------------------------------------------------- diff --git a/airflow/www/templates/airflow/dag.html b/airflow/www/templates/airflow/dag.html index d5a145d..ed84f27 100644 --- a/airflow/www/templates/airflow/dag.html +++ b/airflow/www/templates/airflow/dag.html @@ -54,7 +54,7 @@ Back to {{ dag.parent_dag.dag_id }}</a> </li> {% endif %} - <li><a href="{{ url_for("airflow.graph", dag_id=dag.dag_id, root=root) }}"> + <li><a href="{{ url_for("airflow.graph", dag_id=dag.dag_id, root=root, execution_date=execution_date) }}"> <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span> Graph View</a></li> <li><a href="{{ url_for("airflow.tree", dag_id=dag.dag_id, num_runs=25, root=root) }}"> http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/ed932901/airflow/www/utils.py ---------------------------------------------------------------------- diff --git a/airflow/www/utils.py b/airflow/www/utils.py index ada8ce2..4a3ac2e 100644 --- a/airflow/www/utils.py +++ b/airflow/www/utils.py @@ -259,7 +259,7 @@ def action_logging(f): task_id=request.args.get('task_id'), dag_id=request.args.get('dag_id')) - if 'execution_date' in request.args: + if request.args.get('execution_date'): log.execution_date = timezone.parse(request.args.get('execution_date')) with create_session() as session: http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/ed932901/tests/core.py ---------------------------------------------------------------------- diff --git a/tests/core.py b/tests/core.py index 308804d..9cbae9d 100644 --- a/tests/core.py +++ b/tests/core.py @@ -1596,12 +1596,12 @@ class WebUiTests(unittest.TestCase): self.dagbag = models.DagBag(include_examples=True) self.dag_bash = self.dagbag.dags['example_bash_operator'] - self.dag_bash2 = self.dagbag.dags['test_example_bash_operator'] + self.dag_python = self.dagbag.dags['example_python_operator'] self.sub_dag = self.dagbag.dags['example_subdag_operator'] self.runme_0 = self.dag_bash.get_task('runme_0') self.example_xcom = self.dagbag.dags['example_xcom'] - self.dagrun_bash2 = self.dag_bash2.create_dagrun( + self.dagrun_python = self.dag_python.create_dagrun( run_id="test_{}".format(models.DagRun.id_for_date(timezone.utcnow())), execution_date=DEFAULT_DATE, start_date=timezone.utcnow(), @@ -1628,14 +1628,16 @@ class WebUiTests(unittest.TestCase): self.assertIn("DAGs", resp_html) self.assertIn("example_bash_operator", resp_html) - # The HTML should contain data for the last-run. A link to the specific run, and the text of - # the date. + # The HTML should contain data for the last-run. A link to the specific run, + # and the text of the date. url = "/admin/airflow/graph?" + urlencode({ - "dag_id": self.dag_bash2.dag_id, - "execution_date": self.dagrun_bash2.execution_date, + "dag_id": self.dag_python.dag_id, + "execution_date": self.dagrun_python.execution_date, }).replace("&", "&") self.assertIn(url, resp_html) - self.assertIn(self.dagrun_bash2.execution_date.strftime("%Y-%m-%d %H:%M"), resp_html) + self.assertIn( + self.dagrun_python.execution_date.strftime("%Y-%m-%d %H:%M"), + resp_html) def test_query(self): response = self.app.get('/admin/queryview/') @@ -1662,6 +1664,10 @@ class WebUiTests(unittest.TestCase): response = self.app.get( '/admin/airflow/graph?dag_id=example_bash_operator') self.assertIn("runme_0", response.data.decode('utf-8')) + # confirm that the graph page loads when execution_date is blank + response = self.app.get( + '/admin/airflow/graph?dag_id=example_bash_operator&execution_date=') + self.assertIn("runme_0", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/tree?num_runs=25&dag_id=example_bash_operator') self.assertIn("runme_0", response.data.decode('utf-8')) @@ -1673,8 +1679,8 @@ class WebUiTests(unittest.TestCase): self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/landing_times?' - 'days=30&dag_id=test_example_bash_operator') - self.assertIn("test_example_bash_operator", response.data.decode('utf-8')) + 'days=30&dag_id=example_python_operator') + self.assertIn("example_python_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/landing_times?' 'days=30&dag_id=example_xcom') @@ -1713,16 +1719,16 @@ class WebUiTests(unittest.TestCase): '/admin/airflow/task_stats') self.assertIn("example_bash_operator", response.data.decode('utf-8')) url = ( - "/admin/airflow/success?task_id=run_this_last&" - "dag_id=test_example_bash_operator&upstream=false&downstream=false&" + "/admin/airflow/success?task_id=print_the_context&" + "dag_id=example_python_operator&upstream=false&downstream=false&" "future=false&past=false&execution_date={}&" "origin=/admin".format(DEFAULT_DATE_DS)) response = self.app.get(url) self.assertIn("Wait a minute", response.data.decode('utf-8')) response = self.app.get(url + "&confirmed=true") response = self.app.get( - '/admin/airflow/clear?task_id=run_this_last&' - 'dag_id=test_example_bash_operator&future=true&past=false&' + '/admin/airflow/clear?task_id=print_the_context&' + 'dag_id=example_python_operator&future=true&past=false&' 'upstream=true&downstream=false&' 'execution_date={}&' 'origin=/admin'.format(DEFAULT_DATE_DS)) @@ -1741,8 +1747,8 @@ class WebUiTests(unittest.TestCase): self.assertIn("section-1-task-5", response.data.decode('utf-8')) response = self.app.get(url + "&confirmed=true") url = ( - "/admin/airflow/clear?task_id=runme_1&" - "dag_id=test_example_bash_operator&future=false&past=false&" + "/admin/airflow/clear?task_id=print_the_context&" + "dag_id=example_python_operator&future=false&past=false&" "upstream=false&downstream=true&" "execution_date={}&" "origin=/admin".format(DEFAULT_DATE_DS)) @@ -1787,10 +1793,10 @@ class WebUiTests(unittest.TestCase): def test_fetch_task_instance(self): url = ( "/admin/airflow/object/task_instances?" - "dag_id=test_example_bash_operator&" + "dag_id=example_python_operator&" "execution_date={}".format(DEFAULT_DATE_DS)) response = self.app.get(url) - self.assertIn("run_this_last", response.data.decode('utf-8')) + self.assertIn("print_the_context", response.data.decode('utf-8')) def tearDown(self): configuration.conf.set("webserver", "expose_config", "False")
