From f97bf6cf6158313bf0cadbff4d88ba089516273a Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Thu, 20 Jun 2024 12:45:41 +0200 Subject: [PATCH] #2291: Add script for generating sample LBDatafile with lb_iter example --- scripts/check_lb_data_files.sh | 8 ++++ scripts/generate_and_validate_lb_data_file.py | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 scripts/generate_and_validate_lb_data_file.py diff --git a/scripts/check_lb_data_files.sh b/scripts/check_lb_data_files.sh index af17686c44..3f04f385bf 100755 --- a/scripts/check_lb_data_files.sh +++ b/scripts/check_lb_data_files.sh @@ -18,6 +18,10 @@ function run_schema_validator() { fi } +# Use vt to generate LB Datafile +python3 "${path_to_vt_src_dir}/scripts/generate_and_validate_lb_data_file.py" \ + -g -s "${path_to_vt_src_dir}" -b "${path_to_vt_build_dir}" -i "LBData_from_lb_iter.%p.json" + find . -iname "*.json" | grep -v "compile_commands" | while read f do run_schema_validator "$f" @@ -27,3 +31,7 @@ find . -iname "*.json.br" | while read f do run_schema_validator "$f" done + +# # Use vt to generate LB Datafile +# python3 "${path_to_vt_src_dir}/scripts/generate_and_validate_lb_data_file.py" \ +# -v -s "${path_to_vt_src_dir}" -b "${path_to_vt_build_dir}" -i "${path_to_vt_build_dir}/LBData_from_lb_iter.json" diff --git a/scripts/generate_and_validate_lb_data_file.py b/scripts/generate_and_validate_lb_data_file.py new file mode 100644 index 0000000000..7b0fa9b99a --- /dev/null +++ b/scripts/generate_and_validate_lb_data_file.py @@ -0,0 +1,42 @@ +import subprocess +import argparse + +def generate(vt_build, out_path): + """ + Runs vt lb_iter example to generate LBDatafile + """ + exe_path = vt_build + "/examples/collection/lb_iter" + out_dir = "--vt_lb_data_dir=" + vt_build + out_file = "--vt_lb_data_file=" + out_path + + args = (exe_path, "8", "1.0", "2", "--vt_lb", "--vt_lb_interval=1", "--vt_lb_name=RotateLB", "--vt_lb_data", "--vt_lb_data_compress=false", out_dir, out_file) + runner = subprocess.Popen(args, stdout=subprocess.PIPE) + runner.wait() + +def validate(file_to_validate, reference_file): + """ + Compares file to validate wih reference + """ + + +def main(): + parser = argparse.ArgumentParser() + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument("--generate", "-g", dest='generate', required=False, action='store_true') + group.add_argument("--validate", "-v", dest='validate', required=False, action='store_true') + + parser.add_argument("--vt-source-dir", "-s", dest='vt_source_dir', required=True) + parser.add_argument("--vt-build-dir", "-b", dest='vt_build_dir', required=True) + + parser.add_argument("--inout-file", "-i", dest='inout_file', required=True) + parser.add_argument("--reference-file", "-r", dest='reference_file', required=False) + args = parser.parse_args() + + if args.generate: + generate(args.vt_build_dir, args.inout_file) + if args.validate: + validate(args.inout_file, args.reference_file) + + +if __name__ == '__main__': + main()