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/05/06 18:44:44 UTC

[GitHub] [airflow] XD-DENG opened a new pull request #8742: Avoid color info in response of /dag_stats & /task_stats

XD-DENG opened a new pull request #8742:
URL: https://github.com/apache/airflow/pull/8742


   Currently the color for each state is repeatedly appearing in the response payload of endpoints `/dag_stats` and `/task_stats`.
   
   This can be avoided by having the mapping between state and color in the static file, and map each state into different color at client side after client receives the necessary info, instead of passing duplicated color information in the response payload.
   
   This significantly reduces the size of data to be transferred from server to client.
   
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] (inapplicable for this change?) 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] XD-DENG commented on a change in pull request #8742: Avoid color info in response of /dag_stats & /task_stats

Posted by GitBox <gi...@apache.org>.
XD-DENG commented on a change in pull request #8742:
URL: https://github.com/apache/airflow/pull/8742#discussion_r421076787



##########
File path: airflow/www/views.py
##########
@@ -353,6 +356,7 @@ def get_int_arg(value, default=0):
                                            status=arg_status_filter if arg_status_filter else None),
             num_runs=num_runs,
             tags=tags,
+            state_color=state_color_mapping,

Review comment:
       Hi @mik-laj , thanks for the suggestion.
   
   I have done an update by adding an assert in an existing test, which should suffice the purpose here.
   
   Let me know if you have any other suggestion? Cheers.




----------------------------------------------------------------
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] XD-DENG commented on a change in pull request #8742: Avoid color info in response of /dag_stats & /task_stats

Posted by GitBox <gi...@apache.org>.
XD-DENG commented on a change in pull request #8742:
URL: https://github.com/apache/airflow/pull/8742#discussion_r421407905



##########
File path: airflow/www/views.py
##########
@@ -337,6 +337,9 @@ def get_int_arg(value, default=0):
 
         num_of_pages = int(math.ceil(num_of_all_dags / float(dags_per_page)))
 
+        state_color_mapping = State.state_color.copy()
+        state_color_mapping["null"] = state_color_mapping.pop(None)

Review comment:
       Python already handles it for us:
   ```python
   import json
   print(json.dumps({None: 123}))
   ```
   gives us `{"null": 123}`.
   
   The issue is the `sort_keys` argument when we run `json.dumps()`.
   




----------------------------------------------------------------
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] XD-DENG commented on pull request #8742: Avoid color info in response of /dag_stats & /task_stats

Posted by GitBox <gi...@apache.org>.
XD-DENG commented on pull request #8742:
URL: https://github.com/apache/airflow/pull/8742#issuecomment-625392001


   Rebased to the latest master


----------------------------------------------------------------
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 #8742: Avoid color info in response of /dag_stats & /task_stats

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



##########
File path: airflow/www/views.py
##########
@@ -353,6 +356,7 @@ def get_int_arg(value, default=0):
                                            status=arg_status_filter if arg_status_filter else None),
             num_runs=num_runs,
             tags=tags,
+            state_color=state_color_mapping,

Review comment:
       Hi. Would you like to add a test that will check if the correct value was passed to the template? A method has been added today that makes it easy. I think it's worth gradually extending this idea to other tests to increase the confidence of the Web UI tests.
   https://github.com/apache/airflow/pull/8505




----------------------------------------------------------------
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] XD-DENG commented on a change in pull request #8742: Avoid color info in response of /dag_stats & /task_stats

Posted by GitBox <gi...@apache.org>.
XD-DENG commented on a change in pull request #8742:
URL: https://github.com/apache/airflow/pull/8742#discussion_r421013821



##########
File path: airflow/www/views.py
##########
@@ -337,6 +337,9 @@ def get_int_arg(value, default=0):
 
         num_of_pages = int(math.ceil(num_of_all_dags / float(dags_per_page)))
 
+        state_color_mapping = State.state_color.copy()
+        state_color_mapping["null"] = state_color_mapping.pop(None)

Review comment:
       `None` is one of the keys in `State.state_color`, and it cannot be handled by Flask's `tojson` directly. So a special treatment is needed here.
   
   A related issue I raised in Flask: https://github.com/pallets/flask/issues/3599




----------------------------------------------------------------
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] ashb commented on a change in pull request #8742: Avoid color info in response of /dag_stats & /task_stats

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



##########
File path: airflow/www/views.py
##########
@@ -337,6 +337,9 @@ def get_int_arg(value, default=0):
 
         num_of_pages = int(math.ceil(num_of_all_dags / float(dags_per_page)))
 
+        state_color_mapping = State.state_color.copy()
+        state_color_mapping["null"] = state_color_mapping.pop(None)

Review comment:
       Keys in JSON must be strings, so `{ null: "x"}` isn't valid JSON. So it _sort_ of makes sense that it doesn't get added. Sort of.




----------------------------------------------------------------
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] XD-DENG commented on pull request #8742: Avoid color info in response of /dag_stats & /task_stats

Posted by GitBox <gi...@apache.org>.
XD-DENG commented on pull request #8742:
URL: https://github.com/apache/airflow/pull/8742#issuecomment-626361211


   Hi guys @mik-laj @kaxil @ashb , a gentle ping. Mind taking another 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