Handled error runs where log.lammps is not created (e.g. using more MPI procs than the number of physical CPUs)
This commit is contained in:
@ -199,12 +199,7 @@ def execute(lmp_binary, config, input_file_name, generate_ref_yaml=False):
|
|||||||
print(f"Executing: {cmd_str}")
|
print(f"Executing: {cmd_str}")
|
||||||
p = subprocess.run(cmd_str, shell=True, text=True, capture_output=True)
|
p = subprocess.run(cmd_str, shell=True, text=True, capture_output=True)
|
||||||
|
|
||||||
#output = p.stdout.split('\n')
|
return cmd_str, p.stdout, p.stderr, p.returncode
|
||||||
output = p.stdout
|
|
||||||
# process output to handle failed runs
|
|
||||||
|
|
||||||
return cmd_str, output
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
attempt to plug in the REG markers before each run command
|
attempt to plug in the REG markers before each run command
|
||||||
@ -333,12 +328,17 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False)
|
|||||||
# lmp.file(input_test)
|
# lmp.file(input_test)
|
||||||
|
|
||||||
# or more customizable with config.yaml
|
# or more customizable with config.yaml
|
||||||
cmd_str, output = execute(lmp_binary, config, input_test)
|
cmd_str, output, error, returncode = execute(lmp_binary, config, input_test)
|
||||||
|
|
||||||
# restore the nprocs value in the configuration
|
# restore the nprocs value in the configuration
|
||||||
config['nprocs'] = saved_nprocs
|
config['nprocs'] = saved_nprocs
|
||||||
|
|
||||||
# process thermo output
|
# process thermo output
|
||||||
|
if returncode != 0:
|
||||||
|
print(f"ERROR: Failed with {input_test}. Check the log file for the run output.\n")
|
||||||
|
logger.info(f"\n{error}")
|
||||||
|
continue
|
||||||
|
|
||||||
thermo = extract_data_to_yaml("log.lammps")
|
thermo = extract_data_to_yaml("log.lammps")
|
||||||
|
|
||||||
num_runs = len(thermo)
|
num_runs = len(thermo)
|
||||||
@ -469,9 +469,6 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False)
|
|||||||
'''
|
'''
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
logging.basicConfig(filename='run.log', level=logging.INFO)
|
|
||||||
|
|
||||||
# default values
|
# default values
|
||||||
lmp_binary = ""
|
lmp_binary = ""
|
||||||
configFileName = "config.yaml"
|
configFileName = "config.yaml"
|
||||||
@ -479,18 +476,20 @@ if __name__ == "__main__":
|
|||||||
genref = False
|
genref = False
|
||||||
verbose = False
|
verbose = False
|
||||||
output_file = "output.xml"
|
output_file = "output.xml"
|
||||||
|
log_file = "run.log"
|
||||||
|
|
||||||
# parse the arguments
|
# parse the arguments
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument("--lmp-bin", dest="lmp_binary", default="", help="LAMMPS binary")
|
parser.add_argument("--lmp-bin", dest="lmp_binary", default="", help="LAMMPS binary")
|
||||||
parser.add_argument("--config-file", dest="config_file", default="config.yaml",
|
parser.add_argument("--config-file", dest="config_file", default=configFileName,
|
||||||
help="Configuration YAML file")
|
help="Configuration YAML file")
|
||||||
parser.add_argument("--example-folders", dest="example_folders", default="", help="Example subfolders")
|
parser.add_argument("--example-folders", dest="example_folders", default="", help="Example subfolders")
|
||||||
parser.add_argument("--gen-ref",dest="genref", action='store_true', default=False,
|
parser.add_argument("--gen-ref",dest="genref", action='store_true', default=False,
|
||||||
help="Generating reference data")
|
help="Generating reference data")
|
||||||
parser.add_argument("--verbose",dest="verbose", action='store_true', default=False,
|
parser.add_argument("--verbose",dest="verbose", action='store_true', default=False,
|
||||||
help="Verbose output")
|
help="Verbose output")
|
||||||
parser.add_argument("--output",dest="output", default="output.xml", help="Output file")
|
parser.add_argument("--output",dest="output", default=output_file, help="Output file")
|
||||||
|
parser.add_argument("--logfile",dest="logfile", default=log_file, help="Log file")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -503,6 +502,11 @@ if __name__ == "__main__":
|
|||||||
print(example_subfolders)
|
print(example_subfolders)
|
||||||
genref = args.genref
|
genref = args.genref
|
||||||
verbose = args.verbose
|
verbose = args.verbose
|
||||||
|
log_file = args.logfile
|
||||||
|
|
||||||
|
# logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logging.basicConfig(filename=log_file, level=logging.INFO, filemode="w")
|
||||||
|
|
||||||
# read in the configuration of the tests
|
# read in the configuration of the tests
|
||||||
with open(configFileName, 'r') as f:
|
with open(configFileName, 'r') as f:
|
||||||
@ -530,7 +534,7 @@ if __name__ == "__main__":
|
|||||||
inplace_input = True
|
inplace_input = True
|
||||||
test_cases = []
|
test_cases = []
|
||||||
|
|
||||||
# if the example folders are not specified from the command-line argument -example-folders
|
# if the example folders are not specified from the command-line argument --example-folders
|
||||||
if len(example_subfolders) == 0:
|
if len(example_subfolders) == 0:
|
||||||
example_subfolders.append("../../examples/melt")
|
example_subfolders.append("../../examples/melt")
|
||||||
example_subfolders.append('../../examples/flow')
|
example_subfolders.append('../../examples/flow')
|
||||||
@ -595,6 +599,9 @@ if __name__ == "__main__":
|
|||||||
if 'RIGID' in packages:
|
if 'RIGID' in packages:
|
||||||
example_subfolders.append('../../examples/rigid')
|
example_subfolders.append('../../examples/rigid')
|
||||||
|
|
||||||
|
if 'SNAP' in packages:
|
||||||
|
example_subfolders.append('../../examples/snap')
|
||||||
|
|
||||||
if 'SRD' in packages:
|
if 'SRD' in packages:
|
||||||
example_subfolders.append('../../examples/srd')
|
example_subfolders.append('../../examples/srd')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user