Added progress to track the tests processed
This commit is contained in:
@ -305,7 +305,7 @@ def has_markers(inputFileName):
|
|||||||
results = pool.starmap(func, args)
|
results = pool.starmap(func, args)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False, output=None):
|
def iterate(lmp_binary, input_list, config, results, working_dir, removeAnnotatedInput=False, output=None):
|
||||||
EPSILON = np.float64(config['epsilon'])
|
EPSILON = np.float64(config['epsilon'])
|
||||||
nugget = float(config['nugget'])
|
nugget = float(config['nugget'])
|
||||||
|
|
||||||
@ -316,13 +316,23 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False,
|
|||||||
# using REG-commented input scripts, now turned off (False)
|
# using REG-commented input scripts, now turned off (False)
|
||||||
using_markers = False
|
using_markers = False
|
||||||
|
|
||||||
|
progress_file = working_dir + "/progress.txt"
|
||||||
|
progress = None
|
||||||
|
|
||||||
# iterate over the input scripts
|
# iterate over the input scripts
|
||||||
for input in input_list:
|
for input in input_list:
|
||||||
|
|
||||||
|
if os.path.isfile(progress_file) == True:
|
||||||
|
progress = open(progress_file, "a")
|
||||||
|
else:
|
||||||
|
progress = open(progress_file, "w")
|
||||||
|
|
||||||
# skip the input file if listed
|
# skip the input file if listed
|
||||||
if 'skip' in config:
|
if 'skip' in config:
|
||||||
if input in config['skip']:
|
if input in config['skip']:
|
||||||
logger.info(f"SKIPPED: {input} as specified in the configuration file {configFileName}")
|
logger.info(f"SKIPPED: {input} as specified in the configuration file {configFileName}")
|
||||||
|
progress.write(f"{input}: skipped\n")
|
||||||
|
progress.close()
|
||||||
test_id = test_id + 1
|
test_id = test_id + 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -401,6 +411,8 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False,
|
|||||||
logger.info(f"SKIPPED: {thermo_ref_file} does not exist in the working directory.")
|
logger.info(f"SKIPPED: {thermo_ref_file} does not exist in the working directory.")
|
||||||
result.status = "skipped due to missing the log file"
|
result.status = "skipped due to missing the log file"
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
progress.write(f"{input}: skipped\n")
|
||||||
|
progress.close()
|
||||||
test_id = test_id + 1
|
test_id = test_id + 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -415,6 +427,8 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False,
|
|||||||
logger.info(f"ERROR: No log.lammps generated with {input_test} with return code {returncode}. Check the {log_file} for the run output.\n")
|
logger.info(f"ERROR: No log.lammps generated with {input_test} with return code {returncode}. Check the {log_file} for the run output.\n")
|
||||||
logger.info(f"\n{input_test}:")
|
logger.info(f"\n{input_test}:")
|
||||||
logger.info(f"\n{error}")
|
logger.info(f"\n{error}")
|
||||||
|
progress.write(f"{input}: error\n")
|
||||||
|
progress.close()
|
||||||
test_id = test_id + 1
|
test_id = test_id + 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -431,6 +445,8 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False,
|
|||||||
result.status = "error"
|
result.status = "error"
|
||||||
logger.info(f"ERROR: Failed with {input_test} due to {result.status}.\n")
|
logger.info(f"ERROR: Failed with {input_test} due to {result.status}.\n")
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
progress.write(f"{input}: error\n")
|
||||||
|
progress.close()
|
||||||
test_id = test_id + 1
|
test_id = test_id + 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -439,6 +455,8 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False,
|
|||||||
logger.info(f"ERROR: Number of runs in log.lammps ({num_runs}) is not the same as that in the reference log ({num_runs_ref})")
|
logger.info(f"ERROR: Number of runs in log.lammps ({num_runs}) is not the same as that in the reference log ({num_runs_ref})")
|
||||||
result.status = "error"
|
result.status = "error"
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
progress.write(f"{input}: error\n")
|
||||||
|
progress.close()
|
||||||
test_id = test_id + 1
|
test_id = test_id + 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -537,7 +555,10 @@ def iterate(lmp_binary, input_list, config, results, removeAnnotatedInput=False,
|
|||||||
|
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
|
||||||
str_t = f"Finished " + input_test
|
progress.write(f"{input}: completed\n")
|
||||||
|
progress.close()
|
||||||
|
|
||||||
|
str_t = f"Completed " + input_test
|
||||||
print(str_t)
|
print(str_t)
|
||||||
print("-"*(5*width+4))
|
print("-"*(5*width+4))
|
||||||
test_id = test_id + 1
|
test_id = test_id + 1
|
||||||
@ -682,14 +703,15 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
all_results = []
|
all_results = []
|
||||||
|
|
||||||
# default setting is to use inplace_input
|
|
||||||
if inplace_input == True:
|
|
||||||
# save current working dir
|
# save current working dir
|
||||||
p = subprocess.run("pwd", shell=True, text=True, capture_output=True)
|
p = subprocess.run("pwd", shell=True, text=True, capture_output=True)
|
||||||
pwd = p.stdout.split('\n')[0]
|
pwd = p.stdout.split('\n')[0]
|
||||||
pwd = os.path.abspath(pwd)
|
pwd = os.path.abspath(pwd)
|
||||||
print("\nWorking directory: " + pwd)
|
print("\nWorking directory: " + pwd)
|
||||||
|
|
||||||
|
# default setting is to use inplace_input
|
||||||
|
if inplace_input == True:
|
||||||
|
|
||||||
# change dir to a folder under examples/, need to use os.chdir()
|
# change dir to a folder under examples/, need to use os.chdir()
|
||||||
# TODO: loop through the subfolders under examples/, depending on the installed packages
|
# TODO: loop through the subfolders under examples/, depending on the installed packages
|
||||||
|
|
||||||
@ -706,7 +728,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for directory in example_subfolders:
|
for directory in example_subfolders:
|
||||||
|
|
||||||
p = subprocess.run("pwd", shell=True, text=True, capture_output=True)
|
# change to the directory where the input script and data files are located
|
||||||
print("\nEntering " + directory)
|
print("\nEntering " + directory)
|
||||||
os.chdir(directory)
|
os.chdir(directory)
|
||||||
|
|
||||||
@ -720,7 +742,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# iterate through the input scripts
|
# iterate through the input scripts
|
||||||
results = []
|
results = []
|
||||||
num_passed = iterate(lmp_binary, input_list, config, results)
|
num_passed = iterate(lmp_binary, input_list, config, results, pwd)
|
||||||
passed_tests += num_passed
|
passed_tests += num_passed
|
||||||
|
|
||||||
# append the results to the all_results list
|
# append the results to the all_results list
|
||||||
@ -734,7 +756,7 @@ if __name__ == "__main__":
|
|||||||
input_list=['in.lj']
|
input_list=['in.lj']
|
||||||
total_tests = len(input_list)
|
total_tests = len(input_list)
|
||||||
results = []
|
results = []
|
||||||
passed_tests = iterate(lmp_binary, input_list, config, results)
|
passed_tests = iterate(lmp_binary, input_list, config, results, pwd)
|
||||||
|
|
||||||
all_results.extend(results)
|
all_results.extend(results)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user