Compare commits
3 commits
1ca9b4fb09
...
a12e1a5ab4
Author | SHA1 | Date | |
---|---|---|---|
a12e1a5ab4 | |||
bd0e5f9ffc | |||
fdaf5e9086 |
3 changed files with 37 additions and 5 deletions
15
low_level.py
15
low_level.py
|
@ -223,6 +223,8 @@ def get_progress_from_logfile(filename):
|
||||||
total_operations = int(splitted_line.split("/")[1])
|
total_operations = int(splitted_line.split("/")[1])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
elif "Fatal" in line or "Error" in line:
|
||||||
|
return -1, -1
|
||||||
return current_operation, total_operations
|
return current_operation, total_operations
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,8 +242,14 @@ 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)
|
||||||
|
if current_operation == -1:
|
||||||
|
print_message("Error appeared in log file, skipping it.",level=3,module="low level",verbose=verbose)
|
||||||
return
|
return
|
||||||
|
|
||||||
with tqdm(desc=desc, total=total_operations, disable=(verbose==0), **kwargs) as pbar:
|
with tqdm(desc=desc, total=total_operations, disable=(verbose==0), **kwargs) as pbar:
|
||||||
|
@ -251,6 +259,11 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs
|
||||||
if current_operation > previous_operation:
|
if current_operation > previous_operation:
|
||||||
pbar.update(current_operation-previous_operation)
|
pbar.update(current_operation-previous_operation)
|
||||||
previous_operation = current_operation
|
previous_operation = current_operation
|
||||||
|
if current_operation == -1:
|
||||||
|
print_message("Error appeared in log file, skipping it.",level=3,module="low level",verbose=verbose)
|
||||||
|
return
|
||||||
k+=1
|
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)
|
print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose)
|
||||||
|
|
||||||
|
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,12 +14,16 @@ 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:
|
||||||
subprocess.Popen(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # Use Popen instead of run to be able to display the progress bar
|
subprocess.Popen(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # Use Popen instead of run to be able to display the progress bar
|
||||||
progress_bar_from_logfile(log_file, desc=main_dict["simname"], verbose=parsed_args.verbose, leave=False)
|
if not main_dict["mode"] in ["pre_sCOLA", "post_sCOLA", "allsCOLA"]: # No progress bar for pre/post sCOLA
|
||||||
|
progress_bar_from_logfile(log_file, desc=main_dict["simname"], verbose=parsed_args.verbose, leave=False)
|
||||||
else:
|
else:
|
||||||
subprocess.run(command_args)
|
subprocess.run(command_args)
|
||||||
|
|
||||||
|
@ -51,13 +55,18 @@ 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
|
||||||
|
remove(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:
|
||||||
subprocess.run(command_args)
|
subprocess.run(command_args)
|
||||||
|
|
||||||
print_message("Simbelmyne job submitted.", 2, "simbelmyne", verbose=parsed_args.verbose)
|
print_message("Simbelmyne job submitted.", 2, "simbelmyne", verbose=parsed_args.verbose)
|
||||||
progress_bar_from_logfile(log_file, desc=main_dict["simname"], verbose=parsed_args.verbose)
|
if not main_dict["mode"] in ["pre_sCOLA", "post_sCOLA", "allsCOLA"]: # No progress bar for pre/post sCOLA
|
||||||
|
progress_bar_from_logfile(log_file, desc=main_dict["simname"], verbose=parsed_args.verbose)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Execution mode {parsed_args.execution} not recognized.")
|
raise ValueError(f"Execution mode {parsed_args.execution} not recognized.")
|
||||||
|
@ -75,7 +84,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