Search in sources :

Example 1 with ModelLoadContextProto

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();
}
Also used : ServiceException(com.google.protobuf.ServiceException) MatrixLoadContext(com.tencent.angel.model.MatrixLoadContext) ModelLoadContext(com.tencent.angel.model.ModelLoadContext) ModelLoadContextProto(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.ModelLoadContextProto)

Aggregations

ServiceException (com.google.protobuf.ServiceException)1 MatrixLoadContext (com.tencent.angel.model.MatrixLoadContext)1 ModelLoadContext (com.tencent.angel.model.ModelLoadContext)1 ModelLoadContextProto (com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.ModelLoadContextProto)1