Skip to content

Commit

Permalink
test from remote storage
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Oct 15, 2024
1 parent 2f33d72 commit 2f62f1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
5 changes: 1 addition & 4 deletions tests/simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ if(HighFive)

# doesn't make sense in serial
phare_mpi_python3_exec(9 3 load_balancing test_load_balancing.py ${CMAKE_CURRENT_BINARY_DIR})
phare_mpi_python3_exec(9 3 initing test_init_from_restart.py ${CMAKE_CURRENT_BINARY_DIR})

endif(testMPI)

phare_python3_exec(11, test_diagnostic_timestamps test_diagnostic_timestamps.py ${CMAKE_CURRENT_BINARY_DIR})

if(NOT lowResourceTests)
# has to be serial, to run secondary mpirun internally
add_no_mpi_python3_test(initing test_init_from_restart.py ${CMAKE_CURRENT_BINARY_DIR})
endif()

endif()

Expand Down
32 changes: 5 additions & 27 deletions tests/simulator/test_init_from_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess
import numpy as np
import pyphare.pharein as ph

from pathlib import Path

from pyphare.simulator.simulator import Simulator
from pyphare.pharesee.hierarchy.patchdata import FieldData, ParticleData
Expand All @@ -19,10 +19,10 @@
time_step = 0.001
time_step_nbr = 5
final_time = time_step_nbr * time_step
first_mpi_size = 4
first_mpi_size = 5
ppc = 100
cells = 200
first_out = "phare_outputs/reinit/first"
first_out = "test_init_from_restart"
secnd_out = "phare_outputs/reinit/secnd"
timestamps = np.arange(0, final_time + time_step, time_step)
restart_idx = Z = 2
Expand Down Expand Up @@ -77,30 +77,8 @@ def test_reinit(self):
self.assertTrue(hierarchy_compare(*ds, atol=1e-12))


def run_first_sim():
"""uses params from tests_restarts.py"""
simput = copy.deepcopy(test_restarts.simArgs)
simput["restart_options"]["dir"] = first_out
simput["restart_options"]["timestamps"] = timestamps
simput["diag_options"]["options"]["dir"] = first_out
sim = ph.Simulation(**simput)
dump_all_diags(test_restarts.setup_model().populations, timestamps=timestamps)
Simulator(sim).run()


def launch():
"""Launch secondary process to run first simulation to avoid initalizing MPI now"""

cmd = f"mpirun -n {first_mpi_size} python3 -O {__file__} lol"
try:
p = subprocess.run(cmd.split(" "), check=True, capture_output=True)
except subprocess.CalledProcessError as e:
print("CalledProcessError", e)


if __name__ == "__main__":
if len(sys.argv) == 1:
launch()
if Path("test_init_from_restart").exists():
unittest.main()
else:
run_first_sim()
print("No source data found - see tools/test_data_gen.py ")

0 comments on commit 2f62f1d

Please sign in to comment.