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 2019/10/19 17:28:05 UTC

[GitHub] [airflow] nuclearpinguin commented on a change in pull request #6371: [AIRFLOW-5691] Rewrite Dataproc operators to use python library

nuclearpinguin commented on a change in pull request #6371: [AIRFLOW-5691] Rewrite Dataproc operators to use python library
URL: https://github.com/apache/airflow/pull/6371#discussion_r336746250
 
 

 ##########
 File path: airflow/gcp/example_dags/example_dataproc.py
 ##########
 @@ -41,69 +40,130 @@
 PYSPARK_MAIN = os.environ.get("PYSPARK_MAIN", "hello_world.py")
 PYSPARK_URI = "gs://{}/{}".format(BUCKET, PYSPARK_MAIN)
 
+
+# Cluster definition
+CLUSTER = {
+    "project_id": PROJECT_ID,
+    "cluster_name": CLUSTER_NAME,
+    "config": {
+        "master_config": {
+            "num_instances": 1,
+            "machine_type_uri": "n1-standard-4",
+            "disk_config": {"boot_disk_type": "pd-standard", "boot_disk_size_gb": 1024},
+        },
+        "worker_config": {
+            "num_instances": 2,
+            "machine_type_uri": "n1-standard-4",
+            "disk_config": {"boot_disk_type": "pd-standard", "boot_disk_size_gb": 1024},
+        },
+    },
+}
+
+
+# Update options
+CLUSTER_UPDATE = {
+    "config": {
+        "worker_config": {"num_instances": 3},
+        "secondary_worker_config": {"num_instances": 3},
+    }
+}
+UPDATE_MASK = {
+    "paths": [
+        "config.worker_config.num_instances",
+        "config.secondary_worker_config.num_instances",
+    ]
+}
+
+TIMEOUT = {"seconds": 1 * 24 * 60 * 60}
+
+
+# Jobs definitions
+PIG_JOB = {
+    "reference": {"project_id": PROJECT_ID},
+    "placement": {"cluster_name": CLUSTER_NAME},
+    "pig_job": {"query_list": {"queries": ["define sin HiveUDF('sin');"]}},
+}
+
+SPARK_SQL_JOB = {
+    "reference": {"project_id": PROJECT_ID},
+    "placement": {"cluster_name": CLUSTER_NAME},
+    "spark_sql_job": {"query_list": {"queries": ["SHOW DATABASES;"]}},
+}
+
+SPARK_JOB = {
+    "reference": {"project_id": PROJECT_ID},
+    "placement": {"cluster_name": CLUSTER_NAME},
+    "spark_job": {
+        "jar_file_uris": ["file:///usr/lib/spark/examples/jars/spark-examples.jar"],
+        "main_class": "org.apache.spark.examples.SparkPi",
+    },
+}
+
+PYSPARK_JOB = {
+    "reference": {"project_id": PROJECT_ID},
+    "placement": {"cluster_name": CLUSTER_NAME},
+    "pyspark_job": {"main_python_file_uri": PYSPARK_URI},
+}
+
+HIVE_JOB = {
+    "reference": {"project_id": PROJECT_ID},
+    "placement": {"cluster_name": CLUSTER_NAME},
+    "hive_job": {"query_list": {"queries": ["SHOW DATABASES;"]}},
+}
+
+HADOOP_JOB = {
+    "reference": {"project_id": PROJECT_ID},
+    "placement": {"cluster_name": CLUSTER_NAME},
+    "hadoop_job": {
+        "main_jar_file_uri": "file:///usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar",
+        "args": ["wordcount", "gs://pub/shakespeare/rose.txt", OUTPUT_PATH],
+    },
+}
+
 with models.DAG(
     "example_gcp_dataproc",
     default_args={"start_date": airflow.utils.dates.days_ago(1)},
     schedule_interval=None,
 ) as dag:
     create_cluster = DataprocClusterCreateOperator(
-        task_id="create_cluster",
-        cluster_name=CLUSTER_NAME,
-        project_id=PROJECT_ID,
-        num_workers=2,
-        region=REGION,
+        task_id="create_cluster", project_id=PROJECT_ID, cluster=CLUSTER, region=REGION
 
 Review comment:
   Yes, that was how I checked backwards compatibility. Channing example DAG was last thing I did. If you wish I can change the DAG in separate PR.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services