use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.ModelLoadContextProto in project angel by Tencent.
the class MasterService method load.
/**
* Load model from file
*/
@Override
public LoadResponse load(RpcController controller, LoadRequest request) throws ServiceException {
if (context.getModelLoader().isLoading()) {
throw new ServiceException("Model is loading now, please wait");
}
ModelLoadContextProto loadContextProto = request.getLoadContext();
ModelLoadContext loadContext = ProtobufUtil.convert(loadContextProto);
List<MatrixLoadContext> needLoadMatrices = loadContext.getMatricesContext();
int size = needLoadMatrices.size();
for (int i = 0; i < size; i++) {
if (!context.getMatrixMetaManager().exist(needLoadMatrices.get(i).getMatrixName())) {
throw new ServiceException("matrix " + needLoadMatrices.get(i).getMatrixName() + " does not exist");
}
}
int requestId;
try {
requestId = context.getModelLoader().load(loadContext);
} catch (Throwable x) {
throw new ServiceException(x);
}
return LoadResponse.newBuilder().setRequestId(requestId).build();
}
Aggregations