Skip to content

Commit

Permalink
#2291: Add script for generating sample LBDatafile with lb_iter example
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Jun 27, 2024
1 parent 3638817 commit f97bf6c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/check_lb_data_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
42 changes: 42 additions & 0 deletions scripts/generate_and_validate_lb_data_file.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit f97bf6c

Please sign in to comment.