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/07/08 10:05:15 UTC

[GitHub] [airflow] ashb commented on a change in pull request #16766: Add an Amazon EMR on EKS provider package

ashb commented on a change in pull request #16766:
URL: https://github.com/apache/airflow/pull/16766#discussion_r666054245



##########
File path: airflow/providers/amazon/aws/operators/emr_containers.py
##########
@@ -0,0 +1,151 @@
+# 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.
+
+from typing import Any, Optional
+from uuid import uuid4
+
+from airflow.exceptions import AirflowException
+
+try:
+    from functools import cached_property
+except ImportError:
+    from cached_property import cached_property
+
+from airflow.models import BaseOperator
+from airflow.providers.amazon.aws.hooks.emr_containers import EMRContainerHook
+from airflow.utils.decorators import apply_defaults
+
+
+class EMRContainerOperator(BaseOperator):
+    """
+    An operator that submits jobs to EMR on EKS virtual clusters.
+
+    :param name: The name of the job run.
+    :type name: str
+    :param virtual_cluster_id: The EMR on EKS virtual cluster ID
+    :type virtual_cluster_id: str
+    :param execution_role_arn: The IAM role ARN associated with the job run.
+    :type execution_role_arn: str
+    :param release_label: The Amazon EMR release version to use for the job run.
+    :type release_label: str
+    :param job_driver: Job configuration details, e.g. the Spark job parameters.
+    :type job_driver: dict
+    :param configuration_overrides: The configuration overrides for the job run,
+        specifically either application configuration or monitoring configuration.
+    :type configuration_overrides: dict
+    :param client_request_token: The client idempotency token of the job run request.
+        Use this if you want to specify a unique ID to prevent two jobs from getting started.
+        If no token is provided, a UUIDv4 token will be generated for you.
+    :type client_request_token: str
+    :param aws_conn_id: The Airflow connection used for AWS credentials.
+    :type aws_conn_id: str
+    :param sleep_time: Time (in seconds) to wait between two consecutive calls to check query status on EMR
+    :type sleep_time: int
+    :param max_tries: Maximum number of times to wait for the job run to finish.
+        Defaults to None, which will poll until the job is *not* in a pending, submitted, or running state.
+    :type max_tries: int
+    """
+
+    template_fields = ["name", "virtual_cluster_id", "execution_role_arn", "release_label", "job_driver"]
+    ui_color = "#f9c915"
+
+    @apply_defaults
+    def __init__(  # pylint: disable=too-many-arguments
+        self,
+        *,
+        name: str,
+        virtual_cluster_id: str,
+        execution_role_arn: str,
+        release_label: str,
+        job_driver: dict,
+        configuration_overrides: Optional[dict] = None,
+        client_request_token: Optional[str] = None,
+        aws_conn_id: str = "aws_default",
+        sleep_time: int = 30,

Review comment:
       defaults inline is fine, and is the more moral style we use, espeically as the constant would only be used in this one place.




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