use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.ModelSaveContextProto in project angel by Tencent.
the class MasterService method save.
/**
* Save model to files.
*
* @param controller rpc controller of protobuf
* @param request save request that contains all matrices need save
* @throws ServiceException some matrices do not exist or save operation is interrupted
*/
@SuppressWarnings("unchecked")
@Override
public SaveResponse save(RpcController controller, SaveRequest request) throws ServiceException {
ModelSaveContextProto saveContextProto = request.getSaveContext();
ModelSaveContext saveContext = ProtobufUtil.convert(saveContextProto);
List<MatrixSaveContext> needSaveMatrices = saveContext.getMatricesContext();
int size = needSaveMatrices.size();
for (int i = 0; i < size; i++) {
if (!context.getMatrixMetaManager().exist(needSaveMatrices.get(i).getMatrixName())) {
throw new ServiceException("matrix " + needSaveMatrices.get(i).getMatrixName() + " does not exist");
}
}
int requestId;
try {
requestId = context.getModelSaver().save(saveContext);
} catch (Throwable x) {
throw new ServiceException(x);
}
return SaveResponse.newBuilder().setRequestId(requestId).build();
}
Aggregations