CreateOnlineModelCommand extends AbstractCommand { public static CreateOnlineModelCommand parse(String cmd, ExecutionContext ctx) throws ODPSConsoleException { if (cmd == null || ctx == null) { return null; } OnlineModelInfo modelInfo = CreateOnlineModelCommand.buildOnlineModelInfo(cmd, PATTERN, ctx); if (modelInfo == null) { return null; } modelInfo.version = 0; if (modelInfo.project == null) { modelInfo.project = ctx.getProjectName(); } return new CreateOnlineModelCommand(modelInfo, cmd, ctx); } CreateOnlineModelCommand(OnlineModelInfo modelInfo, String cmd,
                                  ExecutionContext ctx); static void printUsage(PrintStream stream); @Override void run(); static Options getOptions(); static OnlineModelInfo buildOnlineModelInfo(String cmd, Pattern PATTERN,
                                                     ExecutionContext ctx); static CreateOnlineModelCommand parse(String cmd, ExecutionContext ctx); static final String[] HELP_TAGS; }
@Test public void testCreateOnLineModelParameterError3() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel -p prj1 model1 " + "-target target1 " + "-id id1 " + "-libName lib1 " + "-refResource res1 " + "-offlinemodelName aaa " + "-instanceNum 2 " + "-cpu 100 " + "-memory 2"; expectEx.expect(ODPSConsoleException.class); expectEx.expectMessage("invalid parameter for onlinemodel, please HELP ONLINEMODEL."); CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); }
@Test public void testCreateOnLineModelParameterError4() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel -p prj1 model1 " + "-target target1 " + "-id id1 " + "-libName lib1 " + "-refResource res1 " + "-instanceNum 2 " + "-cpu 100 " + "-runtime xxx"; expectEx.expect(ODPSConsoleException.class); expectEx.expectMessage("Parameter -runtime must be Jar or Native."); CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); }
@Test public void testCreateOnLineModelExists() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel model_exist " + "-offlinemodelProject online_model_test " + "-offlinemodelName lr_model_for_online"; CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); assertNotNull(command); }
@Test public void testCreateOnLineModelWithOfflineModel() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel t_offlinemodel " + "-offlinemodelProject online_model_test " + "-offlinemodelName lr_model_for_online " + "-qos 5000 " + "-instanceNum 2 " + "-cpu 100 " + "-memory 2"; CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); assertNotNull(command); }
@Test public void testCreateOnLineModelWith3rdModel() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel t_3rd_cpp " + "-target abc " + "-id SampleProcessor " + "-libName libsample_processor.so " + "-refResource online_model_test/resources/sample_processor.tar.gz " + "-qos 5000 " + "-instanceNum 2 " + "-cpu 100 " + "-gpu 100 " + "-memory 2"; CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); assertNotNull(command); }
@Test public void testCreateOnLineModelWithJavaModel() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel t_3rd_jar " + "-target abc " + "-id com.aliyun.openservices.odps.predict.pmml.PmmlProcessor " + "-libName predict-pmml-processor.jar " + "-refResource online_model_test/resources/predict-pmml-processor.jar,online_model_test/resources/irislinearreg.xml " + "-configuration irislinearreg.xml " + "-qos 5000 " + "-instanceNum 2 " + "-cpu 100 " + "-memory 2 " + "-runtime Jar"; CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); assertNotNull(command); }
@Test public void testCreateOnLineModelParameterError1() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel -p prj1 model1 " + "-qos 5000 " + "-instanceNum 2 " + "-cpu 100 " + "-memory 2"; expectEx.expect(ODPSConsoleException.class); expectEx.expectMessage("invalid parameter for onlinemodel, please HELP ONLINEMODEL."); CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); }
@Test public void testCreateOnLineModelParameterError2() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create onlinemodel -p prj1 model1 " + "-target target1 " + "-libName lib1 " + "-refResource res1 " + "-qos 5000 " + "-instanceNum 2 " + "-cpu 100 " + "-memory 2"; expectEx.expect(ODPSConsoleException.class); expectEx.expectMessage("invalid parameter for onlinemodel, please HELP ONLINEMODEL."); CreateOnlineModelCommand command = CreateOnlineModelCommand.parse(cmd, context); }