Added argument parsers
This commit is contained in:
@ -3,7 +3,7 @@ UPDATE: Oct 25, 2023:
|
|||||||
Launching the LAMMPS binary under testing using a configuration defined in a yaml file (e.g. config.yaml)
|
Launching the LAMMPS binary under testing using a configuration defined in a yaml file (e.g. config.yaml)
|
||||||
this way we can launch LAMMPS with mpirun with more flexibility. Also it simplifies the build configuration.
|
this way we can launch LAMMPS with mpirun with more flexibility. Also it simplifies the build configuration.
|
||||||
|
|
||||||
python3 run_tests.py /path/to/lmp_binary
|
python3 run_tests.py --lmp-bin=/path/to/lmp_binary --config-file=config.yaml --gen-ref=False
|
||||||
|
|
||||||
Original plan: using the LAMMPS Python module
|
Original plan: using the LAMMPS Python module
|
||||||
The following steps are for setting up regression tests with the LAMMPS Python module
|
The following steps are for setting up regression tests with the LAMMPS Python module
|
||||||
@ -37,6 +37,9 @@ import sys
|
|||||||
import re, yaml
|
import re, yaml
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import optparse, sys
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from yaml import CSafeLoader as Loader
|
from yaml import CSafeLoader as Loader
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -184,15 +187,30 @@ def iterate(input_list):
|
|||||||
'''
|
'''
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
# default values
|
||||||
lmp_binary = ""
|
lmp_binary = ""
|
||||||
# if lmp binary is specified in the command line
|
configFileName = "config.yaml"
|
||||||
if len(sys.argv) >= 2:
|
genref = False
|
||||||
lmp_binary = sys.argv[1]
|
|
||||||
|
# parse the arguments
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("--lmp-bin", dest="lmp_binary", type = "string", default="",
|
||||||
|
help="LAMMPS binary")
|
||||||
|
parser.add_option("--config-file", dest="config_file", type = "string", default="config.yaml",
|
||||||
|
help="Configuration YAML file")
|
||||||
|
parser.add_option("--gen-ref",dest="genref", default=False,
|
||||||
|
help="Generating reference data")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
lmp_binary = options.lmp_binary
|
||||||
|
config_file= options.config_file
|
||||||
|
genref = options.genref
|
||||||
|
|
||||||
# read in the configuration of the tests
|
# read in the configuration of the tests
|
||||||
with open("config.yaml", 'r') as f:
|
with open(configFileName, 'r') as f:
|
||||||
config = yaml.load(f, Loader=Loader)
|
config = yaml.load(f, Loader=Loader)
|
||||||
print(f"Using configuration (config.yaml): {config}")
|
print(f"Using configuration {configFileName}: {config}")
|
||||||
|
|
||||||
# check if lmp_binary is specified in the config yaml
|
# check if lmp_binary is specified in the config yaml
|
||||||
if lmp_binary == "":
|
if lmp_binary == "":
|
||||||
|
|||||||
Reference in New Issue
Block a user