[jira] [Commented] (AIRFLOW-2310) Enable AWS Glue Job Integration
[ https://issues.apache.org/jira/browse/AIRFLOW-2310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16657924#comment-16657924 ] ASF GitHub Bot commented on AIRFLOW-2310: - Fokko closed pull request #3504: [AIRFLOW-2310]: Add AWS Glue Job Compatibility to Airflow URL: https://github.com/apache/incubator-airflow/pull/3504 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/airflow/contrib/aws_glue_job_hook.py b/airflow/contrib/aws_glue_job_hook.py new file mode 100644 index 00..323313400a --- /dev/null +++ b/airflow/contrib/aws_glue_job_hook.py @@ -0,0 +1,212 @@ +# -*- coding: utf-8 -*- +# +# 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 airflow.exceptions import AirflowException +from airflow.contrib.hooks.aws_hook import AwsHook +import os.path +import time + + +class AwsGlueJobHook(AwsHook): +""" +Interact with AWS Glue - create job, trigger, crawler + +:param job_name: unique job name per AWS account +:type str +:param desc: job description +:type str +:param concurrent_run_limit: The maximum number of concurrent runs allowed for a job +:type int +:param script_location: path to etl script either on s3 or local +:type str +:param conns: A list of connections used by the job +:type list +:param retry_limit: Maximum number of times to retry this job if it fails +:type int +:param num_of_dpus: Number of AWS Glue DPUs to allocate to this Job +:type int +:param region_name: aws region name (example: us-east-1) +:type region_name: str +:param s3_bucket: S3 bucket where logs and local etl script will be uploaded +:type str +:param iam_role_name: AWS IAM Role for Glue Job +:type str +""" + +def __init__(self, + job_name=None, + desc=None, + concurrent_run_limit=None, + script_location=None, + conns=None, + retry_limit=None, + num_of_dpus=None, + aws_conn_id='aws_default', + region_name=None, + iam_role_name=None, + s3_bucket=None, *args, **kwargs): +self.job_name = job_name +self.desc = desc +self.concurrent_run_limit = concurrent_run_limit or 1 +self.script_location = script_location +self.conns = conns or ["s3"] +self.retry_limit = retry_limit or 0 +self.num_of_dpus = num_of_dpus or 10 +self.aws_conn_id = aws_conn_id +self.region_name = region_name +self.s3_bucket = s3_bucket +self.role_name = iam_role_name +self.S3_PROTOCOL = "s3://" +self.S3_ARTIFACTS_PREFIX = 'artifacts/glue-scripts/' +self.S3_GLUE_LOGS = 'logs/glue-logs/' +super(AwsGlueJobHook, self).__init__(*args, **kwargs) + +def get_conn(self): +conn = self.get_client_type('glue', self.region_name) +return conn + +def list_jobs(self): +conn = self.get_conn() +return conn.get_jobs() + +def get_iam_execution_role(self): +""" +:return: iam role for job execution +""" +iam_client = self.get_client_type('iam', self.region_name) + +try: +glue_execution_role = iam_client.get_role(RoleName=self.role_name) +self.log.info("Iam Role Name: {}".format(self.role_name)) +return glue_execution_role +except Exception as general_error: +raise AirflowException( +'Failed to create aws glue job, error: {error}'.format( +error=str(general_error) +) +) + +def initialize_job(self, script_arguments=None): +""" +Initializes connection with AWS Glue +to run job +:return: +""" +if self.s3_bucket is None: +raise AirflowException( +'Could not initialize
[jira] [Commented] (AIRFLOW-2310) Enable AWS Glue Job Integration
[ https://issues.apache.org/jira/browse/AIRFLOW-2310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16656307#comment-16656307 ] ASF GitHub Bot commented on AIRFLOW-2310: - oelesinsc24 opened a new pull request #4068: [AIRFLOW-2310]: Add AWS Glue Job Compatibility to Airflow URL: https://github.com/apache/incubator-airflow/pull/4068 Make sure you have checked _all_ steps below. ### Jira - [ ] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/projects/AIRFLOW/issues/AIRFLOW-2310 - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue. ### Description - [ ] Here are some details about my PR, including screenshots of any UI changes: - This PR is a continuation of the existing PR: https://github.com/apache/incubator-airflow/pull/3504. - Adds AWS Glue execution to Apache Airflow ### Tests - [ ] My PR adds the following unit tests OR does not need testing for this extremely good reason: Added tests.contrib.test_aws_glue_job_hook.py. However, moto the test class for boto3 does not support AWS Glue Job mock currently ### Commits - [ ] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [ ] In case of new functionality, my PR adds documentation that describes how to use it. - When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added. ### Code Quality - [ ] Passes `flake8` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Enable AWS Glue Job Integration > --- > > Key: AIRFLOW-2310 > URL: https://issues.apache.org/jira/browse/AIRFLOW-2310 > Project: Apache Airflow > Issue Type: Improvement > Components: contrib >Reporter: Olalekan Elesin >Assignee: Olalekan Elesin >Priority: Major > Labels: AWS > > Would it be possible to integrate AWS Glue into Airflow, such that Glue jobs > and ETL pipelines can be orchestrated with Airflow -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (AIRFLOW-2310) Enable AWS Glue Job Integration
[ https://issues.apache.org/jira/browse/AIRFLOW-2310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16564040#comment-16564040 ] ASF GitHub Bot commented on AIRFLOW-2310: - suma-ps commented on issue #3504: [AIRFLOW-2310]: Add AWS Glue Job Compatibility to Airflow URL: https://github.com/apache/incubator-airflow/pull/3504#issuecomment-409303864 @OElesin Do you plan to resolve the merge issues soon? Looking forward to using the Glue operator soon, thanks! This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Enable AWS Glue Job Integration > --- > > Key: AIRFLOW-2310 > URL: https://issues.apache.org/jira/browse/AIRFLOW-2310 > Project: Apache Airflow > Issue Type: Improvement > Components: contrib >Reporter: Olalekan Elesin >Assignee: Olalekan Elesin >Priority: Major > Labels: AWS > > Would it be possible to integrate AWS Glue into Airflow, such that Glue jobs > and ETL pipelines can be orchestrated with Airflow -- This message was sent by Atlassian JIRA (v7.6.3#76005)