From 96ffac01935368f183be8ad894c2723fcecb918b Mon Sep 17 00:00:00 2001 From: Umar Jamil Date: Sun, 21 May 2023 18:44:35 +0800 Subject: [PATCH] default console width --- train.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/train.py b/train.py index f71ee29..b7365af 100644 --- a/train.py +++ b/train.py @@ -83,10 +83,14 @@ def run_validation(model, validation_ds, tokenizer_src, tokenizer_tgt, max_len, expected.append(target_text) predicted.append(model_out_text) - # get the console window width - with os.popen('stty size', 'r') as console: - _, console_width = console.read().split() - console_width = int(console_width) + try: + # get the console window width + with os.popen('stty size', 'r') as console: + _, console_width = console.read().split() + console_width = int(console_width) + except: + # If we can't get the console width, use 80 as default + console_width = 80 # Print the source, target and model output print_msg('-'*console_width)