fdoelker
fdoelker
RRunPod
Created by fdoelker on 6/3/2024 in #⛅|pods
Console for kohya_ss / Stable Diffusion
Awesome this helped a lot. I have this script running in a notebook now
import time
import os
import collections
from IPython.display import clear_output

log_file_path = "/workspace/logs/webui.log"
# log_file_path = "/workspace/logs/kohya_ss.log"

# Function to get the last N lines from a file
def get_last_n_lines(file_path, n=30): # Changed to 50 lines
with open(file_path, 'rb') as file:
# Deque to store the last N lines
last_n_lines = collections.deque(maxlen=n)
try:
# Read lines and append to deque
for line in file:
last_n_lines.append(line)
except Exception as e:
print(f"An error occurred: {e}")
# Decode lines from bytes to string
return [line.decode('utf-8').strip() for line in last_n_lines]

while True:
# Clear the previous output
clear_output(wait=True)

# Get the last n lines from the log file
last_n_lines = get_last_n_lines(log_file_path) # Changed to 50 lines

# Display the last n lines in JupyterLab
for line in last_n_lines:
print(line)

# Wait for a brief moment before checking for updates
time.sleep(0.1)
import time
import os
import collections
from IPython.display import clear_output

log_file_path = "/workspace/logs/webui.log"
# log_file_path = "/workspace/logs/kohya_ss.log"

# Function to get the last N lines from a file
def get_last_n_lines(file_path, n=30): # Changed to 50 lines
with open(file_path, 'rb') as file:
# Deque to store the last N lines
last_n_lines = collections.deque(maxlen=n)
try:
# Read lines and append to deque
for line in file:
last_n_lines.append(line)
except Exception as e:
print(f"An error occurred: {e}")
# Decode lines from bytes to string
return [line.decode('utf-8').strip() for line in last_n_lines]

while True:
# Clear the previous output
clear_output(wait=True)

# Get the last n lines from the log file
last_n_lines = get_last_n_lines(log_file_path) # Changed to 50 lines

# Display the last n lines in JupyterLab
for line in last_n_lines:
print(line)

# Wait for a brief moment before checking for updates
time.sleep(0.1)
Works like a charm. Thank you @digigoblin !
4 replies