CreateOfflineModelCommand extends AbstractCommand { public static CreateOfflineModelCommand parse(String cmd, ExecutionContext ctx) throws ODPSConsoleException { if (cmd == null || ctx == null) { return null; } OfflineModelInfo modelInfo = CreateOfflineModelCommand.buildOfflineModelInfo(cmd, PATTERN, ctx); if (modelInfo == null) { return null; } return new CreateOfflineModelCommand(ctx.getProjectName(), modelInfo, cmd, ctx); } CreateOfflineModelCommand(String projectName,
                                   OfflineModelInfo modelInfo,
                                   String cmd,
                                   ExecutionContext ctx); static void printUsage(PrintStream stream); @Override void run(); static OfflineModelInfo buildOfflineModelInfo(
          String cmd, Pattern PATTERN, ExecutionContext ctx); static CreateOfflineModelCommand parse(String cmd, ExecutionContext ctx); static final String[] HELP_TAGS; }
@Test public void testCreateOfflineModelWithType() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create offlinemodel t_offlinemodel " + "-modelPath oss: "-type tensorflow " + "-version 1.0 " + "-configuration '{\"path\":\"abc/\"}'"; CreateOfflineModelCommand command = CreateOfflineModelCommand.parse(cmd, context); assertNotNull(command); }
@Test public void testCreateOfflineModelWithProcessor() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create offlinemodel t_offlinemodel " + "-modelPath oss: "-processor '[{\"id\":\"MnistProcessor\",\"libName\":\"libmnist_processor.so\"," + "\"refResource\":\"mnist_processor.tar.gz\",\"configuration\":\"\",\"runtime\":\"Native\"}]'"; CreateOfflineModelCommand command = CreateOfflineModelCommand.parse(cmd, context); assertNotNull(command); }
@Test public void testCreateOffLineModelWithBoth() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create offlinemodel t_offlinemodel " + "-modelPath oss: "-processor '[{\"id\":\"MnistProcessor\",\"libName\":\"libmnist_processor.so\"," + "\"refResource\":\"mnist_processor.tar.gz\",\"configuration\":\"\",\"runtime\":\"Native\"}]' " + "-type tensorflow " + "-version 1.0"; expectEx.expect(ODPSConsoleException.class); expectEx.expectMessage(ODPSConsoleConstants.BAD_COMMAND + "invalid parameter for offlinemodel, please HELP OFFLINEMODEL."); CreateOfflineModelCommand command = CreateOfflineModelCommand.parse(cmd, context); }
@Test public void testCreateOffineAmbiguousModelName() throws ODPSConsoleException, OdpsException { ExecutionContext context = ExecutionContext.init(); String cmd = "create offlinemodel t_offlinemodel t_offlinemodel2 " + "-modelPath oss: "-type tensorflow " + "-version 1.0"; expectEx.expect(ODPSConsoleException.class); expectEx.expectMessage(ODPSConsoleConstants.BAD_COMMAND + "Model name is ambiguous."); CreateOfflineModelCommand command = CreateOfflineModelCommand.parse(cmd, context); }