-
Notifications
You must be signed in to change notification settings - Fork 24
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 6853bc9
Showing
5 changed files
with
72 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,52 @@ | ||
import os | ||
Check notice Code scanning / CodeQL Unused import Note
Import of 'os' is not used.
|
||
|
||
from pathlib import Path | ||
|
||
|
||
def have_phlop(): | ||
try: | ||
from phlop.dict import ValDict | ||
|
||
return True | ||
except ImportError: | ||
... | ||
Check notice Code scanning / CodeQL Statement has no effect Note
This statement has no effect.
|
||
return False | ||
|
||
|
||
def valdict(**kwargs): | ||
if not have_phlop(): | ||
return dict | ||
|
||
from phlop.dict import ValDict | ||
|
||
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 | ||
|
||
_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 | ||
from phlop.app import stats_man as sm | ||
|
||
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