dstandish commented on code in PR #28440:
URL: https://github.com/apache/airflow/pull/28440#discussion_r1060411483
##########
airflow/utils/log/file_task_handler.py:
##########
@@ -62,19 +62,29 @@ def __init__(self, base_log_folder: str, filename_template:
str | None = None):
# handler, not the one that calls super()__init__.
stacklevel=(2 if type(self) == FileTaskHandler else 3),
)
+ self.maintain_propagate: bool = False
def set_context(self, ti: TaskInstance) -> None | SetContextPropagate:
"""
Provide task_instance context to airflow task handler.
+ Generally speaking returns None. But if attr `maintain_propagate` has
+ been set to propagate, then returns sentinel MAINTAIN_PROPAGATE. This
+ has the effect of overriding the default behavior to set `propagate`
+ to False whenever set_context is called. At time of writing, this
+ functionality is only used in unit testing.
+
:param ti: task instance object
"""
- local_loc = self._init_file(ti)
- self.handler = NonCachingFileHandler(local_loc, encoding="utf-8")
- if self.formatter:
- self.handler.setFormatter(self.formatter)
- self.handler.setLevel(self.level)
- return None
+ from airflow.models.taskinstance import TaskInstance
+
+ if isinstance(ti, TaskInstance):
+ local_loc = self._init_file(ti)
+ self.handler = NonCachingFileHandler(local_loc, encoding="utf-8")
+ if self.formatter:
+ self.handler.setFormatter(self.formatter)
+ self.handler.setLevel(self.level)
Review Comment:
i think it came up when i was mocking a TI.... and it doesn't hurt
anybody.... but i've removed it for now let's see what the tests say
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]