Skip to content

Commit 9f11e6c

Browse files
committed
More updates to use paths.py in py scripts
1 parent 6ef3a85 commit 9f11e6c

File tree

4 files changed

+29
-31
lines changed

4 files changed

+29
-31
lines changed

run_reg_test.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
sys.path.insert(0, str(Path(__file__).resolve().parent / "vtr_flow/scripts/python_libs"))
1616
sys.path.insert(0, str(Path(__file__).resolve().parent / "vtr_flow/scripts"))
1717
from run_vtr_task import vtr_command_main as run_vtr_task
18-
from vtr import (
19-
find_vtr_file,
20-
find_vtr_root,
21-
RawDefaultHelpFormatter,
22-
)
18+
from vtr import RawDefaultHelpFormatter, paths
2319

2420
# pylint: enable=wrong-import-position, import-error
2521
BASIC_VERBOSITY = 1
@@ -196,7 +192,7 @@ def vtr_command_main(arg_list, prog=None):
196192

197193
def display_qor(reg_test):
198194
""" Display the qor tests script files to be run outside of this script """
199-
test_dir = Path(find_vtr_root()) / "vtr_flow/tasks/regression_tests" / reg_test
195+
test_dir = paths.regression_tests_path / reg_test
200196
if not (test_dir / "qor_geomean.txt").is_file():
201197
print("QoR results do not exist ({}/qor_geomean.txt)".format(str(test_dir)))
202198
return 1
@@ -242,14 +238,14 @@ def display_qor(reg_test):
242238
def run_odin_test(args, test_name):
243239
""" Run ODIN II test with given test name """
244240
odin_reg_script = [
245-
find_vtr_file("verify_odin.sh"),
241+
str(paths.odin_verify_path),
246242
"--clean",
247243
"-C",
248-
find_vtr_file("output_on_error.conf"),
244+
str(paths.odin_output_on_error_path),
249245
"--nb_of_process",
250246
str(args.j),
251247
"--test",
252-
"{}/ODIN_II/regression_test/benchmark/".format(find_vtr_root()),
248+
"{}/regression_test/benchmark/".format(str(paths.odin_path)),
253249
]
254250
if test_name == "odin_reg_full":
255251
odin_reg_script[-1] += "suite/full_suite"
@@ -285,14 +281,7 @@ def run_odin_test(args, test_name):
285281

286282
def collect_task_list(reg_test):
287283
""" create a list of task files """
288-
task_list_filepath = (
289-
Path(find_vtr_root())
290-
/ "vtr_flow"
291-
/ "tasks"
292-
/ "regression_tests"
293-
/ reg_test
294-
/ "task_list.txt"
295-
)
284+
task_list_filepath = paths.tasks_path / "regression_tests" / reg_test / "task_list.txt"
296285
if not task_list_filepath.is_file():
297286
raise IOError("Test does not exist: {}".format(reg_test))
298287
return str(task_list_filepath)

vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
InspectError,
3131
VtrError,
3232
create_jobs,
33+
paths,
3334
)
3435

3536
# pylint: enable=wrong-import-position
@@ -363,7 +364,7 @@ def check_two_files(
363364

364365
# Verify that all params and pass requirement metric are included in both the result files
365366
# We do not worry about non-pass_requriements elements being different or missing
366-
pass_req_filepath = find_vtr_file(config.pass_requirements_file)
367+
pass_req_filepath = str(paths.pass_requirements_path / config.pass_requirements_file)
367368
pass_requirements = load_pass_requirements(pass_req_filepath)
368369

369370
for metric in pass_requirements.keys():

vtr_flow/scripts/python_libs/vtr/paths.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
# VTR Paths
99
vtr_flow_path = root_path / "vtr_flow"
10-
scripts_path = vtr_flow_path / "scripts"
11-
build_path = root_path / "build"
1210

1311
# ODIN paths
1412
odin_path = root_path / "ODIN_II"
1513
odin_exe_path = odin_path / "odin_II"
1614
odin_cfg_path = vtr_flow_path / "misc" / "basic_odin_config_split.xml"
15+
odin_verify_path = odin_path / "verify_odin.sh"
16+
odin_output_on_error_path = odin_path / "regression_test" / ".library" / "output_on_error.conf"
1717

1818
# ABC paths
1919
abc_path = root_path / "abc"
@@ -29,14 +29,23 @@
2929
vpr_path = root_path / "vpr"
3030
vpr_exe_path = vpr_path / "vpr"
3131

32+
# Flow scripts
33+
scripts_path = vtr_flow_path / "scripts"
34+
run_vtr_flow_path = scripts_path / "run_vtr_flow.py"
35+
flow_template_path = scripts_path / "flow_script_template.txt"
36+
37+
# Task files
38+
tasks_path = vtr_flow_path / "tasks"
39+
regression_tests_path = tasks_path / "regression_tests"
40+
41+
# Parsing files
42+
parse_path = vtr_flow_path / "parse"
43+
vtr_benchmarks_parse_path = parse_path / "parse_config" / "common" / "vtr_benchmarks.txt"
44+
pass_requirements_path = parse_path / "pass_requirements"
45+
3246
# Other scripts
3347
blackbox_latches_script_path = scripts_path / "blackbox_latches.pl"
3448
restore_multiclock_latch_old_script_path = scripts_path / "restore_multiclock_latch_information.pl"
3549
restore_multiclock_latch_script_path = scripts_path / "restore_multiclock_latch.pl"
3650
valgrind_supp = vpr_path / "valgrind.supp"
3751
lsan_supp = vpr_path / "lsan.supp"
38-
39-
# Task files
40-
vtr_benchmarks_parse_path = (
41-
vtr_flow_path / "parse" / "parse_config" / "common" / "vtr_benchmarks.txt"
42-
)

vtr_flow/scripts/run_vtr_task.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
from vtr import (
2424
load_list_file,
25-
find_vtr_file,
26-
find_vtr_root,
2725
format_elapsed_time,
2826
RawDefaultHelpFormatter,
2927
argparse_str2bool,
@@ -40,6 +38,7 @@
4038
create_jobs,
4139
calc_geomean,
4240
summarize_qor,
41+
paths,
4342
)
4443
from vtr.error import VtrError, InspectError, CommandError
4544

@@ -359,7 +358,7 @@ def create_run_script(args, job, work_dir):
359358
human_readable_memory_est = format_human_readable_memory(memory_estimate)
360359
Path(work_dir).mkdir(parents=True)
361360
run_script_file = Path(work_dir) / "vtr_flow.sh"
362-
template = find_vtr_file("flow_script_template.txt")
361+
template = str(paths.flow_template_path)
363362
with open(template, "r") as in_file:
364363
template_string = in_file.readlines()
365364
template_string = "".join(template_string)
@@ -434,11 +433,11 @@ def run_vtr_flow_process(queue, run_dirs, job, script):
434433
with open(vtr_flow_out, "w+") as out_file:
435434
with redirect_stdout(out_file):
436435
if script == "run_vtr_flow.py":
437-
out = run_vtr_flow(job.run_command(), find_vtr_file("run_vtr_flow.py"))
436+
out = run_vtr_flow(job.run_command(), str(paths.run_vtr_flow_path))
438437
else:
439438
out = subprocess.call(
440-
[find_vtr_file(script)] + job.run_command(),
441-
cwd=find_vtr_root(),
439+
[str(paths.scripts_path / script)] + job.run_command(),
440+
cwd=str(paths.root_path),
442441
stdout=out_file,
443442
)
444443

0 commit comments

Comments
 (0)