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

@ -19,16 +19,7 @@ def main_monofonic(parsed_args):
command_args = [path_to_monofonic_binary, monofonic_dict["config"]]
if parsed_args.verbose < 2:
from io import BytesIO
from low_level import stdout_redirector, stderr_redirector
f = BytesIO()
g = BytesIO()
with stdout_redirector(f):
with stderr_redirector(g):
subprocess.run(command_args)
g.close()
f.close()
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
subprocess.run(command_args)
@ -42,8 +33,8 @@ def main_monofonic(parsed_args):
main_dict=parse_arguments_main(parsed_args)
slurm_script = slurm_dict["scripts"]+"monofonic.sh"
if not isfile(slurm_script):
print_message(f"SLURM script {slurm_script} does not exist. Creating it.", 2, "monofonic", verbose=parsed_args.verbose)
if not isfile(slurm_script) or parsed_args.force:
print_message(f"SLURM script {slurm_script} does not exist (or forced). Creating it.", 2, "monofonic", verbose=parsed_args.verbose)
create_slurm_script(
slurm_template=slurm_dict["monofonic_template"],
slurm_script=slurm_script,
@ -60,16 +51,7 @@ def main_monofonic(parsed_args):
command_args = ["sbatch", slurm_script]
if parsed_args.verbose < 2:
from io import BytesIO
from low_level import stdout_redirector, stderr_redirector
f = BytesIO()
g = BytesIO()
with stdout_redirector(f):
with stderr_redirector(g):
subprocess.run(command_args)
g.close()
f.close()
subprocess.run(command_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
subprocess.run(command_args)
@ -97,6 +79,6 @@ if __name__ == "__main__":
register_arguments_slurm(parser)
register_arguments_card_for_ICs(parser)
register_arguments_cosmo(parser)
parsed_args = parser.parse_args
parsed_args = parser.parse_args()
main_monofonic(parsed_args)