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



##########
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:
       Hm, I'm not sure if ignoring any `KeyError` is a good approach. Or do we 
expect that the template will be wrong and the validation will happen on 
Dataproc side?




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