airflow.providers.microsoft.azure.log.wasb_task_handler

WasbRemoteLogIO

便于配置使用类名作为日志记录器的超类。

WasbTaskHandler

WasbTaskHandler 是一个处理和读取任务实例日志的 Python 日志处理程序。

模块内容

class airflow.providers.microsoft.azure.log.wasb_task_handler.WasbRemoteLogIO(context=None)[source]

基类: airflow.utils.log.logging_mixin.LoggingMixin

便于配置使用类名作为日志记录器的超类。

remote_base: str[source]
base_log_folder: pathlib.Path[source]
delete_local_copy: bool[source]
wasb_container: str[source]
processors = ()[source]
upload(path, ti)[source]

将给定的日志路径上传到远程存储。

property hook[source]

返回 WasbHook。

read(relative_path, ti)[source]
wasb_log_exists(remote_log_location)[source]

检查 remote_log_location 是否存在于远程存储中。

参数:

remote_log_location (str) – 日志在远程存储中的位置

返回:

如果位置存在则返回 True,否则返回 False

返回类型:

bool

wasb_read(remote_log_location, return_error=False)[source]

返回在 remote_log_location 找到的日志。如果找不到日志或发生错误,则返回 ‘’。

参数:
  • remote_log_location (str) – 日志在远程存储中的位置

  • return_error (bool) – 如果为 True,则在发生错误时返回字符串错误消息。否则,在发生错误时返回 ‘’。

write(log, remote_log_location, append=True)[source]

将日志写入 remote_log_location。如果未创建 hook,则静默失败。

参数:
  • log (str) – 要写入 remote_log_location 的日志

  • remote_log_location (str) – 日志在远程存储中的位置

  • append (bool) – 如果为 False,任何现有日志文件将被覆盖。如果为 True,新日志将附加到任何现有日志之后。

class airflow.providers.microsoft.azure.log.wasb_task_handler.WasbTaskHandler(base_log_folder, wasb_log_folder, wasb_container, **kwargs)[source]

基类: airflow.utils.log.file_task_handler.FileTaskHandler, airflow.utils.log.logging_mixin.LoggingMixin

WasbTaskHandler 是一个处理和读取任务实例日志的 Python 日志处理程序。

它扩展了 airflow FileTaskHandler,并上传和读取 Wasb 远程存储。

trigger_should_wrap = True[source]
handler: logging.FileHandler | None = None[source]
log_relative_path = ''[source]
closed = False[source]
upload_on_close = True[source]
io[source]
set_context(ti, *, identifier=None)[source]

为 airflow 任务处理程序提供 task_instance 上下文。

通常返回 None。但如果属性 maintain_propagate 被设置为 propagate,则返回 sentinel MAINTAIN_PROPAGATE。这会覆盖在每次调用 set_context 时将 propagate 设置为 False 的默认行为。在编写本文时,此功能仅用于单元测试。

参数:
  • ti (airflow.models.taskinstance.TaskInstance) – 任务实例对象

  • identifier (str | None) – 如果设置,则向日志文件添加后缀。用于在任务或触发器运行之外的上下文将异常消息中继到任务日志。

close()[source]

关闭并将本地日志文件上传到 Wasb 远程存储。

此条目有帮助吗?