def _unwrap_job_response(response): if response.return_code == str(SUCCESS): return ProtoToMeta.proto_to_job_meta(Parse(response.data, JobProto())) elif response.return_code == str(RESOURCE_DOES_NOT_EXIST): return None else: raise AIFlowException(response.return_msg)
def proto_to_job(proto: JobProto) -> JobInfo: if proto is None: return None else: return JobInfo(job_name=proto.name, state=ProtoToMeta.proto_to_state(proto.job_state), workflow_execution=proto_to_workflow_execution( proto.workflow_execution))
def _unwrap_job_list_response(response): if response.return_code == str(SUCCESS): job_proto_list = Parse(response.data, JobListProto()) return ProtoToMeta.proto_to_job_meta_list(job_proto_list.jobs) elif response.return_code == str(RESOURCE_DOES_NOT_EXIST): return None else: raise AIFlowException(response.return_msg)
def _unwrap_dataset_list_response(response): if response.return_code == str(SUCCESS): dataset_proto_list = Parse(response.data, DatasetListProto()) return ProtoToMeta.proto_to_dataset_meta_list( dataset_proto_list.datasets) elif response.return_code == str(RESOURCE_DOES_NOT_EXIST): return None else: raise AIFlowException(response.return_msg)
def _unwrap_workflow_list_response(response): if response.return_code == str(SUCCESS): workflow_proto_list = Parse(response.data, WorkflowListProto()) return ProtoToMeta.proto_to_workflow_meta_list( workflow_proto_list.workflows) elif response.return_code == str(RESOURCE_DOES_NOT_EXIST): return None else: raise AIFlowException(response.return_msg)
def _unwrap_model_relation_list_response(response): if response.return_code == str(SUCCESS): model_proto_list = Parse(response.data, ModelRelationListProto()) return ProtoToMeta.proto_to_model_relation_meta_list( model_proto_list.model_relations) elif response.return_code == str(RESOURCE_DOES_NOT_EXIST): return None else: raise AIFlowException(response.return_msg)
def proto_to_workflow_execution( proto: WorkflowExecutionProto) -> WorkflowExecutionInfo: if proto is None: return None else: return WorkflowExecutionInfo( execution_id=proto.execution_id, state=ProtoToMeta.proto_to_state(proto.execution_state), workflow_info=proto_to_workflow(proto.workflow))
def _unwrap_example_list_response(response): if response.return_code == str(SUCCESS): example_proto_list = Parse(response.data, ExampleListProto()) return ProtoToMeta.proto_to_example_meta_list( example_proto_list.examples) elif response.return_code == str(RESOURCE_DOES_NOT_EXIST): return None else: raise AIFlowException(response.return_msg)
def registerExamples(self, request, context): _examples = ProtoToMeta.proto_to_example_meta_list(request.examples) response = self.store.register_examples(_examples) return _warp_example_list_response(response)
def updateWorkflowExecutionState(self, request, context): _state = ProtoToMeta.proto_to_state(request.state) uuid = self.store.update_workflow_execution_state(_state, request.name) return _wrap_update_response(uuid)
def updateJobState(self, request, context): _state = ProtoToMeta.proto_to_state(request.state) uuid = self.store.update_job_state(_state, request.name) return _wrap_update_response(uuid)
def registerDatasets(self, request, context): _datasets = ProtoToMeta.proto_to_dataset_meta_list(request.datasets) response = self.store.register_datasets(_datasets) return _warp_dataset_list_response(response)