Skip to content

Commit 60f5132

Browse files
committed
hotfix: make args global so it can be accessed by body functions
Signed-off-by: Jack Luar <[email protected]>
1 parent 1a629f5 commit 60f5132

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
)
7272
# URL to ORFS GitHub repository
7373
ORFS_URL = "https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts"
74+
# Global variable for args
75+
args = None
7476

7577

7678
class AutoTunerBase(tune.Trainable):
@@ -433,36 +435,36 @@ def parse_arguments():
433435
" training stderr\n\t2: also print training stdout.",
434436
)
435437

436-
arguments = parser.parse_args()
437-
if arguments.mode == "tune":
438-
arguments.algorithm = arguments.algorithm.lower()
438+
args = parser.parse_args()
439+
if args.mode == "tune":
440+
args.algorithm = args.algorithm.lower()
439441
# Validation of arguments
440-
if arguments.eval == "ppa-improv" and arguments.reference is None:
442+
if args.eval == "ppa-improv" and args.reference is None:
441443
print(
442444
'[ERROR TUN-0006] The argument "--eval ppa-improv"'
443445
' requires that "--reference <FILE>" is also given.'
444446
)
445447
sys.exit(7)
446448

447449
# Check for experiment name and resume flag.
448-
if arguments.resume and arguments.experiment == "test":
450+
if args.resume and args.experiment == "test":
449451
print(
450452
'[ERROR TUN-0031] The flag "--resume"'
451453
' requires that "--experiment NAME" is also given.'
452454
)
453455
sys.exit(1)
454456

455457
# If the experiment name is the default, add a UUID to the end.
456-
if arguments.experiment == "test":
458+
if args.experiment == "test":
457459
id = str(uuid())[:8]
458-
arguments.experiment = f"{arguments.mode}-{id}"
460+
args.experiment = f"{args.mode}-{id}"
459461
else:
460-
arguments.experiment += f"-{arguments.mode}"
462+
args.experiment += f"-{args.mode}"
461463

462-
if arguments.timeout is not None:
463-
arguments.timeout = round(arguments.timeout * 3600)
464+
if args.timeout is not None:
465+
args.timeout = round(args.timeout * 3600)
464466

465-
return arguments
467+
return args
466468

467469

468470
def set_algorithm(experiment_name, config):

0 commit comments

Comments
 (0)