You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/24 19:53:56 UTC
[GitHub] [airflow] wolfier opened a new pull request #14990: Fix url generation for TriggerDagRunOperatorLink
wolfier opened a new pull request #14990:
URL: https://github.com/apache/airflow/pull/14990
Fixes: [#14675](https://github.com/apache/airflow/issues/14675)
Instead of building the relative url manually, we can leverage flask's url generation to account for differing airflow base URL and HTML base URL.
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil merged pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #14990:
URL: https://github.com/apache/airflow/pull/14990
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r611173022
##########
File path: tests/utils/test_helpers.py
##########
@@ -140,10 +141,18 @@ def test_merge_dicts_recursive_right_only(self):
@conf_vars(
{
- ("webserver", "dag_default_view"): "custom",
+ ("webserver", "dag_default_view"): "graph",
}
)
def test_build_airflow_url_with_query(self):
+ """
+ Test query generated with dag_id and params
+ """
query = {"dag_id": "test_dag", "param": "key/to.encode"}
- url = build_airflow_url_with_query(query)
- assert url == "/custom?dag_id=test_dag¶m=key%2Fto.encode"
+ expected_url = "/graph?dag_id=test_dag¶m=key%2Fto.encode"
+
+ from airflow.www.app import cached_app
+
+ with cached_app(testing=True).test_request_context():
+ assert build_airflow_url_with_query(query) == expected_url
+
Review comment:
```suggestion
```
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] wolfier commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
wolfier commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r601660940
##########
File path: airflow/utils/helpers.py
##########
@@ -22,9 +22,10 @@
from functools import reduce
from itertools import filterfalse, tee
from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, TypeVar
-from urllib import parse
+from flask import url_for
from jinja2 import Template
+from urllib import parse
Review comment:
oooh. I was wondering why there was a separation there.
Will do.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r600891025
##########
File path: airflow/utils/helpers.py
##########
@@ -213,4 +213,4 @@ def build_airflow_url_with_query(query: Dict[str, Any]) -> str:
'http://0.0.0.0:8000/base/graph?dag_id=my-task&root=&execution_date=2020-10-27T10%3A59%3A25.615587
"""
view = conf.get('webserver', 'dag_default_view').lower()
- return f"/{view}?{parse.urlencode(query)}"
+ return url_for(f'Airflow.{view}', **query)
Review comment:
Kwrags of `url_for` are by default used for endpoint variable arguments (e.g. `/foo/{var}`), and only unrecognised key-values are appended as a query string. This works now since (I think) none of Airflow’s endpoints currently take any arguments, but could introduce subtle bugs in the future. Something like this is probably better for maintenance down the road.
```python
url = flask.url_for(f"Airflow.{view}")
return f"{url}?{urllib.parse.urlencode(query)}"
```
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-816224166
One test failed
```
FAILED tests/utils/test_helpers.py::TestHelpers::test_build_airflow_url_with_query
```
URL: https://github.com/apache/airflow/pull/14990/checks?check_run_id=2293633953#step:6:11359
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] wolfier commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
wolfier commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-815295378
@kaxil
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r601274447
##########
File path: airflow/utils/helpers.py
##########
@@ -22,9 +22,10 @@
from functools import reduce
from itertools import filterfalse, tee
from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, TypeVar
-from urllib import parse
+from flask import url_for
from jinja2 import Template
+from urllib import parse
Review comment:
This should be put in the block above, with other stdlib imports.
##########
File path: airflow/utils/helpers.py
##########
@@ -22,9 +22,10 @@
from functools import reduce
from itertools import filterfalse, tee
from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, TypeVar
-from urllib import parse
+from flask import url_for
from jinja2 import Template
+from urllib import parse
Review comment:
This should be in the block above, with other stdlib imports.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] github-actions[bot] commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-817237507
[The Workflow run](https://github.com/apache/airflow/actions/runs/737205894) is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-817294805
Awesome work, congrats on your first merged pull request!
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] wolfier commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
wolfier commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-816793542
These failures are hard to find :( I see them now if i view them in raw logs.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] wolfier commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
wolfier commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-816146682
Thank you for pointing those out! I missed those checks!
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r611173137
##########
File path: tests/utils/test_helpers.py
##########
@@ -18,6 +18,7 @@
import unittest
from datetime import datetime
+from unittest import mock
Review comment:
```suggestion
```
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
uranusjr commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r600891025
##########
File path: airflow/utils/helpers.py
##########
@@ -213,4 +213,4 @@ def build_airflow_url_with_query(query: Dict[str, Any]) -> str:
'http://0.0.0.0:8000/base/graph?dag_id=my-task&root=&execution_date=2020-10-27T10%3A59%3A25.615587
"""
view = conf.get('webserver', 'dag_default_view').lower()
- return f"/{view}?{parse.urlencode(query)}"
+ return url_for(f'Airflow.{view}', **query)
Review comment:
Kwrags of `url_for` are by default used for endpoint variable arguments (e.g. `/foo/{var}`), and only unrecognised key-values are appended as a query string. This works now since (I think) none of Airflow’s endpoints currently take any arguments, but could introduce subtle bugs in the future. Something like this is probably better for maintenance down the road.
```python
url = url_for(f"Airflow.{view}")
f"{url}?{urllib.parse.urlencode(query)}"
```
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] wolfier commented on a change in pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
wolfier commented on a change in pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#discussion_r600963085
##########
File path: airflow/utils/helpers.py
##########
@@ -213,4 +213,4 @@ def build_airflow_url_with_query(query: Dict[str, Any]) -> str:
'http://0.0.0.0:8000/base/graph?dag_id=my-task&root=&execution_date=2020-10-27T10%3A59%3A25.615587
"""
view = conf.get('webserver', 'dag_default_view').lower()
- return f"/{view}?{parse.urlencode(query)}"
+ return url_for(f'Airflow.{view}', **query)
Review comment:
Great insight! I will follow your suggestion!
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] wolfier commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
wolfier commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-817235666
Fixed test with cached_app which is needed for url_for.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] github-actions[bot] commented on pull request #14990: Fix url generation for TriggerDagRunOperatorLink
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #14990:
URL: https://github.com/apache/airflow/pull/14990#issuecomment-817294263
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org