|
|
|
@ -61,12 +61,14 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
public String trainExec(RasaCmdArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
|
|
|
|
|
|
|
|
|
|
// /rasa/v3_jiazhuangxian/domain.yml domain的路径,应该是从zip文件中加压出来的文件的路径后面拼上/domain.yml
|
|
|
|
|
|
|
|
|
|
String domain = replaceDuplicateSeparator(String.join(File.separator,dataPath,argument.getModelId(),"domain.yml"));
|
|
|
|
|
|
|
|
|
|
// /rasa/v3_jiazhuangxian/ yml文件的路径,应该是从zip文件中加压出来的文件的路径,在配置文件中配置
|
|
|
|
|
String localDataPath = replaceDuplicateSeparator(String.join(File.separator,dataPath,argument.getModelId()));
|
|
|
|
|
|
|
|
|
|
// /rasa/models 生成出来的模型的存放路径,也写在配置文件里面
|
|
|
|
|
String localModelsPath = replaceDuplicateSeparator(String.join(File.separator,modelsPath,argument.getModelId()));
|
|
|
|
|
|
|
|
|
|
List<String> cmds = ListUtil.toList(shellEnv, trainShell,config,localDataPath,domain,localModelsPath);
|
|
|
|
|
|
|
|
|
|
cmds.add(argument.getFixedModelName());
|
|
|
|
@ -75,14 +77,17 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
|
|
|
|
|
List<String> outMessage = execCmd(cmds, s -> StrUtil.isNotBlank(s) && s.contains(RasaConstant.TRAN_SUCCESS_MESSAGE), 300);
|
|
|
|
|
|
|
|
|
|
String outMessageString = String.join("\r\n", outMessage);
|
|
|
|
|
//保存 模型信息
|
|
|
|
|
RasaModelInfo rasaModelInfo = new RasaModelInfo();
|
|
|
|
|
rasaModelInfo.setModelId(argument.getModelId());
|
|
|
|
|
rasaModelInfo.setTranStatus(trainIsSuccess(outMessage)?1:0);
|
|
|
|
|
rasaModelInfo.setServerStatus(-1);
|
|
|
|
|
rasaModelInfo.setTrainCmd(cmds);
|
|
|
|
|
rasaModelInfo.setTrainLog(outMessageString);
|
|
|
|
|
rasaModeService.saveOrUpdateByModelId(rasaModelInfo);
|
|
|
|
|
|
|
|
|
|
return String.join("\r\n",outMessage);
|
|
|
|
|
return outMessageString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,21 +104,24 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
// 2.1 -m 参数对应的值 /rasa/models/aaa1111.tar.gz 指run的模型的路径,/rasa/models应该来自于配置文件,和训练时的--out是同一配置项;
|
|
|
|
|
// aaa1111.tar.gz这个,前面的文件名应该是--fixed-model-name指定的,.tar.gz是文件后缀,代码拼接
|
|
|
|
|
String localPath = replaceDuplicateSeparator(String.join(File.separator,modelsPath,argument.getModelId(),argument.getFixedModelName()+".tar.gz"));
|
|
|
|
|
|
|
|
|
|
List<String> cmds = ListUtil.toList(shellEnv, runShell,localPath,endpoints,String.valueOf(port));
|
|
|
|
|
|
|
|
|
|
log.info("runExec cmd : {}",StrUtil.join(" ",cmds));
|
|
|
|
|
|
|
|
|
|
List<String> outMessageList = execCmd(cmds, s -> StrUtil.isNotBlank(s) && s.contains(RasaConstant.RUN_SUCCESS_MESSAGE), 300);
|
|
|
|
|
|
|
|
|
|
String outMessageString = String.join("\r\n", outMessageList);
|
|
|
|
|
// 3. 更新模型信息
|
|
|
|
|
RasaModelInfo rasaModelInfo = new RasaModelInfo();
|
|
|
|
|
rasaModelInfo.setModelId(argument.getModelId());
|
|
|
|
|
rasaModelInfo.setPort(port);
|
|
|
|
|
rasaModelInfo.setServerStatus(runIsSuccess(outMessageList)?1:0);
|
|
|
|
|
rasaModelInfo.setCmd(ListUtil.toList(shellEnv, runShell,localPath,endpoints));
|
|
|
|
|
rasaModelInfo.setRunCmd(ListUtil.toList(shellEnv, runShell,localPath,endpoints));
|
|
|
|
|
rasaModelInfo.setRunLog(outMessageString);
|
|
|
|
|
rasaModeService.saveOrUpdateByModelId(rasaModelInfo);
|
|
|
|
|
|
|
|
|
|
return String.join("\r\n",outMessageList);
|
|
|
|
|
return outMessageString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|