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 2020/06/18 14:13:56 UTC

[GitHub] [airflow] turbaszek opened a new pull request #9380: Use current_app.dag_bag instead of global variable

turbaszek opened a new pull request #9380:
URL: https://github.com/apache/airflow/pull/9380


   This PR proposes to use `flask.current_app.dag_bag` instead of global variable from `airflow.www.views`. In this way, there will be no coupling between views and the new API.
   
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Target Github ISSUE in description if exists
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   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).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


----------------------------------------------------------------
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] mik-laj commented on a change in pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9380:
URL: https://github.com/apache/airflow/pull/9380#discussion_r442262303



##########
File path: tests/www/test_views.py
##########
@@ -2535,7 +2531,7 @@ def test_operator_extra_link_multiple_operators(self, get_dag_function):
         AirflowLink2 returns 'https://airflow.apache.org/1.10.5/' link
         GoogleLink returns 'https://www.google.com'
         """
-        get_dag_function.return_value = self.dag
+        mock_get_dagbag.return_value.get_dag.return_value = self.dag

Review comment:
       It will be simpler.




----------------------------------------------------------------
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] turbaszek commented on pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
turbaszek commented on pull request #9380:
URL: https://github.com/apache/airflow/pull/9380#issuecomment-646046329


   @mik-laj and @ephraimbuddy you may want to take a look


----------------------------------------------------------------
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] mik-laj commented on pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
mik-laj commented on pull request #9380:
URL: https://github.com/apache/airflow/pull/9380#issuecomment-646504132


   I was afraid that this change could affect the time it took to run the tests.  However, I checked it and saw no degradation.
       Before:
   ```
   ==================================================================== 1 failed, 169 passed, 6 skipped, 134 warnings in 370.20s (0:06:10) ====================================================================
   ```
    After:
   ```
   ==================================================================== 1 failed, 169 passed, 6 skipped, 134 warnings in 366.13s (0:06:06) ====================================================================
   ```
   
   I also did manual tests and didn't notice any problems.


----------------------------------------------------------------
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] turbaszek merged pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
turbaszek merged pull request #9380:
URL: https://github.com/apache/airflow/pull/9380


   


----------------------------------------------------------------
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] mik-laj commented on a change in pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9380:
URL: https://github.com/apache/airflow/pull/9380#discussion_r442262100



##########
File path: tests/www/test_views.py
##########
@@ -2535,7 +2531,7 @@ def test_operator_extra_link_multiple_operators(self, get_dag_function):
         AirflowLink2 returns 'https://airflow.apache.org/1.10.5/' link
         GoogleLink returns 'https://www.google.com'
         """
-        get_dag_function.return_value = self.dag
+        mock_get_dagbag.return_value.get_dag.return_value = self.dag

Review comment:
       ```suggestion
           self.app.dagbag = mock.MagicMock(**{'get_dag.return_vaalue': self.dag})
   ```




----------------------------------------------------------------
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] ephraimbuddy commented on pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on pull request #9380:
URL: https://github.com/apache/airflow/pull/9380#issuecomment-646072195


   There's one test that is failing. `pytest tests/www/test_views.py -k test_failed_success`. From the name, it seems to be the expected behaviour?


----------------------------------------------------------------
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] turbaszek commented on a change in pull request #9380: Use current_app.dag_bag instead of global variable

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #9380:
URL: https://github.com/apache/airflow/pull/9380#discussion_r442266822



##########
File path: tests/www/test_views.py
##########
@@ -2535,7 +2531,7 @@ def test_operator_extra_link_multiple_operators(self, get_dag_function):
         AirflowLink2 returns 'https://airflow.apache.org/1.10.5/' link
         GoogleLink returns 'https://www.google.com'
         """
-        get_dag_function.return_value = self.dag
+        mock_get_dagbag.return_value.get_dag.return_value = self.dag

Review comment:
       Yes but it has to be done on class level, otherwise this would create side effects




----------------------------------------------------------------
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