From 296f0f81c7acc6ec58dd7cba635e24849234d28f Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Thu, 24 Oct 2024 10:09:32 +0200 Subject: [PATCH] better timing directory creation (#914) --- pyphare/pyphare/simulator/monitoring.py | 17 +++++++++++++++++ pyphare/pyphare/simulator/simulator.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pyphare/pyphare/simulator/monitoring.py b/pyphare/pyphare/simulator/monitoring.py index fb2703e01..3d7abbf74 100644 --- a/pyphare/pyphare/simulator/monitoring.py +++ b/pyphare/pyphare/simulator/monitoring.py @@ -1,5 +1,14 @@ +# +# +# + +import os from pathlib import Path +from pyphare.logger import getLogger + +logger = getLogger(__name__) + def have_phlop(): from importlib.util import find_spec @@ -46,3 +55,11 @@ def monitoring_shutdown(cpplib): if _globals.stats_man: _globals.stats_man.kill().join() + + +def timing_setup(cpplib): + if cpplib.mpi_rank() == 0: + try: + Path(".phare/timings").mkdir(parents=True, exist_ok=True) + except FileNotFoundError: + logger.error(f"Couldn't find timing dir from {os.getcwd() }") diff --git a/pyphare/pyphare/simulator/simulator.py b/pyphare/pyphare/simulator/simulator.py index 66e2f5ffe..5bebe5e30 100644 --- a/pyphare/pyphare/simulator/simulator.py +++ b/pyphare/pyphare/simulator/simulator.py @@ -30,7 +30,7 @@ def make_cpp_simulator(dim, interp, nbrRefinedPart, hier): from pyphare.cpp import cpp_lib if SCOPE_TIMING: - Path(".phare/timings").mkdir(exist_ok=True) + mon.timing_setup(cpp_lib()) make_sim = f"make_simulator_{dim}_{interp}_{nbrRefinedPart}" return getattr(cpp_lib(), make_sim)(hier)