From e265136b892c714ee9827949d25656f6fcf1e234 Mon Sep 17 00:00:00 2001 From: Elad Kalif <45845474+eladkal@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:55:19 +0200 Subject: [PATCH 1/6] Deprecating email, email_on_retry, email_on_failure in `BaseOperator` --- airflow/config_templates/config.yml | 8 ++++++++ airflow/models/baseoperator.py | 24 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 613c5e3394a40..529476428ec2d 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -2141,6 +2141,10 @@ email: description: | Whether email alerts should be sent when a task is retried version_added: 2.0.0 + + deprecation_reason: | + This email integration is no longer coupled with Airflow core. + SmtpNotifier provide easy interface to send email notifications. type: boolean example: ~ default: "True" @@ -2151,6 +2155,10 @@ email: type: boolean example: ~ default: "True" + version_deprecated: 2.10.5 + deprecation_reason: | + This email integration is no longer coupled with Airflow core. + SmtpNotifier provide easy interface to send email notifications. subject_template: description: | File that will be used as the template for Email subject (which will be rendered using Jinja2). diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py index 65900276271a6..846eab421c2ff 100644 --- a/airflow/models/baseoperator.py +++ b/airflow/models/baseoperator.py @@ -610,11 +610,11 @@ class derived from this one results in the creation of a task object, (e.g. user/person/team/role name) to clarify ownership is recommended. :param email: the 'to' email address(es) used in email alerts. This can be a single email or multiple ones. Multiple addresses can be specified as a - comma or semicolon separated string or by passing a list of strings. + comma or semicolon separated string or by passing a list of strings. (deprecated) :param email_on_retry: Indicates whether email alerts should be sent when a - task is retried + task is retried (deprecated) :param email_on_failure: Indicates whether email alerts should be sent when - a task failed + a task failed (deprecated) :param retries: the number of retries that should be performed before failing the task :param retry_delay: delay between retries, can be set as ``timedelta`` or @@ -981,6 +981,24 @@ def __init__( self.email_on_retry = email_on_retry self.email_on_failure = email_on_failure + if self.email: + warnings.warn( + "email is deprecated please migrate to SmtpNotifier`.", + RemovedInAirflow3Warning, + stacklevel=2, + ) + if self.email_on_retry: + warnings.warn( + "email_on_retry is deprecated please migrate to SmtpNotifier`.", + RemovedInAirflow3Warning, + stacklevel=2, + ) + if self.email_on_failure: + warnings.warn( + "email_on_retry is deprecated please migrate to SmtpNotifier`.", + RemovedInAirflow3Warning, + stacklevel=2, + ) if execution_timeout is not None and not isinstance(execution_timeout, timedelta): raise ValueError( f"execution_timeout must be timedelta object but passed as type: {type(execution_timeout)}" From 3bad66b376bcc67458602479054e8b4b91dfeeb0 Mon Sep 17 00:00:00 2001 From: Elad Kalif <45845474+eladkal@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:03:26 +0200 Subject: [PATCH 2/6] remove blank line --- airflow/config_templates/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 529476428ec2d..7fbe134602455 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -2141,7 +2141,6 @@ email: description: | Whether email alerts should be sent when a task is retried version_added: 2.0.0 - deprecation_reason: | This email integration is no longer coupled with Airflow core. SmtpNotifier provide easy interface to send email notifications. From 0af8926608eccb21e96b7c7fcc48569468ad4c2f Mon Sep 17 00:00:00 2001 From: Elad Kalif <45845474+eladkal@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:10:59 +0200 Subject: [PATCH 3/6] fix --- airflow/config_templates/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 7fbe134602455..9cd17151d14c4 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -2141,12 +2141,13 @@ email: description: | Whether email alerts should be sent when a task is retried version_added: 2.0.0 - deprecation_reason: | - This email integration is no longer coupled with Airflow core. - SmtpNotifier provide easy interface to send email notifications. type: boolean example: ~ default: "True" + version_deprecated: 2.10.5 + deprecation_reason: | + This email integration is no longer coupled with Airflow core. + SmtpNotifier provide easy interface to send email notifications. default_email_on_failure: description: | Whether email alerts should be sent when a task failed From b6e28aa12f05c45c768b048764c584e5a1861822 Mon Sep 17 00:00:00 2001 From: Elad Kalif <45845474+eladkal@users.noreply.github.com> Date: Tue, 21 Jan 2025 09:01:51 +0200 Subject: [PATCH 4/6] fixes --- airflow/models/baseoperator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py index 846eab421c2ff..22cf8e757107a 100644 --- a/airflow/models/baseoperator.py +++ b/airflow/models/baseoperator.py @@ -981,19 +981,19 @@ def __init__( self.email_on_retry = email_on_retry self.email_on_failure = email_on_failure - if self.email: + if emailis not None: warnings.warn( "email is deprecated please migrate to SmtpNotifier`.", RemovedInAirflow3Warning, stacklevel=2, ) - if self.email_on_retry: + if email_on_retry is not None: warnings.warn( "email_on_retry is deprecated please migrate to SmtpNotifier`.", RemovedInAirflow3Warning, stacklevel=2, ) - if self.email_on_failure: + if email_on_failure is not None: warnings.warn( "email_on_retry is deprecated please migrate to SmtpNotifier`.", RemovedInAirflow3Warning, From 755c1c8de7d6ca5fd1c7a2df3f87e65c6af614a7 Mon Sep 17 00:00:00 2001 From: Elad Kalif <45845474+eladkal@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:31:02 +0200 Subject: [PATCH 5/6] typo --- airflow/models/baseoperator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py index 22cf8e757107a..125622b585708 100644 --- a/airflow/models/baseoperator.py +++ b/airflow/models/baseoperator.py @@ -981,7 +981,7 @@ def __init__( self.email_on_retry = email_on_retry self.email_on_failure = email_on_failure - if emailis not None: + if email is not None: warnings.warn( "email is deprecated please migrate to SmtpNotifier`.", RemovedInAirflow3Warning, From ecde24dd96025905a0ed934af83745232b9a47c8 Mon Sep 17 00:00:00 2001 From: Elad Kalif <45845474+eladkal@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:47:31 +0200 Subject: [PATCH 6/6] fix --- airflow/config_templates/config.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 9cd17151d14c4..613c5e3394a40 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -2144,10 +2144,6 @@ email: type: boolean example: ~ default: "True" - version_deprecated: 2.10.5 - deprecation_reason: | - This email integration is no longer coupled with Airflow core. - SmtpNotifier provide easy interface to send email notifications. default_email_on_failure: description: | Whether email alerts should be sent when a task failed @@ -2155,10 +2151,6 @@ email: type: boolean example: ~ default: "True" - version_deprecated: 2.10.5 - deprecation_reason: | - This email integration is no longer coupled with Airflow core. - SmtpNotifier provide easy interface to send email notifications. subject_template: description: | File that will be used as the template for Email subject (which will be rendered using Jinja2).