fixing progress bars with log files
This commit is contained in:
parent
32fa9a5afb
commit
942f775425
3 changed files with 23 additions and 2 deletions
|
@ -240,6 +240,10 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs
|
||||||
current_operation, total_operations = get_progress_from_logfile(filename)
|
current_operation, total_operations = get_progress_from_logfile(filename)
|
||||||
previous_operation = 0
|
previous_operation = 0
|
||||||
|
|
||||||
|
while total_operations == 0: # Wait for the simulation to be initialised, and to run the first operation
|
||||||
|
sleep(2)
|
||||||
|
current_operation, total_operations = get_progress_from_logfile(filename)
|
||||||
|
|
||||||
if current_operation == total_operations:
|
if current_operation == total_operations:
|
||||||
# print_message("Progress bar not needed, the process is already finished.", 3, "low level", verbose=verbose)
|
# print_message("Progress bar not needed, the process is already finished.", 3, "low level", verbose=verbose)
|
||||||
return
|
return
|
||||||
|
|
11
scola.py
11
scola.py
|
@ -22,6 +22,9 @@ def main_scola(parsed_args):
|
||||||
tile_bar = tqdm(total=nboxes_tot, desc="sCOLA", unit="box", disable=(parsed_args.verbose!=1)) # The progress bar cannot work if there are print statements in the loop
|
tile_bar = tqdm(total=nboxes_tot, desc="sCOLA", unit="box", disable=(parsed_args.verbose!=1)) # The progress bar cannot work if there are print statements in the loop
|
||||||
for b in range(1,nboxes_tot+1):
|
for b in range(1,nboxes_tot+1):
|
||||||
if not isfile(card_dict["OutputTilesBase"]+str(b)+".h5") or parsed_args.force:
|
if not isfile(card_dict["OutputTilesBase"]+str(b)+".h5") or parsed_args.force:
|
||||||
|
if isfile(log_file+f"_{b}"): # Remove the preexisting log file to allow for the progress_bar to be run normally
|
||||||
|
from os import remove
|
||||||
|
remove(log_file+f"_{b}")
|
||||||
if parsed_args.verbose > 1:
|
if parsed_args.verbose > 1:
|
||||||
print_message(f"Running box {b}/{nboxes_tot}.", 2, "scola", verbose=parsed_args.verbose)
|
print_message(f"Running box {b}/{nboxes_tot}.", 2, "scola", verbose=parsed_args.verbose)
|
||||||
command_args = ["scola", paramfile, log_file, "-b", str(b)]
|
command_args = ["scola", paramfile, log_file, "-b", str(b)]
|
||||||
|
@ -72,6 +75,10 @@ def main_scola(parsed_args):
|
||||||
print_message(f"Submitting scola job to SLURM.", 1, "scola", verbose=parsed_args.verbose)
|
print_message(f"Submitting scola job to SLURM.", 1, "scola", verbose=parsed_args.verbose)
|
||||||
command_args = ["sbatch", slurm_script]
|
command_args = ["sbatch", slurm_script]
|
||||||
|
|
||||||
|
for b in range(1,nboxes_tot+1):
|
||||||
|
if isfile(log_file+f"_{b}"): # Remove the preexisting log file to allow for the progress_bar to be run normally
|
||||||
|
os.remove(log_file+f"_{b}")
|
||||||
|
|
||||||
if parsed_args.verbose < 2:
|
if parsed_args.verbose < 2:
|
||||||
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
else:
|
else:
|
||||||
|
@ -105,6 +112,10 @@ def main_scola(parsed_args):
|
||||||
print_message(f"Submitting scola job to SLURM.", 1, "scola", verbose=parsed_args.verbose)
|
print_message(f"Submitting scola job to SLURM.", 1, "scola", verbose=parsed_args.verbose)
|
||||||
command_args = ["sbatch", slurm_script]
|
command_args = ["sbatch", slurm_script]
|
||||||
|
|
||||||
|
for b in range(missing_tiles[0],missing_tiles[1]+1):
|
||||||
|
if isfile(log_file+f"_{b}"): # Remove the preexisting log file to allow for the progress_bar to be run normally
|
||||||
|
os.remove(log_file+f"_{b}")
|
||||||
|
|
||||||
if parsed_args.verbose < 2:
|
if parsed_args.verbose < 2:
|
||||||
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -14,7 +14,10 @@ def main_simbelmyne(parsed_args):
|
||||||
if parsed_args.execution == "local":
|
if parsed_args.execution == "local":
|
||||||
print_message("Running Simbelyne in local mode.", 1, "simbelmyne", verbose=parsed_args.verbose)
|
print_message("Running Simbelyne in local mode.", 1, "simbelmyne", verbose=parsed_args.verbose)
|
||||||
|
|
||||||
|
if isfile(log_file): # Remove the preexisting log file to allow for the progress_bar to be run normally
|
||||||
|
from os import remove
|
||||||
|
oremove(log_file)
|
||||||
|
|
||||||
command_args = ["simbelmyne", paramfile, log_file]
|
command_args = ["simbelmyne", paramfile, log_file]
|
||||||
|
|
||||||
if parsed_args.verbose < 2:
|
if parsed_args.verbose < 2:
|
||||||
|
@ -51,6 +54,10 @@ def main_simbelmyne(parsed_args):
|
||||||
|
|
||||||
command_args = ["sbatch", slurm_script]
|
command_args = ["sbatch", slurm_script]
|
||||||
|
|
||||||
|
if isfile(log_file): # Remove the preexisting log file to allow for the progress_bar to be run normally
|
||||||
|
from os import remove
|
||||||
|
oremove(log_file)
|
||||||
|
|
||||||
if parsed_args.verbose < 2:
|
if parsed_args.verbose < 2:
|
||||||
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
else:
|
else:
|
||||||
|
@ -75,7 +82,6 @@ if __name__ == "__main__":
|
||||||
from slurm_submission import register_arguments_slurm
|
from slurm_submission import register_arguments_slurm
|
||||||
|
|
||||||
parser = ArgumentParser(description="Run Simbelmyne.")
|
parser = ArgumentParser(description="Run Simbelmyne.")
|
||||||
# TODO: reduce the volume of arguments
|
|
||||||
register_arguments_main(parser)
|
register_arguments_main(parser)
|
||||||
register_arguments_timestepping(parser)
|
register_arguments_timestepping(parser)
|
||||||
register_arguments_simbelmyne(parser)
|
register_arguments_simbelmyne(parser)
|
||||||
|
|
Loading…
Add table
Reference in a new issue