-
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
77301be
commit a3651a5
Showing
11 changed files
with
249 additions
and
16 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 |
---|---|---|
|
@@ -20,4 +20,5 @@ tools/cmake.sh | |
perf.* | ||
**/*.h5 | ||
.vscode | ||
|
||
.phare* | ||
REPORT_INFO.zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# | ||
# | ||
# program help looks like | ||
""" | ||
usage: phare_sim.py [-h] [-d] | ||
options: | ||
-h, --help show this help message and exit | ||
-d, --dry-run Validate but do not run simulations | ||
""" | ||
|
||
|
||
def parse_cli_args(): | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-d", | ||
"--dry-run", | ||
help="Validate but do not run simulations", | ||
action="store_true", | ||
default=False, | ||
) | ||
|
||
return parser.parse_args() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import os | ||
import sys | ||
import json | ||
import dataclasses | ||
from pathlib import Path | ||
|
||
from pyphare.core import phare_utilities | ||
import pyphare.cpp as cpp | ||
|
||
DOT_PHARE_DIR = Path(os.getcwd()) / ".phare" | ||
|
||
|
||
def python_version_from(binary): | ||
return phare_utilities.decode_bytes( | ||
phare_utilities.run_cli_cmd(f"{binary} -V", check=True).stdout.strip() | ||
) | ||
|
||
|
||
def check_build_config_is_runtime_compatible(strict=True): | ||
try: | ||
build_config: dict = cpp.build_config() | ||
|
||
if "PHARE_CONFIG_ERROR" in build_config: | ||
return | ||
|
||
build_python_version = build_config["PYTHON_VERSION"] | ||
current_python_version = python_version_from(sys.executable) | ||
if build_python_version != current_python_version: | ||
print("Inconsistency detected!") | ||
print("Python during build and now are not the same!") | ||
print("Build python version :", build_python_version) | ||
print("Current python version:", current_python_version) | ||
raise ValueError("Python version mismatch!") | ||
|
||
except RuntimeError as e: | ||
print("Could not interrogate python versions") | ||
print("Please see 'Having Issues' Section of ISSUES.TXT") | ||
print("Actual error (consider adding to issue report):", e) | ||
|
||
except ValueError as e: | ||
print(e) | ||
if strict: | ||
raise e | ||
|
||
|
||
@dataclasses.dataclass | ||
class RuntimeSettings: | ||
python_version: str | ||
python_binary: str | ||
|
||
|
||
def try_system_binary(cli, log_to): | ||
with open(log_to, "w") as f: | ||
try: | ||
proc = phare_utilities.run_cli_cmd(cli, check=True) | ||
f.write(phare_utilities.decode_bytes(proc.stdout).strip()) | ||
except Exception as e: | ||
f.write(f"failed to run cli command {cli}\n") | ||
f.write(f"error {e}") | ||
|
||
|
||
def try_system_binaries(log_dir): | ||
|
||
try_system_binary("free -g", log_dir / "free_dash_g.txt") | ||
try_system_binary("lscpu", log_dir / "lscpu.txt") | ||
try_system_binary("hwloc-info", log_dir / "hwloc_info.txt") | ||
|
||
|
||
def log_runtime_config(): | ||
cpp_lib = cpp.cpp_lib() | ||
|
||
settings = RuntimeSettings( | ||
python_binary=sys.executable, | ||
python_version=python_version_from(sys.executable), | ||
) | ||
|
||
if cpp_lib.mpi_rank() == 0: | ||
DOT_PHARE_DIR.mkdir(exist_ok=True, parents=True) | ||
cpp_lib.mpi_barrier() | ||
|
||
RANK_DIR = DOT_PHARE_DIR / f"rank_{cpp_lib.mpi_rank()}" | ||
RANK_DIR.mkdir(exist_ok=True) | ||
|
||
with open(RANK_DIR / "runtime_config.json", "w") as f: | ||
json.dump(dataclasses.asdict(settings), f) | ||
|
||
try_system_binaries(RANK_DIR) |
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
Oops, something went wrong.