-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5933e40
commit 6f21b34
Showing
5 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from pathlib import Path | ||
|
||
|
||
def have_phlop(): | ||
from importlib.util import find_spec | ||
|
||
try: | ||
return find_spec("phlop.dict") is not None | ||
except (ImportError, ModuleNotFoundError): | ||
return False | ||
|
||
|
||
def valdict(**kwargs): | ||
if not have_phlop(): | ||
return dict | ||
|
||
from phlop.dict import ValDict # pylint: disable=import-error | ||
|
||
return ValDict(**kwargs) | ||
|
||
|
||
_globals = valdict(stats_man=None) | ||
|
||
|
||
def monitoring_yaml_file(cpplib): | ||
path = Path(".phare") / "stats" / f"rank.{cpplib.mpi_rank()}.yaml" | ||
path.parent.mkdir(exist_ok=True, parents=True) | ||
return path | ||
|
||
|
||
def setup_monitoring(cpplib, interval=10): | ||
if not have_phlop(): | ||
return | ||
|
||
from phlop.app import stats_man as sm # pylint: disable=import-error | ||
|
||
_globals.stats_man = sm.AttachableRuntimeStatsManager( | ||
valdict(yaml=monitoring_yaml_file(cpplib), interval=interval), | ||
dict(rank=cpplib.mpi_rank()), | ||
).start() | ||
|
||
|
||
def monitoring_shutdown(cpplib): | ||
if not have_phlop(): | ||
return | ||
|
||
if _globals.stats_man: | ||
_globals.stats_man.kill().join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters