跳到主要内容

文本报告

text_reporting.py 脚本演示了如何报告文本输出和样本。

脚本运行时,会在 examples 项目中创建一个名为 text reporting 的任务。

报告文本到控制台

要将文本报告到任务控制台,请调用 Logger.report_text()

# report text
Logger.current_logger().report_text("hello, this is plain text")

使用 Logger.report_text() 报告的文本将显示在 ClearML Web UI 中任务的控制台 (CONSOLE) 选项卡中。

Text to console Text to console

将文本报告为调试样本

要将较长的文本报告为调试样本(例如,日志、大型文本输出或结构化文本文件),请使用文本流和 .txt 文件扩展名调用 Logger.report_media()

text_to_send = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse ac justo ut dolor scelerisque posuere.
...
"""

Logger.current_logger().report_media(
title="text title",
series="text series",
iteration=1,
stream=six.StringIO(text_to_send),
file_extension=".txt",
)

文本样本将显示在 ClearML Web UI 中任务的调试样本 (DEBUG SAMPLES) 选项卡中。

Text debug sample Text debug sample