Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found #6898

Conversation

aviemzur
Copy link
Member

@aviemzur aviemzur commented Dec 25, 2019

Make sure you have checked all steps below.

Jira

Description

  • Here are some details about my PR, including screenshots of any UI changes:

This PR fiixes EmrAddStepsOperator broken ref & faulty test

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    Fix in tests.contrib.operators.test_emr_add_steps_operator.TestEmrAddStepsOperator#test_init_with_cluster_name

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":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. 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 so we can assign it to a appropriate release

@aviemzur aviemzur changed the title fix EmrAddStepsOperator broken ref & faulty test [AIRFLOW-6432] fix EmrAddStepsOperator broken ref & faulty test Dec 25, 2019
fix EmrAddStepsOperator broken ref & faulty test
@aviemzur aviemzur force-pushed the AIRFLOW-6342-fix-emr-add-steps-operator-broken-ref-and-faulty-test branch from 075b196 to 2920ebd Compare December 25, 2019 07:54
@codecov-io
Copy link

codecov-io commented Dec 25, 2019

Codecov Report

Merging #6898 into master will decrease coverage by 0.07%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6898      +/-   ##
==========================================
- Coverage   84.62%   84.54%   -0.08%     
==========================================
  Files         679      679              
  Lines       38505    38618     +113     
==========================================
+ Hits        32584    32650      +66     
- Misses       5921     5968      +47
Impacted Files Coverage Δ
...irflow/contrib/operators/emr_add_steps_operator.py 91.42% <100%> (+0.25%) ⬆️
airflow/contrib/hooks/emr_hook.py 93.75% <66.66%> (+0.2%) ⬆️
airflow/contrib/hooks/cassandra_hook.py 0% <0%> (-100%) ⬇️
airflow/kubernetes/volume_mount.py 44.44% <0%> (-55.56%) ⬇️
airflow/kubernetes/volume.py 52.94% <0%> (-47.06%) ⬇️
airflow/kubernetes/pod_launcher.py 45.25% <0%> (-46.72%) ⬇️
airflow/kubernetes/refresh_config.py 50.98% <0%> (-23.53%) ⬇️
...rflow/contrib/operators/kubernetes_pod_operator.py 78.75% <0%> (-20%) ⬇️
airflow/models/__init__.py 91.3% <0%> (-8.7%) ⬇️
airflow/utils/cli.py 68.75% <0%> (-5.99%) ⬇️
... and 44 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 581a395...d1d638f. Read the comment docs.

@aviemzur
Copy link
Member Author

R: @ashb

@aviemzur
Copy link
Member Author

@nuclearpinguin added commit changes after CR #1 with the changes you requested

@aviemzur aviemzur changed the title [AIRFLOW-6432] fix EmrAddStepsOperator broken ref & faulty test [AIRFLOW-6432] fix EmrAddStepsOperator broken ref & faulty test & add test case for missing cluster Dec 25, 2019
@aviemzur aviemzur force-pushed the AIRFLOW-6342-fix-emr-add-steps-operator-broken-ref-and-faulty-test branch from b9b6099 to d5d7fc0 Compare December 25, 2019 10:41
airflow/contrib/hooks/emr_hook.py Outdated Show resolved Hide resolved
airflow/contrib/hooks/emr_hook.py Outdated Show resolved Hide resolved
airflow/contrib/hooks/emr_hook.py Outdated Show resolved Hide resolved
airflow/contrib/operators/emr_add_steps_operator.py Outdated Show resolved Hide resolved

job_flow_id = self.job_flow_id

if not job_flow_id:
job_flow_id = emr.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
job_flow_id = emr_hook.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
if not job_flow_id:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is duplicated check, what about:

job_flow_id = job_flow_id  or emr_hook.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
if not job_flow_id:
    raise...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@turbaszek turbaszek added the provider:amazon-aws AWS/Amazon - related issues label Dec 28, 2019
aviemzur and others added 4 commits December 29, 2019 13:09
Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>
Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>
Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>
Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>
@ashb
Copy link
Member

ashb commented Dec 31, 2019

Waht do you mean by "fix EmrAddStepsOperator broken ref"? I can't quite decipher this.

Can you please update the PR title to be a line you would like to see in the changelog about this.

@aviemzur
Copy link
Member Author

aviemzur commented Dec 31, 2019

Waht do you mean by "fix EmrAddStepsOperator broken ref"? I can't quite decipher this.

Can you please update the PR title to be a line you would like to see in the changelog about this.

Sure, how about:
[AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found

Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>
@aviemzur aviemzur changed the title [AIRFLOW-6432] fix EmrAddStepsOperator broken ref & faulty test & add test case for missing cluster [AIRFLOW-6432] throw proper exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name Dec 31, 2019
@aviemzur aviemzur changed the title [AIRFLOW-6432] throw proper exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name [AIRFLOW-6432] raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name Dec 31, 2019
@aviemzur aviemzur changed the title [AIRFLOW-6432] raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name [AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name Dec 31, 2019
@aviemzur aviemzur closed this Dec 31, 2019
@aviemzur aviemzur reopened this Dec 31, 2019
if not job_flow_id:
job_flow_id = emr.get_cluster_id_by_name(self.job_flow_name, self.cluster_states)
raise AirflowException(f'No cluster found for name: {self.job_flow_name}')
Copy link
Member

@turbaszek turbaszek Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I start to think when this exception will be reached? When emr_hook.get_cluster_id_by_name return None. Is it possible or this will fail when calling emr_hook.get_cluster_id_by_name whith self.job_flow_name=None?

Copy link
Member Author

@aviemzur aviemzur Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you ask for a job_flow_name that doesn't exist it returns None
emr_hook.py
test case

@aviemzur aviemzur changed the title [AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found by that name [AIRFLOW-6432] Raise appropriate exception in EmrAddStepsOperator when using job_flow_name and no cluster is found Dec 31, 2019
@turbaszek turbaszek merged commit 5a82741 into apache:master Dec 31, 2019
@aviemzur aviemzur deleted the AIRFLOW-6342-fix-emr-add-steps-operator-broken-ref-and-faulty-test branch January 1, 2020 07:24
galuszkak pushed a commit to FlyrInc/apache-airflow that referenced this pull request Mar 5, 2020
…n using job_flow_name and no cluster is found (apache#6898)

* [AIRFLOW-6432] fixes in EmrAddStepsOperator

fix EmrAddStepsOperator broken ref & faulty test

* changes after CR #1

* Add exception and test case

* Update airflow/contrib/hooks/emr_hook.py

Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>

* Update airflow/contrib/hooks/emr_hook.py

Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>

* Update airflow/contrib/operators/emr_add_steps_operator.py

Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>

* Update airflow/contrib/hooks/emr_hook.py

Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>

* Update tests/contrib/operators/test_emr_add_steps_operator.py

Co-Authored-By: Tomek Urbaszek <turbaszek@gmail.com>

* changes after CR apache#2

Co-authored-by: Tomek Urbaszek <turbaszek@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider:amazon-aws AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants