def save_single_api_record(request): id = utils.save_api_record(json.loads(request.body)) public_info = utils.get_public(request) if public_info.get('auth').get('write') != 1: return public.fail_result_http('have no write right') else: return public.success_result_http({'id': id})
def module_api_view(request): module_id = request.GET.get("module_id") data = {} data["public"] = utils.get_public(request) data["api"] = utils.get_module_api(module_id) return render(request, 'assess/module_api.html', {"data":data})
def train_algorithm(request): module_id = request.GET.get('module_id') scene_id = request.GET.get('scene_id') limit = request.GET.get('limit') if scene_id and module_id: tmp = utils.get_scene_record(module_id,scene_id) for i in tmp: i['data_length'] = range(len(i['data'][i['data'].keys()[0]])) i['resources'] = [] i['apis'] = [] i['api_info'] = [] api_dict = {} for k in i['data'].keys(): if k != 'total' and k.find('#api#') != 0: i['resources'].append(k) if k != 'total' and k.find('#api#') == 0: api_dict[k[5:]] = i['data'][k] #this_api_id = utils.get_api_by_name(k[5:]) i['api_info'].append(k) # TODO for j in i['data_length']: current_api_dict = {} for k,v in api_dict.iteritems(): current_api_dict[k] = v[j] i['apis'].append(current_api_dict) if limit and int(limit) > 0: ret = {'scene_records' : tmp[:int(limit)]} else: ret = {'scene_records': tmp} ret['module_id'] = module_id ret['scene_id'] = scene_id scene_api = utils.get_scene_api(module_id, scene_id) for s in scene_api: s['api_info'] = utils.get_api(s.get('api_id')) # ge threhold if s['api_info']: s['api_info']['threholds'] = utils.get_api_resource(s.get('api_id')) for th in s['api_info']['threholds'].get('resource_list'): th['name'] = utils.get_resource(th.get('resource_id')).get('name') ret['scene_info'] = utils.get_scene(scene_id) ret['module_info'] = utils.get_module(module_id) ret['scene_api'] = scene_api ret['all_resource'] = [] all_resource_ids = [] # get all resource need for s in scene_api: for id in s.get('api_info').get('threholds').get('resource_id'): if not id in all_resource_ids: all_resource_ids.append(id) ret['all_resource'].append(utils.get_resource(id)) ret["public"] = utils.get_public(request) return render(request, 'assess/train_algorithm.html', {'data': ret}) else: return render(request, 'error.html')
def api_view(request): data = {} data["public"] = utils.get_public(request) data["resource"] = utils.get_resource() id = request.GET.get("id") if id: data["api"] = utils.get_api(id) data["resource_list"] = utils.get_api_resource(id) return render(request, 'assess/api.html', {"data":data})
def delete_single_api_record(request): data = json.loads(request.body) public = utils.get_public(request) if public.get('auth').get('write') != 1: return public.fail_result_http('have no write right') if data.get('id'): ret = utils.delete_api_record(data.get('id')) return public.success_result_http(ret) else: return public.fail_result_http('id is empty')
def pre_launch_view(request): public_date = utils.get_public(request) group_id = public_date.get("group_id") ret = {} ret['version'] = utils.get_seal_or_newlab_version() ret['biz_version'] = utils.get_seal_or_newlab_version('biz') ret['shanghaife_version'] = utils.get_seal_or_newlab_version('shanghaife') ret['online'] = [] ret['data'] = {} ret["data"]["public"] = public_date ret['data']['jobs'] = utils.get_group_jobs(group_id) return render(request, "data_mgr/prelaunch.html", ret)
def pre_launch_view(request): public_date = utils.get_public(request) group_id = public_date.get("group_id") ret = {} ret['version'] = utils.get_seal_or_newlab_version() ret['biz_version'] = utils.get_seal_or_newlab_version('biz') ret['shanghaife_version'] = utils.get_seal_or_newlab_version('shanghaife') ret['online'] = [] ret['data'] = {} ret["data"]["public"] = public_date ret['data']['jobs'] = utils.get_group_jobs(group_id) return render(request,"data_mgr/prelaunch.html", ret)
def module_view(request): module_id = request.GET.get("module_id") data = {} data["module_id"] = module_id data["public"] = utils.get_public(request) scenes = utils.get_scene() data["scene"] = scenes for scene in scenes: scene_id = scene["id"] api_list = utils.get_scene_api(module_id, scene_id) scene["api_list"] = [] for api in api_list: api["info"] = utils.get_api(api["api_id"]) scene["api_list"].append(api) return render(request, 'assess/module.html', {"data":data})
def single_api_view(request): ret = {} ret['public'] = utils.get_public(request) api_id = request.GET.get('api_id') records = utils.get_api_record(api_id) api_resource = utils.get_api_resource(api_id) ret['resource'] = [] ret['records'] = [] for i in api_resource['resource_id']: ret['resource'].append(utils.get_resource(i)) ret['records'] = records for r in ret['records']: r['data'] = json.loads(r['data']) ret['api_id'] = api_id return render(request, 'assess/api_record.html', {'data': ret})
def single_api_view(request): ret = {} ret['public'] = utils.get_public(request) api_id = request.GET.get('api_id') records = utils.get_api_record(api_id) api_resource = utils.get_api_resource(api_id) ret['resource'] = [] ret['records'] = [] for i in api_resource['resource_id']: ret['resource'].append(utils.get_resource(i)) ret['records'] = records for r in ret['records']: r['data'] = json.loads(r['data']) ret['api_id'] = api_id return render(request, 'assess/api_record.html', {'data':ret })
def group_view(request): data = {} data["public"] = utils.get_public(request) data["group"] = utils.get_group() return render(request, 'data_mgr/group.html', {"data": data})
def group_view(request): data = {} data["public"] = utils.get_public(request) data["group"] = utils.get_group() return render(request, 'data_mgr/group.html', {"data":data})
def resource_view(request): data = {} data["public"] = utils.get_public(request) data["resource"] = utils.get_resource() return render(request, 'assess/resource.html', {"data":data})
def scene_view(request): data = {} data["public"] = utils.get_public(request) data["scene"] = utils.get_scene() return render(request, 'assess/scene.html', {"data":data})
def train_algorithm(request): module_id = request.GET.get('module_id') scene_id = request.GET.get('scene_id') limit = request.GET.get('limit') if scene_id and module_id: tmp = utils.get_scene_record(module_id, scene_id) for i in tmp: i['data_length'] = range(len(i['data'][i['data'].keys()[0]])) i['resources'] = [] i['apis'] = [] i['api_info'] = [] api_dict = {} for k in i['data'].keys(): if k != 'total' and k.find('#api#') != 0: i['resources'].append(k) if k != 'total' and k.find('#api#') == 0: api_dict[k[5:]] = i['data'][k] #this_api_id = utils.get_api_by_name(k[5:]) i['api_info'].append(k) # TODO for j in i['data_length']: current_api_dict = {} for k, v in api_dict.iteritems(): current_api_dict[k] = v[j] i['apis'].append(current_api_dict) if limit and int(limit) > 0: ret = {'scene_records': tmp[:int(limit)]} else: ret = {'scene_records': tmp} ret['module_id'] = module_id ret['scene_id'] = scene_id scene_api = utils.get_scene_api(module_id, scene_id) for s in scene_api: s['api_info'] = utils.get_api(s.get('api_id')) # ge threhold if s['api_info']: s['api_info']['threholds'] = utils.get_api_resource( s.get('api_id')) for th in s['api_info']['threholds'].get('resource_list'): th['name'] = utils.get_resource( th.get('resource_id')).get('name') ret['scene_info'] = utils.get_scene(scene_id) ret['module_info'] = utils.get_module(module_id) ret['scene_api'] = scene_api ret['all_resource'] = [] all_resource_ids = [] # get all resource need for s in scene_api: for id in s.get('api_info').get('threholds').get('resource_id'): if not id in all_resource_ids: all_resource_ids.append(id) ret['all_resource'].append(utils.get_resource(id)) ret["public"] = utils.get_public(request) return render(request, 'assess/train_algorithm.html', {'data': ret}) else: return render(request, 'error.html')
def assess_main_view(request): data = {} data["public"] = utils.get_public(request) return render(request, 'assess/assess_base.html', {"data":data})