yegeniy opened a new pull request #6281: Run batches of (self-terminating) EMR 
JobFlows [AIRFLOW-XXX]
URL: https://github.com/apache/airflow/pull/6281
 
 
   What is this:
   -------------
   
   This commit introduces an implementation of an operator that allows
   Airflow to manage the execution of multiple EMR clusters. The clusters
   are all configured through a Jinja template ahead of time, but submitted
   in batches, allowing for workflows that require both sequences and
   parallel clusters. The operator assumes that all the clusters it manages
   auto-terminate.
   
   As demonstrated in the unit test, with this operator the following
   batches of EMR clusters could be set up: First, cluster1 runs its steps
   until they all complete and the cluster terminates. Then, cluster2a and
   cluster2b run their steps in parallel until they both terminate.
   Finally, cluster3 runs its steps.
   
   Why use this:
   -------------
   
   1) The primary appeal of this operator is for submitting one-off tasks
   to EMR. The most straight-forward way to do this is to set up a DAG
   consisting of a single `EmrRunJobFlows` operator which derives its
   `job_flows` value from the DagRun's conf attribute ([`airflow dags
   trigger --conf`][1]). While the actual EMR steps are obfuscated, one
   small benefit from using this operator over modifying the DAG using the
   existing EMR operators is that, while the resulting work is dynamic at
   DagRun-time, the structure of the DAG stays constant between wildly
   different runs, so we can see the execution history even when a typical
   DAG would have been modified and lost its history in the Web UI.
   
   [1]: https://airflow.readthedocs.io/en/latest/cli-ref.html#trigger
   
   2) It can also simplify the retry logic wherever
   `EmrCreateJobFlowOperator` and `EmrJobFlowSensor` operator pairs are
   used. The `retry_handler` of an `EmrJobFlowSensor` task would need to
   run an `airflow clear` on the preceding `EmrCreateJobFlowOperator` task
   if it detects that the cluster failed, while somehow maintaining the
   total count of attempts. Using the `EmrJobFlowSensor`, a cluster can be
   restarted on failure without a custom `retry_handler` - simply by
   setting `retries > 0`. Please note that, as described in its docstring,
   the current implementation of `EmrRunJobFlows` limits the retry logic to
   just this basic use case. This is because we don't expose any
   information for a `retry_handler` to reason about at this time. This
   could be improved by pushing step- and cluster- level status information
   to an XCom, but that is not implemented here at this time because the
   operator implementation is complex enough as is. If they are to be
   retried, please make sure that all steps be idempotent.
   
   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/browse/AIRFLOW-XXX
     - 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.
     - In case you are proposing a fundamental code change, you need to create 
an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)).
     - In case you are adding a dependency, check if the license complies with 
the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Description
   
   - [ ] Here are some details about my PR, including screenshots of any UI 
changes:
   
   ### Tests
   
   - [ ] My PR adds the following unit tests __OR__ does not need testing for 
this extremely good reason:
   
   ### 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.
     - All the public functions and the classes in the PR contain docstrings 
that explain what it does
     - If you implement backwards incompatible changes, please leave a note in 
the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so 
we can assign it to a appropriate release
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to