Added remove run directory option
This commit is contained in:
parent
cd5fd6ce6c
commit
50039a4b6e
|
@ -48,6 +48,11 @@ parser.add_argument('tasks', nargs='+')
|
||||||
parser.add_argument('--maxthreads', type=int, default=2,
|
parser.add_argument('--maxthreads', type=int, default=2,
|
||||||
help="Number of fpga_flow threads to run default = 2," +
|
help="Number of fpga_flow threads to run default = 2," +
|
||||||
"Typically <= Number of processors on the system")
|
"Typically <= Number of processors on the system")
|
||||||
|
parser.add_argument('--remove_run_dir', type=str,
|
||||||
|
help="Remove run dir " +
|
||||||
|
"'all' to remove all." +
|
||||||
|
"<int>,<int> to remove specific run dir" +
|
||||||
|
"<int>-<int> To remove range of directory")
|
||||||
parser.add_argument('--config', help="Override default configuration")
|
parser.add_argument('--config', help="Override default configuration")
|
||||||
parser.add_argument('--test_run', action="store_true",
|
parser.add_argument('--test_run', action="store_true",
|
||||||
help="Dummy run shows final generated VPR commands")
|
help="Dummy run shows final generated VPR commands")
|
||||||
|
@ -84,6 +89,8 @@ def main():
|
||||||
logger.info("Currently running task %s" % eachtask)
|
logger.info("Currently running task %s" % eachtask)
|
||||||
eachtask = eachtask.replace("\\", "/").split("/")
|
eachtask = eachtask.replace("\\", "/").split("/")
|
||||||
job_run_list = generate_each_task_actions(eachtask)
|
job_run_list = generate_each_task_actions(eachtask)
|
||||||
|
if args.remove_run_dir:
|
||||||
|
continue
|
||||||
eachtask = "_".join(eachtask)
|
eachtask = "_".join(eachtask)
|
||||||
if not args.test_run:
|
if not args.test_run:
|
||||||
run_actions(job_run_list)
|
run_actions(job_run_list)
|
||||||
|
@ -111,6 +118,40 @@ def validate_command_line_arguments():
|
||||||
logger.info("Set up to run %d Parallel threads", args.maxthreads)
|
logger.info("Set up to run %d Parallel threads", args.maxthreads)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_run_dir():
|
||||||
|
remove_dir = []
|
||||||
|
try:
|
||||||
|
argval = args.remove_run_dir.lower()
|
||||||
|
if argval == "all":
|
||||||
|
for eachRun in glob.glob("run*"):
|
||||||
|
remove_dir += [eachRun]
|
||||||
|
elif "-" in argval:
|
||||||
|
minval, maxval = map(int, argval.split("-"))
|
||||||
|
if minval > maxval:
|
||||||
|
raise Exception("Enter valid range to remove")
|
||||||
|
for eachRun in glob.glob("run*"):
|
||||||
|
if minval <= int(eachRun[-3:]) <= maxval:
|
||||||
|
remove_dir += [eachRun]
|
||||||
|
elif "," in argval:
|
||||||
|
for eachRun in argval.split(","):
|
||||||
|
remove_dir += ["run%03d" % int(eachRun)]
|
||||||
|
else:
|
||||||
|
logger.error("Unknow argument to --remove_run_dir")
|
||||||
|
except:
|
||||||
|
logger.exception("Failed to parse remove rund_dir options")
|
||||||
|
|
||||||
|
try:
|
||||||
|
for eachdir in remove_dir:
|
||||||
|
logger.info('Removing run_dir %s' % (eachdir))
|
||||||
|
if os.path.exists('latest'):
|
||||||
|
if eachdir == os.readlink('latest'):
|
||||||
|
remove_dir += ["latest"]
|
||||||
|
shutil.rmtree(eachdir, ignore_errors=True)
|
||||||
|
except:
|
||||||
|
logger.exception("Failed to remove %s run directory" %
|
||||||
|
(eachdir or "Unknown"))
|
||||||
|
|
||||||
|
|
||||||
def generate_each_task_actions(taskname):
|
def generate_each_task_actions(taskname):
|
||||||
"""
|
"""
|
||||||
This script generates all the scripts required for each benchmark
|
This script generates all the scripts required for each benchmark
|
||||||
|
@ -130,6 +171,9 @@ def generate_each_task_actions(taskname):
|
||||||
# Create run directory for current task run ./runxxx
|
# Create run directory for current task run ./runxxx
|
||||||
run_dirs = [int(os.path.basename(x)[-3:]) for x in glob.glob('run*[0-9]')]
|
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)
|
curr_run_dir = "run%03d" % (max(run_dirs+[0, ])+1)
|
||||||
|
if args.remove_run_dir:
|
||||||
|
remove_run_dir()
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
os.mkdir(curr_run_dir)
|
os.mkdir(curr_run_dir)
|
||||||
if os.path.islink('latest') or os.path.exists('latest'):
|
if os.path.islink('latest') or os.path.exists('latest'):
|
||||||
|
|
Loading…
Reference in New Issue