diff --git a/low_level.py b/low_level.py index 8d56a98..e721508 100644 --- a/low_level.py +++ b/low_level.py @@ -223,8 +223,6 @@ def get_progress_from_logfile(filename): total_operations = int(splitted_line.split("/")[1]) except: pass - elif "Fatal" in line or "Error" in line: - return -1, -1 return current_operation, total_operations @@ -242,14 +240,8 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs current_operation, total_operations = get_progress_from_logfile(filename) 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: # 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 with tqdm(desc=desc, total=total_operations, disable=(verbose==0), **kwargs) as pbar: @@ -259,11 +251,6 @@ def progress_bar_from_logfile(filename:str, desc:str="", verbose:int=1, **kwargs if current_operation > previous_operation: pbar.update(current_operation-previous_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 if k*update_interval >= limit: - print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose) - - return \ No newline at end of file + print_message(f"Progress bar timed out after {limit} seconds.", 3, "low level", verbose=verbose) \ No newline at end of file diff --git a/scola.py b/scola.py index a6156ad..87e2f43 100644 --- a/scola.py +++ b/scola.py @@ -22,9 +22,6 @@ 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 for b in range(1,nboxes_tot+1): 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: print_message(f"Running box {b}/{nboxes_tot}.", 2, "scola", verbose=parsed_args.verbose) command_args = ["scola", paramfile, log_file, "-b", str(b)] @@ -75,10 +72,6 @@ def main_scola(parsed_args): print_message(f"Submitting scola job to SLURM.", 1, "scola", verbose=parsed_args.verbose) 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: subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) else: @@ -112,10 +105,6 @@ def main_scola(parsed_args): print_message(f"Submitting scola job to SLURM.", 1, "scola", verbose=parsed_args.verbose) 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: subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) else: diff --git a/simbelmyne.py b/simbelmyne.py index effb375..417845d 100644 --- a/simbelmyne.py +++ b/simbelmyne.py @@ -14,16 +14,12 @@ def main_simbelmyne(parsed_args): if parsed_args.execution == "local": 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] 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 - 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) + progress_bar_from_logfile(log_file, desc=main_dict["simname"], verbose=parsed_args.verbose, leave=False) else: subprocess.run(command_args) @@ -55,18 +51,13 @@ def main_simbelmyne(parsed_args): 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: subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) else: subprocess.run(command_args) print_message("Simbelmyne job submitted.", 2, "simbelmyne", 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) + progress_bar_from_logfile(log_file, desc=main_dict["simname"], verbose=parsed_args.verbose) else: raise ValueError(f"Execution mode {parsed_args.execution} not recognized.") @@ -84,6 +75,7 @@ if __name__ == "__main__": from slurm_submission import register_arguments_slurm parser = ArgumentParser(description="Run Simbelmyne.") + # TODO: reduce the volume of arguments register_arguments_main(parser) register_arguments_timestepping(parser) register_arguments_simbelmyne(parser)