你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Fix loading python environment in reframe tests
这个提交包含在:
4
tests/.gitignore
vendored
4
tests/.gitignore
vendored
@@ -2,4 +2,6 @@ output/
|
||||
stage/
|
||||
reframe.log
|
||||
reframe.out
|
||||
reframe_perf.out
|
||||
reframe_perf.out
|
||||
|
||||
configuration/user_config.py
|
@@ -4,25 +4,30 @@ import reframe as rfm
|
||||
import reframe.utility.sanity as sn
|
||||
from reframe.utility import udeps
|
||||
|
||||
from configuration.user_config import GPRMAX_ROOT_DIR
|
||||
|
||||
|
||||
PATH_TO_PYENV = os.path.join(".venv", "bin", "activate")
|
||||
|
||||
@rfm.simple_test
|
||||
class CreatePyenvTest(rfm.RunOnlyRegressionTest):
|
||||
valid_systems = ["archer2:compute"]
|
||||
valid_prog_environs = ["PrgEnv-cray"]
|
||||
valid_systems = ["generic", "archer2:login"]
|
||||
valid_prog_environs = ["builtin", "PrgEnv-cray"]
|
||||
modules = ["cray-python"]
|
||||
|
||||
# DOES NOT CURRENTLY WORK!!!
|
||||
prerun_cmds = [
|
||||
"python -m venv --system-site-packages --prompt gprMax .venv",
|
||||
"source .venv/bin/activate",
|
||||
"pip install -r requirements.txt"
|
||||
f"source {PATH_TO_PYENV}",
|
||||
f"pip install -r {os.path.join(GPRMAX_ROOT_DIR, 'requirements.txt')}"
|
||||
]
|
||||
executable = "pip install -e ."
|
||||
keep_files = ["requirements.txt"]
|
||||
executable = f"pip install -e {GPRMAX_ROOT_DIR}"
|
||||
|
||||
@sanity_function
|
||||
def test_requirements_installed(self):
|
||||
return sn.assert_found(r'Successfully installed ', self.stdout) and sn.assert_not_found(r'ERROR', self.stdout)
|
||||
def check_requirements_installed(self):
|
||||
return sn.assert_found(r"Successfully installed (?!gprMax)", self.stdout, "Failed to install requirements") \
|
||||
and sn.assert_found(r"Successfully installed gprMax", self.stdout, "Failed to install gprMax") \
|
||||
and sn.assert_not_found(r"finished with status 'error'", self.stdout) \
|
||||
and sn.assert_not_found(r"ERROR:", self.stderr)
|
||||
|
||||
|
||||
class GprmaxBaseTest(rfm.RunOnlyRegressionTest):
|
||||
@@ -30,7 +35,6 @@ class GprmaxBaseTest(rfm.RunOnlyRegressionTest):
|
||||
valid_prog_environs = ["PrgEnv-cray"]
|
||||
executable = "python -m gprMax --log-level 25"
|
||||
exclusive_access = True
|
||||
prerun_cmds = ["source .venv/bin/activate"]
|
||||
|
||||
@run_after("init")
|
||||
def setup_omp(self):
|
||||
@@ -40,12 +44,13 @@ class GprmaxBaseTest(rfm.RunOnlyRegressionTest):
|
||||
|
||||
@run_after("init")
|
||||
def inject_dependencies(self):
|
||||
self.depends_on("CreatePyenvTest", udeps.fully)
|
||||
self.depends_on("CreatePyenvTest", udeps.by_env)
|
||||
|
||||
@require_deps
|
||||
def set_sourcedir(self, CreatePyenvTest):
|
||||
self.sourcesdir = ['src', CreatePyenvTest(part="archer2:compute", environ="PrgEnv-cray").stagedir]
|
||||
def set_sourcesdir(self, CreatePyenvTest):
|
||||
path_to_pyenv = os.path.join(CreatePyenvTest(part="login").stagedir, PATH_TO_PYENV)
|
||||
self.prerun_cmds = [f"source {path_to_pyenv}"]
|
||||
|
||||
@sanity_function
|
||||
def test_simulation_complete(self):
|
||||
return sn.assert_found(r'=== Simulation completed in ', self.stdout)
|
||||
return sn.assert_found(r"=== Simulation completed in ", self.stdout)
|
@@ -4,6 +4,7 @@ import reframe as rfm
|
||||
from reframe.core.builtins import parameter
|
||||
|
||||
from base_tests import GprmaxBaseTest
|
||||
from utilities.data import get_data_from_h5_file
|
||||
|
||||
|
||||
"""ReFrame tests for taskfarm functionality
|
||||
@@ -27,7 +28,7 @@ class BasicModelsTest(GprmaxBaseTest):
|
||||
|
||||
# List of available basic test models
|
||||
model = parameter([
|
||||
"2D_ExHyHz"
|
||||
"2D_ExHyHz",
|
||||
"2D_EyHxHz",
|
||||
"2D_EzHxHy",
|
||||
"cylinder_Ascan_2D",
|
||||
@@ -39,6 +40,10 @@ class BasicModelsTest(GprmaxBaseTest):
|
||||
num_cpus_per_task = 16
|
||||
|
||||
@run_after("init")
|
||||
def set_model(self):
|
||||
self.executable_opts = f"{self.model}.in -o {self.model}.h5".split()
|
||||
self.keep_files = [f"{self.model}.in", f"{self.model}.h5"]
|
||||
def set_filenames(self):
|
||||
input_file = f"{self.model}.in"
|
||||
output_file = f"{self.model}.h5"
|
||||
self.executable_opts = [input_file, "-o", output_file]
|
||||
self.postrun_cmds = [f"python -m toolboxes.Plotting.plot_Ascan -save {output_file}"]
|
||||
self.keep_files = [input_file, output_file, f"{self.model}.pdf"]
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户