This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-8-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit feaeb8c5fb246f945be5aa96ba49441c6700ae39 Author: Daniel Standish <15932138+dstand...@users.noreply.github.com> AuthorDate: Tue Nov 21 09:55:16 2023 -0800 Check attr on parent not self re TaskContextLogger set_context (#35780) To know whether we should supply `identifier` param, need to check parent class. --- airflow/providers/amazon/aws/log/s3_task_handler.py | 4 +++- airflow/providers/elasticsearch/log/es_task_handler.py | 4 +++- airflow/providers/google/cloud/log/gcs_task_handler.py | 4 +++- airflow/providers/microsoft/azure/log/wasb_task_handler.py | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/airflow/providers/amazon/aws/log/s3_task_handler.py b/airflow/providers/amazon/aws/log/s3_task_handler.py index 761c4ce463..f3664f7c41 100644 --- a/airflow/providers/amazon/aws/log/s3_task_handler.py +++ b/airflow/providers/amazon/aws/log/s3_task_handler.py @@ -78,7 +78,9 @@ class S3TaskHandler(FileTaskHandler, LoggingMixin): ) def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None: - if getattr(self, "supports_task_context_logging", False): + # todo: remove-at-min-airflow-version-2.8 + # after Airflow 2.8 can always pass `identifier` + if getattr(super(), "supports_task_context_logging", False): super().set_context(ti, identifier=identifier) else: super().set_context(ti) diff --git a/airflow/providers/elasticsearch/log/es_task_handler.py b/airflow/providers/elasticsearch/log/es_task_handler.py index 1e8c75b7e3..c9d3a180e1 100644 --- a/airflow/providers/elasticsearch/log/es_task_handler.py +++ b/airflow/providers/elasticsearch/log/es_task_handler.py @@ -443,7 +443,9 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix self.handler.setLevel(self.level) self.handler.setFormatter(self.formatter) else: - if getattr(self, "supports_task_context_logging", False): + # todo: remove-at-min-airflow-version-2.8 + # after Airflow 2.8 can always pass `identifier` + if getattr(super(), "supports_task_context_logging", False): super().set_context(ti, identifier=identifier) else: super().set_context(ti) diff --git a/airflow/providers/google/cloud/log/gcs_task_handler.py b/airflow/providers/google/cloud/log/gcs_task_handler.py index 39d0f072a8..9921bb8753 100644 --- a/airflow/providers/google/cloud/log/gcs_task_handler.py +++ b/airflow/providers/google/cloud/log/gcs_task_handler.py @@ -142,7 +142,9 @@ class GCSTaskHandler(FileTaskHandler, LoggingMixin): ) def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None: - if getattr(self, "supports_task_context_logging", False): + # todo: remove-at-min-airflow-version-2.8 + # after Airflow 2.8 can always pass `identifier` + if getattr(super(), "supports_task_context_logging", False): super().set_context(ti, identifier=identifier) else: super().set_context(ti) diff --git a/airflow/providers/microsoft/azure/log/wasb_task_handler.py b/airflow/providers/microsoft/azure/log/wasb_task_handler.py index f3a00e8432..c57de1acb1 100644 --- a/airflow/providers/microsoft/azure/log/wasb_task_handler.py +++ b/airflow/providers/microsoft/azure/log/wasb_task_handler.py @@ -96,7 +96,9 @@ class WasbTaskHandler(FileTaskHandler, LoggingMixin): return None def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None: - if getattr(self, "supports_task_context_logging", False): + # todo: remove-at-min-airflow-version-2.8 + # after Airflow 2.8 can always pass `identifier` + if getattr(super(), "supports_task_context_logging", False): super().set_context(ti, identifier=identifier) else: super().set_context(ti)