From 781c2d5855412d0aa47be82a06a566cc2f364b80 Mon Sep 17 00:00:00 2001 From: Julie Ganeshan Date: Tue, 3 Dec 2024 08:43:53 -0800 Subject: [PATCH] Strip lines when log-tailing (#973) Summary: For some reason, certain jobs have logs that end in \n\n, making unreadable whitespace This diff explicitly strips lines before prefixing them, and then manually adds back exactly one "\n" Created from CodeHub with https://fburl.com/edit-in-codehub Reviewed By: haonans, tonykao8080 Differential Revision: D66191123 --- torchx/util/log_tee_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchx/util/log_tee_helpers.py b/torchx/util/log_tee_helpers.py index 0bad6f8f2..df43bf248 100644 --- a/torchx/util/log_tee_helpers.py +++ b/torchx/util/log_tee_helpers.py @@ -102,7 +102,7 @@ def _print_log_lines_for_role_replica( color_begin = "" color_end = "" prefix = f"{color_begin}{which_role}/{which_replica}{color_end} " - print(_prefix_line(prefix, line), file=dst, end="", flush=True) + print(_prefix_line(prefix, line.strip()), file=dst, end="\n", flush=True) except Exception as e: exceptions.put(e) raise