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/07/29 07:50:27 UTC

[GitHub] [airflow] turbaszek opened a new pull request #10033: Introduce BaseExecutor.validate_command to avoid duplication

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


   This PR proposes a simple method to avoid duplication of code in Executors.
   
   ---
   **^ 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] turbaszek merged pull request #10033: Introduce BaseExecutor.validate_command to avoid duplication

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


   


----------------------------------------------------------------
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 #10033: Introduce BaseExecutor.validate_command to avoid duplication

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



##########
File path: airflow/executors/celery_executor.py
##########
@@ -71,9 +71,7 @@
 @app.task
 def execute_command(command_to_exec: CommandType) -> None:
     """Executes command."""
-    if command_to_exec[0:3] != ["airflow", "tasks", "run"]:
-        raise ValueError('The command must start with ["airflow", "tasks", "run"].')
-
+    BaseExecutor.validate_command(command_to_exec)

Review comment:
       ```suggestion
       cls.validate_command(command_to_exec)
   ```
   
   that should work 🤷  - WDYT ?

##########
File path: airflow/executors/celery_executor.py
##########
@@ -71,9 +71,7 @@
 @app.task
 def execute_command(command_to_exec: CommandType) -> None:
     """Executes command."""
-    if command_to_exec[0:3] != ["airflow", "tasks", "run"]:
-        raise ValueError('The command must start with ["airflow", "tasks", "run"].')
-
+    BaseExecutor.validate_command(command_to_exec)

Review comment:
       Oh yes, sry didnt realize it was not a part of the class




----------------------------------------------------------------
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 #10033: Introduce BaseExecutor.validate_command to avoid duplication

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



##########
File path: airflow/executors/celery_executor.py
##########
@@ -71,9 +71,7 @@
 @app.task
 def execute_command(command_to_exec: CommandType) -> None:
     """Executes command."""
-    if command_to_exec[0:3] != ["airflow", "tasks", "run"]:
-        raise ValueError('The command must start with ["airflow", "tasks", "run"].')
-
+    BaseExecutor.validate_command(command_to_exec)

Review comment:
       I think the `cls` will be undefined in this place

##########
File path: airflow/executors/celery_executor.py
##########
@@ -71,9 +71,7 @@
 @app.task
 def execute_command(command_to_exec: CommandType) -> None:
     """Executes command."""
-    if command_to_exec[0:3] != ["airflow", "tasks", "run"]:
-        raise ValueError('The command must start with ["airflow", "tasks", "run"].')
-
+    BaseExecutor.validate_command(command_to_exec)

Review comment:
       But I updated other usages to `self.` instead of `BaseExecutor.`




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