kaxil commented on a change in pull request #6749: [AIRFLOW-6193] Do not use 
asserts in Airflow main code
URL: https://github.com/apache/airflow/pull/6749#discussion_r355152935
 
 

 ##########
 File path: airflow/providers/google/cloud/operators/dataproc.py
 ##########
 @@ -232,12 +232,11 @@ def __init__(self,
         self.customer_managed_key = customer_managed_key
         self.single_node = num_workers == 0
 
-        assert not (self.custom_image and self.image_version), \
-            "custom_image and image_version can't be both set"
+        if self.custom_image and self.image_version:
+            raise ValueError("The custom_image and image_version can't be both 
set")
 
-        assert (
-            not self.single_node or (self.single_node and 
self.num_preemptible_workers == 0)
-        ), "num_workers == 0 means single node mode - no preemptibles allowed"
+        if self.num_preemptible_workers == 0 and not self.single_node:
+            raise ValueError("num_workers == 0 means single node mode - no 
preemptibles allowed")
 
 Review comment:
   This doesn't cover the case when `self.num_preemptible_workers >= 0 and 
self.single_node`
   
   So I think it should be
   ```suggestion
           if self.single_node and self.num_preemptible_workers > 0:
               raise ValueError("num_workers == 0 means single node mode - no 
preemptibles allowed")
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to