-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
fix EmrAddStepsOperator broken ref & faulty test
075b196
to
2920ebd
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
R: @ashb |
@nuclearpinguin added commit changes after CR #1 with the changes you requested |
b9b6099
to
d5d7fc0
Compare
|
||
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: |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
Co-Authored-By: Tomek Urbaszek <[email protected]>
Co-Authored-By: Tomek Urbaszek <[email protected]>
Co-Authored-By: Tomek Urbaszek <[email protected]>
Co-Authored-By: Tomek Urbaszek <[email protected]>
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: |
Co-Authored-By: Tomek Urbaszek <[email protected]>
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}') |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
…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 <[email protected]> * Update airflow/contrib/hooks/emr_hook.py Co-Authored-By: Tomek Urbaszek <[email protected]> * Update airflow/contrib/operators/emr_add_steps_operator.py Co-Authored-By: Tomek Urbaszek <[email protected]> * Update airflow/contrib/hooks/emr_hook.py Co-Authored-By: Tomek Urbaszek <[email protected]> * Update tests/contrib/operators/test_emr_add_steps_operator.py Co-Authored-By: Tomek Urbaszek <[email protected]> * changes after CR apache#2 Co-authored-by: Tomek Urbaszek <[email protected]>
Make sure you have checked all steps below.
Jira
Description
This PR fiixes EmrAddStepsOperator broken ref & faulty test
Tests
Fix in
tests.contrib.operators.test_emr_add_steps_operator.TestEmrAddStepsOperator#test_init_with_cluster_name
Commits
Documentation