Skip to content

Commit

Permalink
default console width
Browse files Browse the repository at this point in the history
  • Loading branch information
hkproj committed May 21, 2023
1 parent 926c861 commit 96ffac0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 96ffac0

Please sign in to comment.