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/09/13 07:34:01 UTC

[GitHub] [airflow] iostreamdoth commented on a change in pull request #18197: Add gcs yml config to create dataproc cluster

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



##########
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:
       I believe google-cloud-dataproc takes care of validation of workflow placement message. These are optional either managed_cluster or cluster_selector. 
   https://googleapis.dev/python/dataproc/latest/dataproc_v1beta2/types.html#google.cloud.dataproc_v1beta2.types.WorkflowTemplatePlacement




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