more improvements

This commit is contained in:
Mayeul Aubin 2025-03-06 16:22:04 +01:00
parent e488275523
commit 5fa4dd9683
6 changed files with 56 additions and 44 deletions

View file

@ -185,7 +185,7 @@ def print_ending_module(module:str, verbose:int=1):
print(print_level(0, module)+f"Ending {module} module.")
def wait_until_file_exists(filename:str, verbose:int=1, limit:int=24*3600):
def wait_until_file_exists(filename:str, verbose:int=1, limit:int=1200):
"""
Wait until a file exists.
"""
@ -233,7 +233,7 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs
from tqdm import tqdm
from time import sleep
k=0
limit=3600
limit=600
update_interval=0.2
sleep(2) # Wait for the process to be launched, and for the previous log file to be overwritten if necessary.
wait_until_file_exists(filename, verbose=verbose, limit=limit)
@ -245,12 +245,12 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs
return
with tqdm(desc=desc, total=total_operations, disable=(verbose==0), **kwargs) as pbar:
while current_operation < total_operations and k/update_interval < limit:
while current_operation < total_operations and k*update_interval < limit:
sleep(update_interval)
current_operation, total_operations = get_progress_from_logfile(filename)
if current_operation > previous_operation:
pbar.update(current_operation-previous_operation)
previous_operation = current_operation
k+=1
if k/update_interval >= limit:
if k*update_interval >= limit:
print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose)