Skip to content

Commit b156515

Browse files
committed
[script] apply comments
1 parent 31a315e commit b156515

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

vtr_flow/scripts/python_libs/vtr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
verify_file,
2121
pretty_print_table,
2222
find_task_dir,
23-
set_global_run_dir,
23+
RunDir,
2424
)
2525
from .log_parse import (
2626
determine_lut_size,

vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
VtrError,
3333
create_jobs,
3434
paths,
35-
set_global_run_dir,
35+
RunDir,
3636
)
3737

3838
# pylint: enable=wrong-import-position
@@ -151,7 +151,7 @@ def vtr_command_main(arg_list, prog=None):
151151
# Load the arguments
152152
args = vtr_command_argparser(prog).parse_args(arg_list)
153153
if args.run is not None:
154-
set_global_run_dir(args.run)
154+
RunDir.set_user_run_dir_name(args.run)
155155
try:
156156
task_names = args.task
157157

vtr_flow/scripts/python_libs/vtr/util.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class RunDir:
3333
g_run_dir_name = None
3434

3535
@classmethod
36-
def set_run_dir_name(cls, current_run_dir_name):
36+
def set_user_run_dir_name(cls, current_run_dir_name):
3737
"""
3838
Set the run directory name passed by the user.
3939
"""
4040
cls.g_run_dir_name = current_run_dir_name
4141

4242
@classmethod
43-
def get_run_dir_name(cls):
43+
def get_user_run_dir_name(cls):
4444
"""
4545
Get the run directory name passed by the user.
4646
"""
@@ -250,13 +250,6 @@ def run_system_command(
250250
# pylint: enable=too-many-arguments, too-many-instance-attributes, too-few-public-methods, too-many-locals
251251

252252

253-
def set_global_run_dir(current_run_dir_name):
254-
"""
255-
Set the global run directory name.
256-
"""
257-
RunDir.set_run_dir_name(current_run_dir_name)
258-
259-
260253
def check_cmd(command):
261254
"""
262255
Return True if command can be run, False otherwise.
@@ -557,7 +550,7 @@ def get_latest_run_dir(base_dir):
557550
"""
558551
Returns the run directory with the highest run number in base_dir
559552
"""
560-
latest_run_dir_name = get_latest_run_dir_name(base_dir)
553+
latest_run_dir_name = get_active_run_dir_name(base_dir)
561554

562555
run_dir = None
563556
if latest_run_dir_name:
@@ -582,7 +575,7 @@ def get_next_run_number(base_dir):
582575
"""
583576
Returns the next available (i.e. non-existing) run number in base_dir
584577
"""
585-
latest_run_dir_name = get_latest_run_dir_name(base_dir)
578+
latest_run_dir_name = get_active_run_dir_name(base_dir)
586579
match = re.match(r"^run(\d{3})$", latest_run_dir_name)
587580
next_run_number = 1
588581
if match:
@@ -592,13 +585,16 @@ def get_next_run_number(base_dir):
592585
return next_run_number
593586

594587

595-
def get_latest_run_dir_name(base_dir):
588+
def get_active_run_dir_name(base_dir):
596589
"""
597-
Returns the highest run number of all run directories with in base_dir
590+
Returns the active run directory name. If the user has specified
591+
a run directory name, it will be returned. Otherwise, the
592+
highest run number of all run directories within in base_dir
593+
will be returned.
598594
"""
599-
latest_run_dir_name = ""
600-
if RunDir.get_run_dir_name() is not None:
601-
latest_run_dir_name = RunDir.get_run_dir_name()
595+
active_run_dir_name = ""
596+
if RunDir.get_user_run_dir_name() is not None:
597+
active_run_dir_name = RunDir.get_user_run_dir_name()
602598
else:
603599
run_number = 1
604600
run_dir = Path(base_dir) / run_dir_name(run_number)
@@ -610,9 +606,9 @@ def get_latest_run_dir_name(base_dir):
610606

611607
# Currently one-past the last existing run dir,
612608
# to get latest existing, subtract one
613-
latest_run_dir_name = run_dir_name(run_number - 1)
609+
active_run_dir_name = run_dir_name(run_number - 1)
614610

615-
return latest_run_dir_name
611+
return active_run_dir_name
616612

617613

618614
def run_dir_name(run_num):

0 commit comments

Comments
 (0)