Skip to content

[VTR Script] Add Run Number to Parse Script #2954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vtr_flow/scripts/python_libs/vtr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
verify_file,
pretty_print_table,
find_task_dir,
set_global_run_dir_number
)
from .log_parse import (
determine_lut_size,
Expand Down
5 changes: 4 additions & 1 deletion vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
VtrError,
create_jobs,
paths,
set_global_run_dir_number,
)

# pylint: enable=wrong-import-position
Expand Down Expand Up @@ -130,7 +131,7 @@ def vtr_command_argparser(prog=None):
help="QoR geomeans are not computed by default",
)

parser.add_argument("-run", default=None, type=str, help="")
parser.add_argument("-run", default=None, type=int, help="Run number to parse. If not provided, the latest run will be parsed.")

parser.add_argument("-revision", default="", help="Revision number")

Expand All @@ -144,6 +145,8 @@ def vtr_command_main(arg_list, prog=None):
"""
# Load the arguments
args = vtr_command_argparser(prog).parse_args(arg_list)
if args.run is not None:
set_global_run_dir_number(args.run)
try:
task_names = args.task

Expand Down
39 changes: 28 additions & 11 deletions vtr_flow/scripts/python_libs/vtr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
from vtr import paths


# The run number passed by get_latest_run_number is the latest run number for the task if this number is None. Otherwise
# it is the run number to parse.
global_run_dir_number = None

class RawDefaultHelpFormatter(
argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
):
Expand Down Expand Up @@ -224,6 +228,13 @@ def run_system_command(

# pylint: enable=too-many-arguments, too-many-instance-attributes, too-few-public-methods, too-many-locals

def set_global_run_dir_number(run_dir_number):
"""
Set the global run directory number.
"""
global global_run_dir_number
global_run_dir_number = run_dir_number


def check_cmd(command):
"""
Expand Down Expand Up @@ -563,20 +574,26 @@ def get_latest_run_number(base_dir):
"""
Returns the highest run number of all run directories with in base_dir
"""
run_number = 1
run_dir = Path(base_dir) / run_dir_name(run_number)
global global_run_dir_number
run_number = None
if global_run_dir_number is None:
run_number = 1
run_dir = Path(base_dir) / run_dir_name(run_number)

if not run_dir.exists():
# No existing run directories
return None
if not run_dir.exists():
# No existing run directories
return None

while run_dir.exists():
run_number += 1
run_dir = Path(base_dir) / run_dir_name(run_number)
while run_dir.exists():
run_number += 1
run_dir = Path(base_dir) / run_dir_name(run_number)

# Currently one-past the last existing run dir,
# to get latest existing, subtract one
return run_number - 1
# Currently one-past the last existing run dir,
# to get latest existing, subtract one
run_number = run_number - 1
else:
run_number = global_run_dir_number
return run_number


def run_dir_name(run_num):
Expand Down
Loading