Skip to content

Commit

Permalink
Removed conditional check for task context logging in airflow version…
Browse files Browse the repository at this point in the history
… 2.8.0 and above (apache#42764)
  • Loading branch information
dirrao authored and joaopamaral committed Oct 21, 2024
1 parent 4ea77a4 commit dc1cb6a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 30 deletions.
7 changes: 1 addition & 6 deletions airflow/providers/amazon/aws/log/s3_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ def hook(self):
)

def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None:
# 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)
super().set_context(ti, identifier=identifier)
# Local location and remote location is needed to open and
# upload local log file to S3 remote storage.
if TYPE_CHECKING:
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/elasticsearch/log/es_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,7 @@ def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> Non
self.handler.setLevel(self.level)
self.handler.setFormatter(self.formatter)
else:
# 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)
super().set_context(ti, identifier=identifier)
self.context_set = True

def close(self) -> None:
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/google/cloud/log/gcs_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ def client(self) -> storage.Client:
)

def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None:
# 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)
super().set_context(ti, identifier=identifier)
# Log relative path is used to construct local and remote
# log path to upload log files into GCS and read from the
# remote location.
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/microsoft/azure/log/wasb_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ def hook(self):
return None

def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None:
# 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)
super().set_context(ti, identifier=identifier)
# Local location and remote location is needed to open and
# upload local log file to Wasb remote storage.
if TYPE_CHECKING:
Expand Down
7 changes: 1 addition & 6 deletions airflow/providers/opensearch/log/os_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,7 @@ def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> Non
self.handler.setLevel(self.level)
self.handler.setFormatter(self.formatter)
else:
# 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)
super().set_context(ti, identifier=identifier)
self.context_set = True

def emit(self, record):
Expand Down

0 comments on commit dc1cb6a

Please sign in to comment.