turbaszek commented on a change in pull request #18197:
URL: https://github.com/apache/airflow/pull/18197#discussion_r707358215



##########
File path: airflow/providers/google/cloud/operators/dataproc.py
##########
@@ -48,6 +54,83 @@
 )
 
 
+class DataProcCreateWorkflowBaseOperator(BaseOperator):
+    """Helper class for preparing configs from workflow template"""
+
+    def __init__(self, **kwargs):
+        super().__init__(**kwargs)
+
+    def prepare_template(self) -> None:
+        try:
+            # if no file is specified, skip
+            if 
isinstance(self.template["placement"]["managed_cluster"]["config"], str):
+                if 
urlparse(self.template["placement"]["managed_cluster"]["config"]).scheme == 
"gs":
+                    config = self._build_cluster_config(
+                        self.template["placement"]["managed_cluster"]["config"]
+                    )
+
+                    # Dataproc workflows do not accept life cycle_config
+                    if "lifecycle_config" in config:
+                        self.log.warning(
+                            "Workflow does not accept lifecycle in config, 
removing it from config"
+                        )
+                        config.pop("lifecycle_config", None)
+                    self.template["placement"]["managed_cluster"]["config"] = 
config
+                else:
+                    self.log.warning(
+                        "Workflow Template config accepts only gcs path string 
or dictioanry type, "
+                        "skipping build cluster config from yml file"
+                    )
+        except KeyError:
+            pass

Review comment:
       Is there a chance that building template will fail on `KeyError` but the 
template will be valid? If yes, then we should raise the error and expect users 
to always provided valid templates 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to