dacort commented on a change in pull request #16766: URL: https://github.com/apache/airflow/pull/16766#discussion_r667418894
########## File path: airflow/providers/amazon/aws/example_dags/example_emr_eks_job.py ########## @@ -0,0 +1,73 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +This is an example dag for an Amazon EMR on EKS Spark job. +""" +import os +from datetime import timedelta + +from airflow import DAG +from airflow.providers.amazon.aws.operators.emr_containers import EMRContainerOperator +from airflow.utils.dates import days_ago + +# [START howto_operator_emr_eks_env_variables] +VIRTUAL_CLUSTER_ID = os.getenv("VIRTUAL_CLUSTER_ID", "test-cluster") +JOB_ROLE_ARN = os.getenv("JOB_ROLE_ARN", "arn:aws:iam::012345678912:role/emr_eks_default_role") +# [END howto_operator_emr_eks_env_variables] + + +# [START howto_operator_emr_eks_config] +JOB_DRIVER_ARG = { + "sparkSubmitJobDriver": { + "entryPoint": "local:///usr/lib/spark/examples/src/main/python/pi.py", + "sparkSubmitParameters": "--conf spark.executors.instances=2 --conf spark.executors.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1", # noqa: E501 + } +} + +CONFIGURATION_OVERRIDES_ARG = { + "monitoringConfiguration": { + "cloudWatchMonitoringConfiguration": { + "logGroupName": "/aws/emr-eks-spark", + "logStreamNamePrefix": "airflow", + } + } +} +# [END howto_operator_emr_eks_config] + +with DAG( + dag_id='emr_eks_pi_job', + dagrun_timeout=timedelta(hours=2), + start_date=days_ago(1), + schedule_interval="@once", + tags=["emr_containers", "example"], +) as dag: + + # An example of how to get the cluster id and arn from an Airflow connection + # c = BaseHook.get_connection("emr_eks") Review comment: Ah interesting, wasn't aware of that - I'll look more into jinja macros. My goal was to show how to load the cluster id and role arn from a connection as opposed to hard-coding it in the DAG. -- 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]
