def get(self): parser = reqparse.RequestParser() parser.add_argument('jobId') parser.add_argument('userName') args = parser.parse_args() jobId = args["jobId"] userName = args["userName"] job = JobRestAPIUtils.GetJobDetail(userName, jobId) job["jobParams"] = json.loads(base64.b64decode(job["jobParams"])) if "endpoints" in job and job["endpoints"] is not None and ( job["endpoints"].strip()) > 0: job["endpoints"] = json.loads(job["endpoints"]) if "jobStatusDetail" in job and job["jobStatusDetail"] is not None and ( job["jobStatusDetail"].strip()) > 0: try: job["jobStatusDetail"] = Json.loads( base64.b64decode(job["jobStatusDetail"])) except Exception as e: pass if "jobMeta" in job: job.pop("jobMeta", None) resp = jsonify(job) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser = reqparse.RequestParser() parser.add_argument('userName') parser.add_argument('uid') parser.add_argument('gid') parser.add_argument('groups') args = parser.parse_args() ret = {} userName = args["userName"] if args["uid"] is None or len(args["uid"].strip()) == 0: uid = authorization.INVALID_ID else: uid = args["uid"] if args["gid"] is None or len(args["gid"].strip()) == 0: gid = authorization.INVALID_ID else: gid = args["gid"] if args["groups"] is None or len(args["groups"].strip()) == 0: groups = [] else: groups = args["groups"] ret["status"] = JobRestAPIUtils.AddUser(userName, uid, gid, groups) resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser = reqparse.RequestParser() parser.add_argument('vcName') parser.add_argument('storageType') parser.add_argument('url') parser.add_argument('metadata') parser.add_argument('defaultMountPath') parser.add_argument('userName') args = parser.parse_args() vcName = args["vcName"] storageType = args["storageType"] url = args["url"] metadata = args["metadata"] defaultMountPath = args["defaultMountPath"] userName = args["userName"] ret = {} ret["result"] = JobRestAPIUtils.UpdateStorage(userName, vcName, url, storageType, metadata, defaultMountPath) resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): args = self.get_parser.parse_args() vcName = args["vcName"] userName = args["userName"] ret = {} ret["result"] = JobRestAPIUtils.ListStorages(userName, vcName) return generate_response(ret)
def get(self): args = self.get_parser.parse_args() jobId = args["jobId"] userName = args["userName"] job = JobRestAPIUtils.GetJobDetailV2(userName, jobId) remove_creds(job) resp = generate_response(job) return resp
def get(self): args = self.get_parser.parse_args() job_ids = args["jobIds"] username = args["userName"] result = JobRestAPIUtils.approve_jobs(username, job_ids) ret = {"result": result} return generate_response(ret)
def get(self): args = self.get_parser.parse_args() vcName = args["vcName"] userName = args["userName"] url = args["url"] ret = {} ret["result"] = JobRestAPIUtils.DeleteStorage(userName, vcName, url) return generate_response(ret)
def get(self): parser = reqparse.RequestParser() parser.add_argument('jobId', required=True) parser.add_argument('userName', required=True) args = parser.parse_args() jobId = args["jobId"] userName = args["userName"] return JobRestAPIUtils.GetJobLog(userName, jobId)
def get(self): cluster_status, last_updated_time = JobRestAPIUtils.GetClusterStatus() cluster_status["last_updated_time"] = last_updated_time resp = jsonify(cluster_status) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser.add_argument('userName') parser.add_argument('num') args = parser.parse_args() num = None if args["num"] is not None: try: num = int(args["num"]) except: pass if args["userName"] is not None and len(args["userName"].strip()) > 0: jobs = JobRestAPIUtils.GetJobList(args["userName"],num) else: jobs = [] jobList = [] queuedJobs = [] runningJobs = [] finishedJobs = [] visualizationJobs = [] for job in jobs: job.pop("jobDescriptionPath",None) job.pop("jobDescription",None) job["jobParams"] = json.loads(base64.b64decode(job["jobParams"])) if "endpoints" in job and job["endpoints"] is not None and (job["endpoints"].strip()) > 0: job["endpoints"] = json.loads(base64.b64decode(job["endpoints"])) if "jobStatusDetail" in job and job["jobStatusDetail"] is not None and (job["jobStatusDetail"].strip()) > 0: try: job["jobStatusDetail"] = json.loads(base64.b64decode(job["jobStatusDetail"])) except Exception as e: job["jobStatusDetail"] = base64.b64decode(job["jobStatusDetail"]) pass if job["jobStatus"] == "running": if job["jobType"] == "training": runningJobs.append(job) elif job["jobType"] == "visualization": visualizationJobs.append(job) elif job["jobStatus"] == "queued" or job["jobStatus"] == "scheduling" or job["jobStatus"] == "unapproved": queuedJobs.append(job) else: finishedJobs.append(job) ret = {} ret["queuedJobs"] = queuedJobs ret["runningJobs"] = runningJobs ret["finishedJobs"] = finishedJobs ret["visualizationJobs"] = visualizationJobs ret["meta"] = {"queuedJobs": len(queuedJobs),"runningJobs": len(runningJobs),"finishedJobs": len(finishedJobs),"visualizationJobs": len(visualizationJobs)} resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): args = self.get_parser.parse_args() job_id = args.get("jobId") username = args.get("userName") resp, status_code = JobRestAPIUtils.get_job_insight(job_id, username) if status_code != 200: return resp, status_code return generate_response(resp)
def get(self): args = self.get_parser.parse_args() vcName = args["vcName"] quota = args["quota"] metadata = args["metadata"] userName = args["userName"] ret = {} ret["result"] = JobRestAPIUtils.AddVC(userName, vcName, quota, metadata) return generate_response(ret)
def get(self): parser.add_argument('jobId') args = parser.parse_args() jobId = args["jobId"] commands = JobRestAPIUtils.GetCommands(jobId) resp = jsonify(commands) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): args = self.get_parser.parse_args() username = args["userName"] identityName = args["identityName"] resourceType = args["resourceType"] resourceName = args["resourceName"] ret = {} ret["result"] = JobRestAPIUtils.DeleteAce(username, identityName, resourceType, resourceName) return generate_response(ret)
def post(self): args = self.post_parser.parse_args() job_id = args.get("jobId") username = args.get("userName") payload = request.get_json(force=True, silent=True) resp, status_code = JobRestAPIUtils.set_job_insight( job_id, username, payload) if status_code != 200: return resp, status_code return generate_response(resp)
def get(self): parser.add_argument('userName') args = parser.parse_args() userName = args["userName"] cluster_status, last_updated_time = JobRestAPIUtils.GetClusterStatus() cluster_status["last_updated_time"] = last_updated_time resp = jsonify(cluster_status) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser = reqparse.RequestParser() parser.add_argument('jobId') parser.add_argument('userName') args = parser.parse_args() jobId = args["jobId"] userName = args["userName"] job = JobRestAPIUtils.GetJobDetailV2(userName, jobId) remove_creds(job) resp = generate_response(job) return resp
def get(self): args = self.get_parser.parse_args() job_id = args["jobId"] username = args["userName"] resourcegpu = int(args["resourcegpu"]) msg, status_code = JobRestAPIUtils.scale_inference_job( username, job_id, resourcegpu) if status_code != 200: return msg, status_code return generate_response(msg)
def get(self): parser = reqparse.RequestParser() parser.add_argument('jobId') args = parser.parse_args() jobId = args["jobId"] job = JobRestAPIUtils.GetJobStatus(jobId) resp = jsonify(job) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser.add_argument('userName') args = parser.parse_args() userName = args["userName"] ret = {} ret["result"] = JobRestAPIUtils.ListVCs(userName) resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): args = self.get_parser.parse_args() job_id = args["jobId"] username = args["userName"] result = JobRestAPIUtils.resume_job(username, job_id) ret = {} if result: ret["result"] = "Success, the job is scheduled to be resumed." else: ret["result"] = "Cannot resume the job. Job ID:" + job_id return generate_response(ret)
def get(self): args = self.get_parser.parse_args() job_id = args["jobId"] username = args["userName"] result = JobRestAPIUtils.approve_job(username, job_id) ret = {} if result: ret["result"] = "Success, the job has been approved." else: ret["result"] = "Cannot approve the job. Job ID:" + job_id return generate_response(ret)
def get(self): """return job["endpoints"]: curl -X GET /endpoints?jobId=...&userName=...""" args = self.get_parser.parse_args() jobId = args["jobId"] username = args["userName"] ret = JobRestAPIUtils.GetEndpoints(username, jobId) # TODO: return 403 error code # Return empty list for now to keep backward compatibility with old portal. resp = generate_response(ret) return resp
def get(self): args = self.get_parser.parse_args() vcName = args["vcName"] storageType = args["storageType"] url = args["url"] metadata = args["metadata"] defaultMountPath = args["defaultMountPath"] userName = args["userName"] ret = {} ret["result"] = JobRestAPIUtils.UpdateStorage(userName, vcName, url, storageType, metadata, defaultMountPath) return generate_response(ret)
def get(self): parser.add_argument('userName') parser.add_argument('userId') args = parser.parse_args() username = args["userName"] userId = args["userId"] ret = {} ret["status"] = JobRestAPIUtils.AddUser(username, userId) resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser = reqparse.RequestParser() parser.add_argument('vcName') parser.add_argument('userName') args = parser.parse_args() vcName = args["vcName"] userName = args["userName"] ret = {} ret["result"] = JobRestAPIUtils.ListStorages(userName, vcName) resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): args = self.get_parser.parse_args() job_id = args["jobId"] username = args["userName"] result = JobRestAPIUtils.kill_job(username, job_id) ret = {} if result: # NOTE "Success" prefix is used in reaper, please also update reaper code # if need to change it. ret["result"] = "Success, the job is scheduled to be terminated." else: ret["result"] = "Cannot Kill the job. Job ID:" + job_id return generate_response(ret)
def get(self): args = self.get_parser.parse_args() ret = {} userName = args["userName"] uid = args["uid"] gid = args["gid"] groups = args["groups"] public_key = args["public_key"] private_key = args["private_key"] ret["status"] = JobRestAPIUtils.AddUser(userName, uid, gid, groups, public_key, private_key) return generate_response(ret)
def get(self): parser.add_argument('vcName') parser.add_argument('userName') args = parser.parse_args() vcName = args["vcName"] userName = args["userName"] vc_status, last_updated_time = JobRestAPIUtils.GetVCStatus( userName, vcName) vc_status["last_updated_time"] = last_updated_time resp = jsonify(vc_status) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp
def get(self): parser.add_argument('vcName') parser.add_argument('userName') parser.add_argument('url') args = parser.parse_args() vcName = args["vcName"] userName = args["userName"] url = args["url"] ret = {} ret["result"] = JobRestAPIUtils.DeleteStorage(userName, vcName, url) resp = jsonify(ret) resp.headers["Access-Control-Allow-Origin"] = "*" resp.headers["dataType"] = "json" return resp