def submitWorkflow(self, request, context): try: rq: ScheduleWorkflowRequest = request if rq.workflow_json is None or '' == rq.workflow_json: return WorkflowInfoResponse(result=ResultProto( status=StatusProto.ERROR, error_message='workflow json is empty!')) workflow: Workflow = json_utils.loads(rq.workflow_json) config = {} config.update(workflow.properties['blob']) blob_manager = BlobManagerFactory.get_blob_manager(config) project_path: Text = blob_manager\ .download_project(workflow_snapshot_id=workflow.workflow_snapshot_id, remote_path=workflow.project_uri, local_path=self._scheduler_service_config.repository()) project_context: ProjectContext = build_project_context( project_path) project_name = project_context.project_name workflow_info = self._scheduler.submit_workflow( workflow, project_context) 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()))
def listJobs(self, request, context): try: rq: ScheduleJobRequest = request job_list = self._scheduler.list_job_executions(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 listWorkflowExecutions(self, request, context): try: rq: WorkflowExecutionRequest = request workflow_execution_list = self._scheduler.list_workflow_executions( 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 getJob(self, request, context): try: rq: ScheduleJobRequest = request jobs = self._scheduler.get_job_executions(rq.job_name, rq.execution_id) if jobs 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(jobs[0])) except Exception as err: return JobInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message=traceback.format_exc()))
def resumeWorkflowScheduling(self, request, context): try: rq: ScheduleWorkflowRequest = request workflow_info = self._scheduler.resume_workflow_scheduling( 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 listWorkflows(self, request, context): return WorkflowInfoResponse( result=ResultProto(status=StatusProto.ERROR, error_message='Do not support listWorkflows'))