def evaluate(self, params, ii, jj): print(params) new_outpath = self.ouputdir + "/bbo_out_" + str(ii) + "_" + str(jj) if os.path.exists(self.ouputdir) != True: os.makedirs(self.ouputdir) if os.path.exists(new_outpath) != True: os.makedirs(new_outpath) command = "cd " + self.algpath[ 0:-8] + ";PYTHONPATH=./ python " + self.algpath[ -8:] + " --lr " + str( params["lr"]) + " --outputdir " + str(new_outpath) print(new_outpath, command) #os.system(command) info = API_tools.creat_mission(str("bbo_" + str(ii) + "_" + str(jj)), command, "qwer", "wudch", "woodchen") return 1
def post(self,request): # AutoML 新建任务 # res 字典数据格式详见 @/Frontend/src/pages/AutoML/CreateMission/data.d.ts # export interface Former { # //Base set # type:string; # name:string; # description?:string; # //Dataset set # dataName?:string; //新建数据集的名称 # dataOutput?:string; //新建数据集的输出路径 # dataInput?:string; //新建数据集的输入路径 # dataSelection?:string; // 已有数据集的id # //Model set # modelsize:number; # } # @指项目文件夹路径 user = auth.get_user(request) form_dict=request.data # 创建任务 #{'type': 'Image_Classification', 'name': 'dsad', 'modelsize': 12321, 'dataSelection': 3} FRONT_DEBUG=True if(not FRONT_DEBUG): datasetname = None algtype = form_dict["type"] jobname = form_dict['name'] maxflops = int(form_dict['modelsize']) datasetid = form_dict['dataSelection'] if form_dict['dataSelection'] != None: datasetname = models.Dataset.objects.filter(id = int(datasetid))[0] # print(datasetname.name) if algtype == 'Image_Classification': algdict = ["efficientnet_b3a","mobilenetv2_120d","efficientnet_lite0","mobilenetv2_100","mobilenetv3_large_100"] if maxflops > 900: algname = 'efficientnet_b3a' elif maxflops > 600: algname = 'mobilenetv2_120d' elif maxflops > 400: algname = 'efficientnet_lite0' elif maxflops > 300: algname = 'mobilenetv2_100' else: algname = 'mobilenetv3_large_100' #-------挂载CP算法操作---------- #back_untils.alg_cp(r'./../../algorithm/classification/pytorch_automodel/image_classification',"") #----------------------------- #command = "cd ../userhome/fakejobspace/algorithm/classification/pytorch_automodel/image_classification/;" command = "cd ../userhome;mkdir jobspace;cd jobspace;rm -r algorithm;mkdir algorithm;cd algorithm;" \ "git clone https://github.com/MAC-AutoML/PCL_AutoML_System.git;cd ..;" \ "mkdir image_classification;cd ..;" # 测试时使用fakejobspace中的算法运行 command = command+"cd jobspace/algorithm/PCL_AutoML_System/algorithm/classification/pytorch_automodel/image_classification;" command = command + "PYTHONPATH=./ python Timm.py " expdirname = str(jobname) + "_" + str(datasetname) + "_" + str(maxflops) + "_exp_" + str(time.time()) outputdir = "/userhome/jobspace/image_classification/"+expdirname command = command + " --outputdir " + outputdir command = command + " --dataset " + str(datasetname) command = command + " --algname " + str(algname) print(command) info = API_tools.creat_mission(str(jobname), command, user.tocken, user, user.first_name) if not info["payload"]: print("error~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") return Response(data=errParser(errcode=404)) timeArray = time.localtime() otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) jobid = API_tools.get_keyword(str(info["payload"]["jobId"])) name = API_tools.get_keyword(str(jobname)) username = API_tools.get_keyword(str(user.username)) user_id = str(user.id) state = "WAITTING" createdTime = API_tools.get_keyword(str(otherStyleTime)) completedTime = str(0) _path = API_tools.get_keyword(str(outputdir)) Da = models.User_algorithm.objects.filter(user_id=user.id).filter(name=algname)[0] algorithm_id = Da.id dataset_id = form_dict['dataSelection'] with connection.cursor() as cursor: sqltext = "INSERT INTO `automl_web`.`_app_user_job`(`jobid`, `name`, `username`, `user_id`, `state`, `createdTime`, `completedTime`,`_path`, `algorithm_id`, `dataset_id`) " \ "VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}','{9}');".format( jobid, name, username, user_id, state, createdTime, completedTime, _path, algorithm_id, dataset_id ) print("$$$$$$$$$$$", sqltext) cursor.execute(sqltext) # 创建完成 # 【】前端 后端 需要添加判断任务是否创建成功 res=[] res=Parser(res) return Response(data=res)