From 2990eb7406629c488b9c43bc1153f82c06e82c8e Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 14 Feb 2022 22:54:16 -0800 Subject: [PATCH] [Script] Fixed a bug in task run when removing previous runs --- openfpga_flow/scripts/run_fpga_task.py | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/openfpga_flow/scripts/run_fpga_task.py b/openfpga_flow/scripts/run_fpga_task.py index 3c16ee56f..a75114b17 100644 --- a/openfpga_flow/scripts/run_fpga_task.py +++ b/openfpga_flow/scripts/run_fpga_task.py @@ -190,22 +190,23 @@ def generate_each_task_actions(taskname): clean_up_and_exit( "Missing configuration file for task %s" % curr_task_dir) - # Create run directory for current task run ./runxxx - run_dirs = [int(os.path.basename(x)[-3:]) for x in glob.glob('run*[0-9]')] - curr_run_dir = "run%03d" % (max(run_dirs+[0, ])+1) if args.remove_run_dir: remove_run_dir() - try: - os.mkdir(curr_run_dir) - if os.path.islink('latest') or os.path.exists('latest'): - os.remove("latest") - os.symlink(curr_run_dir, "latest") - logger.info('Created "%s" directory for current task run' % - curr_run_dir) - except: - logger.exception("") - logger.error("Failed to create new run directory in task directory") - os.chdir(curr_run_dir) + else: + # Create run directory for current task run ./runxxx + run_dirs = [int(os.path.basename(x)[-3:]) for x in glob.glob('run*[0-9]')] + curr_run_dir = "run%03d" % (max(run_dirs+[0, ])+1) + try: + os.mkdir(curr_run_dir) + if os.path.islink('latest') or os.path.exists('latest'): + os.remove("latest") + os.symlink(curr_run_dir, "latest") + logger.info('Created "%s" directory for current task run' % + curr_run_dir) + except: + logger.exception("") + logger.error("Failed to create new run directory in task directory") + os.chdir(curr_run_dir) # Read task configuration file and check consistency task_conf = ConfigParser(allow_no_value=True,