SamWheating commented on a change in pull request #18197: URL: https://github.com/apache/airflow/pull/18197#discussion_r711836314
########## File path: airflow/providers/google/cloud/operators/dataproc.py ########## @@ -48,6 +54,101 @@ ) +class DataProcCreateWorkflowBaseOperator(BaseOperator): + """Helper class for preparing configs from workflow template""" + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + def _template_has_placement(self): + return True if "placement" in self.template else False + + def _template_is_managed_cluster(self): + + if self._template_has_placement(): + return True if "managed_cluster" in self.template["placement"] else False + else: + # Placement is required field in the template + raise KeyError("Placement is missing") + + def _has_valid_config(self): + if self._template_is_managed_cluster(): + # cluster templates can be of 2 types, managed_cluster or cluster_selector. + return True if "config" in self.template["placement"]["managed_cluster"] else False Review comment: ```suggestion return "config" in self.template["placement"]["managed_cluster"] ``` There's a lot of places in this file which look like: ```python return True if <condition> else False ``` Which can all be shortened to just ```python return <condition> ``` -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org