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/07/01 23:07:33 UTC

[GitHub] [airflow] jedcunningham commented on a change in pull request #16765: Validate type of `priority_weight` during parsing

jedcunningham commented on a change in pull request #16765:
URL: https://github.com/apache/airflow/pull/16765#discussion_r662639162



##########
File path: tests/models/test_baseoperator.py
##########
@@ -109,6 +109,11 @@ def test_incorrect_default_args(self):
         with pytest.raises(AirflowException, match='Argument.*test_param.*required'):
             DummyClass(default_args=default_args)
 
+    def test_incorrect_priority_weight(self):
+        error_msg = "`priority_weight` for task: 'test_op' only accepts integers, <class 'str'> provided: 2."

Review comment:
       ```suggestion
           error_msg = "`priority_weight` for task 'test_op' only accepts integers, received '<class 'str'>'."
   ```

##########
File path: airflow/models/baseoperator.py
##########
@@ -590,10 +590,16 @@ def __init__(
             if isinstance(max_retry_delay, timedelta):
                 self.max_retry_delay = max_retry_delay
             else:
-                self.log.debug("Max_retry_delay isn't timedelta object, assuming secs")
+                self.log.debug("max_retry_delay isn't timedelta object, assuming secs")
                 self.max_retry_delay = timedelta(seconds=max_retry_delay)
 
         self.params = params or {}  # Available in templates!
+        if priority_weight:
+            if not isinstance(priority_weight, int):
+                raise AirflowException(
+                    f"`priority_weight` for task: '{self.task_id}' only accepts integers, "
+                    f"{type(priority_weight)} provided: {priority_weight}."

Review comment:
       ```suggestion
                       f"`priority_weight` for task: '{self.task_id}' only accepts integers, "
                       f"received '{type(priority_weight)}'."
   ```




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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org