Search in sources :

Example 1 with InvalidParameterException

use of com.tencent.angel.exception.InvalidParameterException in project angel by Tencent.

the class ModelMergeAndConverterTask method run.

@Override
public void run(TaskContext taskContext) throws AngelException {
    try {
        // Get input path, output path
        String modelLoadDir = conf.get(AngelConf.ANGEL_LOAD_MODEL_PATH);
        if (modelLoadDir == null) {
            throw new InvalidParameterException("convert source path " + AngelConf.ANGEL_LOAD_MODEL_PATH + " must be set");
        }
        String convertedModelSaveDir = conf.get(AngelConf.ANGEL_SAVE_MODEL_PATH);
        if (convertedModelSaveDir == null) {
            throw new InvalidParameterException("converted model save path " + AngelConf.ANGEL_LOAD_MODEL_PATH + " must be set");
        }
        // Init serde
        String modelSerdeClass = conf.get("angel.modelconverts.serde.class", TextModelLineConvert.class.getName());
        Class<? extends ModelLineConvert> funcClass = (Class<? extends ModelLineConvert>) Class.forName(modelSerdeClass);
        Constructor<? extends ModelLineConvert> constructor = funcClass.getConstructor();
        constructor.setAccessible(true);
        ModelLineConvert serde = constructor.newInstance();
        // Parse need convert model names, if not set, we will convert all models in input directory
        String needConvertModelNames = conf.get("angel.modelconverts.model.names");
        String[] modelNames = null;
        if (needConvertModelNames == null) {
            LOG.info("we will convert all models save in " + modelLoadDir);
            Path modelLoadPath = new Path(modelLoadDir);
            FileSystem fs = modelLoadPath.getFileSystem(conf);
            FileStatus[] fileStatus = fs.listStatus(modelLoadPath);
            if (fileStatus == null || fileStatus.length == 0) {
                throw new IOException("can not find any models in " + modelLoadDir);
            }
            List<String> modelNameList = new ArrayList<>();
            for (int i = 0; i < fileStatus.length; i++) {
                if (fileStatus[i].isDirectory()) {
                    modelNameList.add(fileStatus[i].getPath().getName());
                }
            }
            if (modelNameList.isEmpty()) {
                throw new IOException("can not find any models in " + modelLoadDir);
            }
            modelNames = modelNameList.toArray(new String[0]);
        } else {
            modelNames = needConvertModelNames.split(",");
            if (modelNames.length == 0) {
                throw new IOException("can not find any models in " + modelLoadDir);
            }
        }
        for (int i = 0; i < modelNames.length; i++) {
            LOG.info("===================start to convert model " + modelNames[i]);
            ModelMergeAndConvert.convert(conf, modelLoadDir + Path.SEPARATOR + modelNames[i], convertedModelSaveDir + Path.SEPARATOR + modelNames[i], serde);
            LOG.info("===================end to convert model " + modelNames[i]);
        }
    } catch (Throwable x) {
        LOG.fatal("convert model falied, ", x);
        throw new AngelException(x);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) AngelException(com.tencent.angel.exception.AngelException) FileStatus(org.apache.hadoop.fs.FileStatus) ArrayList(java.util.ArrayList) TextModelLineConvert(com.tencent.angel.tools.TextModelLineConvert) TextModelLineConvert(com.tencent.angel.tools.TextModelLineConvert) ModelLineConvert(com.tencent.angel.tools.ModelLineConvert) IOException(java.io.IOException) InvalidParameterException(com.tencent.angel.exception.InvalidParameterException) FileSystem(org.apache.hadoop.fs.FileSystem)

Example 2 with InvalidParameterException

use of com.tencent.angel.exception.InvalidParameterException in project angel by Tencent.

the class AngelClient method run.

@Override
public void run() throws AngelException {
    if (master == null) {
        throw new AngelException("parameter servers are not started, you must execute startPSServer first!!");
    }
    try {
        createMatrices();
        master.start(null, StartRequest.newBuilder().build());
    } catch (ServiceException | InvalidParameterException e) {
        LOG.error("start application failed.", e);
        throw new AngelException(e);
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) InvalidParameterException(com.tencent.angel.exception.InvalidParameterException) ServiceException(com.google.protobuf.ServiceException)

Example 3 with InvalidParameterException

use of com.tencent.angel.exception.InvalidParameterException in project angel by Tencent.

the class AngelPSClient method loadSysConfig.

private void loadSysConfig() throws InvalidParameterException {
    String angelHomePath = System.getenv("ANGEL_HOME");
    if (angelHomePath == null) {
        LOG.fatal("ANGEL_HOME is empty, please set it first");
        throw new InvalidParameterException("ANGEL_HOME is empty, please set it first");
    }
    conf.addResource(new Path(angelHomePath + "/conf/" + angelSysConfFile));
    LOG.info("load system config file success");
}
Also used : Path(org.apache.hadoop.fs.Path) InvalidParameterException(com.tencent.angel.exception.InvalidParameterException)

Example 4 with InvalidParameterException

use of com.tencent.angel.exception.InvalidParameterException in project angel by Tencent.

the class AppStateStorage method loadMatrixMeta.

/**
 * load matrix meta from file
 *
 * @return MatrixMetaManager matrix meta storage
 * @throws IOException, ClassNotFoundException, InvalidParameterException
 */
public AMMatrixMetaManager loadMatrixMeta() throws IOException, ClassNotFoundException, InvalidParameterException {
    try {
        matrixMetaLock.lock();
        Path matrixFilePath = null;
        try {
            matrixFilePath = findFilePathUsePrefix(matrixMetaFileNamePrefix);
        } catch (Exception x) {
            LOG.error("find matrix meta file failed.", x);
            return null;
        }
        if (matrixFilePath == null) {
            return null;
        }
        FSDataInputStream inputStream = fs.open(new Path(writeDir, matrixFilePath));
        AMMatrixMetaManager matrixMetaManager = new AMMatrixMetaManager(context);
        matrixMetaManager.deserialize(inputStream);
        return matrixMetaManager;
    } finally {
        matrixMetaLock.unlock();
    }
}
Also used : AMMatrixMetaManager(com.tencent.angel.master.matrixmeta.AMMatrixMetaManager) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) InvalidParameterException(com.tencent.angel.exception.InvalidParameterException)

Example 5 with InvalidParameterException

use of com.tencent.angel.exception.InvalidParameterException in project angel by Tencent.

the class AngelRunJar method submit.

public static void submit(Configuration conf) throws Exception {
    LOG.info("angel python file: " + conf.get("angel.pyangel.pyfile"));
    if (null != conf.get("angel.pyangel.pyfile")) {
        conf.set(AngelConf.ANGEL_APP_SUBMIT_CLASS, "com.tencent.angel.api.python.PythonRunner");
    }
    // instance submitter class
    final String submitClassName = conf.get(AngelConf.ANGEL_APP_SUBMIT_CLASS, AngelConf.DEFAULT_ANGEL_APP_SUBMIT_CLASS);
    setKerberos(conf);
    UserGroupInformation ugi = UGITools.getCurrentUser(conf);
    ugi.doAs(new PrivilegedExceptionAction<String>() {

        @Override
        public String run() throws Exception {
            AppSubmitter submmiter = null;
            try {
                Class<?> submitClass = Class.forName(submitClassName);
                submmiter = (AppSubmitter) submitClass.newInstance();
                LOG.info("submitClass: " + submitClass.getName());
            } catch (Exception x) {
                String message = "load submit class failed " + x.getMessage();
                LOG.fatal(message, x);
                throw new InvalidParameterException(message);
            }
            submmiter.submit(conf);
            return "OK";
        }
    });
}
Also used : InvalidParameterException(com.tencent.angel.exception.InvalidParameterException) AppSubmitter(com.tencent.angel.AppSubmitter) InvalidParameterException(com.tencent.angel.exception.InvalidParameterException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

InvalidParameterException (com.tencent.angel.exception.InvalidParameterException)24 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)8 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)7 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)7 AngelException (com.tencent.angel.exception.AngelException)6 IOException (java.io.IOException)6 Path (org.apache.hadoop.fs.Path)4 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)3 GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)3 MatrixClient (com.tencent.angel.psagent.matrix.MatrixClient)3 PartGetFloatArrayAttrsResult (com.tencent.angel.graph.client.psf.get.utils.PartGetFloatArrayAttrsResult)2 PartGetIntArrayAttrsResult (com.tencent.angel.graph.client.psf.get.utils.PartGetIntArrayAttrsResult)2 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)2 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)2 MatrixContext (com.tencent.angel.ml.matrix.MatrixContext)2 ModelLineConvert (com.tencent.angel.tools.ModelLineConvert)2 TextModelLineConvert (com.tencent.angel.tools.TextModelLineConvert)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 Configuration (org.apache.hadoop.conf.Configuration)2