import os
import numpy as np
from multiprocessing import Process
import math
import argparse

parser = argparse.ArgumentParser(description='Plot Errors under varying parameters')
parser.add_argument('-load', action='store', nargs='+', dest='input_files')
#parser.add_argument('-load', action='store', nargs='+', dest='load_filenames')
#parser.add_argument('-overwrite', action='store', dest='overwrite')
#parser.add_argument('-noviz', action='store_true', dest='no_visualization')
#parser.add_argument('-learn_inverse', action='store', type=int, default=0,dest='learn_inverse')
#parser.add_argument('-learn_forward', action='store', type=int, default=0,dest='learn_forward')
parser.add_argument('-n_poses', action='store', type=int, dest='n_timesteps')
parser.add_argument('-n_timesteps', action='store', type=int, dest='n_poses')
parser.add_argument('-output_directory', action='store', dest='output_directory')
#parser.add_argument("-v","--verbose", help="increase output verbosity",
#                    action="store_true", dest='verbose')
args=parser.parse_args()

#START PROCESSES


processes=[]

def process_with_overwrite(command):
    os.system(command)

for input_file in args.input_files:
    
    command="python evaluation_scripts/eval_mmc_performance_single.py -output_directory "+args.output_directory+" -n_poses "+str(args.n_poses)+" -n_timesteps "+str(args.n_timesteps)+" -load "+input_file

    p = Process(target=process_with_overwrite, args=(command,))
    p.start()
    processes.append(p)


#JOIN PROCESSES

for p in processes:
    p.join()
