def listJobs(self, request, context): try: rq: ScheduleJobRequest = request job_list = self._scheduler.list_jobs(rq.execution_id) response = ListJobInfoResponse(result=ResultProto( status=StatusProto.OK)) response.job_list.extend(job_list_to_proto(job_list)) return response except Exception as err: return ListJobInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def listWorkflows(self, request, context): try: rq: ScheduleWorkflowRequest = request workflow_info_list = self._scheduler.list_workflows(rq.namespace) workflow_proto_list = workflow_list_to_proto(workflow_info_list) response = ListWorkflowInfoResponse(result=ResultProto( status=StatusProto.OK)) response.workflow_list.extend(workflow_proto_list) return response except Exception as err: return ListWorkflowInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def getJob(self, request, context): try: rq: ScheduleJobRequest = request job = self._scheduler.get_job(rq.job_name, rq.execution_id) if job is None: return JobInfoResponse(result=ResultProto( status=StatusProto.ERROR, error_message='{} do not exist!'.format(rq.job_name))) return JobInfoResponse(result=ResultProto(status=StatusProto.OK), job=job_to_proto(job)) except Exception as err: return JobInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def killAllWorkflowExecutions(self, request, context): try: rq: WorkflowExecutionRequest = request workflow_execution_list = self._scheduler.kill_all_workflow_execution( rq.namespace, rq.workflow_name) response = ListWorkflowExecutionResponse(result=ResultProto( status=StatusProto.OK)) response.workflow_execution_list.extend( workflow_execution_list_to_proto(workflow_execution_list)) return response except Exception as err: return ListWorkflowExecutionResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def getWorkflow(self, request, context): try: rq: ScheduleWorkflowRequest = request workflow_info = self._scheduler.get_workflow( rq.namespace, rq.workflow_name) if workflow_info is None: return WorkflowInfoResponse(result=ResultProto( status=StatusProto.ERROR, error_message='{} do not exist!'.format(rq.workflow_name))) return WorkflowInfoResponse( result=ResultProto(status=StatusProto.OK), workflow=workflow_to_proto(workflow_info)) except Exception as err: return WorkflowInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def getWorkflowExecution(self, request, context): try: rq: WorkflowExecutionRequest = request workflow_execution = self._scheduler.get_workflow_execution( rq.execution_id) if workflow_execution is None: return WorkflowExecutionResponse(result=ResultProto( status=StatusProto.ERROR, error_message='{} do not exist!'.format(rq.execution_id))) return WorkflowExecutionResponse( result=ResultProto(status=StatusProto.OK), workflow_execution=workflow_execution_to_proto( workflow_execution)) except Exception as err: return WorkflowExecutionResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def startNewWorkflowExecution(self, request, context): try: rq: WorkflowExecutionRequest = request workflow_execution = self._scheduler.start_new_workflow_execution( rq.namespace, rq.workflow_name) if workflow_execution is None: return WorkflowInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message='{}, {} do not exist!'. format(rq.namespace, rq.workflow_name))) return WorkflowExecutionResponse( result=ResultProto(status=StatusProto.OK), workflow_execution=workflow_execution_to_proto( workflow_execution)) except Exception as err: return WorkflowExecutionResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def submitWorkflow(self, request, context): try: rq: ScheduleWorkflowRequest = request workflow: Workflow = json_utils.loads(rq.workflow_json) workflow.workflow_name = rq.workflow_name config = {} config.update(workflow.project_desc.project_config['blob']) # config['local_repository'] = self._scheduler_config.repository() blob_manager = BlobManagerFactory.get_blob_manager(config) project_path: Text = blob_manager\ .download_blob(workflow_id=workflow.workflow_id, remote_path=workflow.project_desc.project_config.get('uploaded_project_path'), local_path=self._scheduler_config.repository()) project_desc: ProjectDesc = get_project_description_from( project_path) project_name = project_desc.project_name # update workflow workflow.project_desc = project_desc for n, j in workflow.jobs.items(): j.job_config.project_desc = project_desc j.job_config.project_path = project_path workflow_info = self._scheduler.submit_workflow( workflow, project_desc) if workflow_info is None: return WorkflowInfoResponse(result=ResultProto( status=StatusProto.ERROR, error_message='{}, {} do not exist!'.format( project_name, workflow.workflow_name))) return WorkflowInfoResponse( result=ResultProto(status=StatusProto.OK), workflow=workflow_to_proto(workflow_info)) except Exception as err: return WorkflowInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))