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

Deprecate EmrContainerOperatorAsync #1402

Merged
merged 3 commits into from
Jan 11, 2024
Merged

Conversation

Lee-W
Copy link
Contributor

@Lee-W Lee-W commented Dec 26, 2023

What's changed

Deprecate EmrContainerOperatorAsync and fallback to EmrContainerOperator with deferrable=True
This is blocked by the release of apache/airflow#36417 apache/airflow#36467

upgrade minimum apache-airflow-providers-amazon to 8.15.0

Why this change

The logic of EmrContainerOperatorAsync has been contributed back to OSS airflow as part of EmrContainerOperator

EmrContainerOperatorAsync

def execute(self, context: Context) -> None:
"""Defers trigger class to poll for state of the job run until it reaches a failure state or success state"""
if not poke(self, context):
self.defer(
timeout=timedelta(seconds=self.timeout),
trigger=EmrContainerSensorTrigger(
virtual_cluster_id=self.virtual_cluster_id,
job_id=self.job_id,
max_tries=self.max_retries,
aws_conn_id=self.aws_conn_id,
poll_interval=self.poll_interval,
),
method_name="execute_complete",
)
# Ignoring the override type check because the parent class specifies "context: Any" but specifying it as
# "context: Context" is accurate as it's more specific.
def execute_complete(self, context: Context, event: dict[str, str]) -> None: # type: ignore[override]
"""
Callback for when the trigger fires - returns immediately.
Relies on trigger to throw an exception, otherwise it assumes execution was
successful.
"""
if event:
if event["status"] == "error":
raise_error_or_skip_exception(self.soft_fail, event["message"])
self.log.info(event["message"])
return None

EmrContainerOperator

https://github.com/apache/airflow/blob/999b70178a1f5d891fd2c88af4831a4ba4c2cbc9/airflow/providers/amazon/aws/sensors/emr.py#L318-L346

* feat(amazon): deprecate EmrContainerOperatorAsync
* feat(amazon): remove EmrContainerOperatorTrigger
Copy link

codecov bot commented Dec 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ad9dbb7) 98.54% compared to head (d6f074c) 98.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1402      +/-   ##
==========================================
- Coverage   98.54%   98.41%   -0.13%     
==========================================
  Files          91       91              
  Lines        5364     5312      -52     
==========================================
- Hits         5286     5228      -58     
- Misses         78       84       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Lee-W Lee-W changed the title Deprecate EmrContainerOperatorAsync (#1393) Deprecate EmrContainerOperatorAsync Dec 28, 2023
@Lee-W Lee-W marked this pull request as ready for review January 3, 2024 03:31
Copy link
Contributor

@pankajastro pankajastro left a comment

Choose a reason for hiding this comment

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

LGTM

@Lee-W Lee-W merged commit 5f1f539 into main Jan 11, 2024
11 checks passed
@Lee-W Lee-W deleted the deprecate-EmrContainerOperatorAsync branch January 11, 2024 06:36
self.log.info(event["message"])
job_id: str = event["job_id"]
return job_id
return super().__init__(*args, deferrable=True, **kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, i think it's accidentally added. let me send a quick fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants