|
|
|
@ -50,7 +50,7 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
@Value("${rasa.run-shell}")
|
|
|
|
|
private String runShell;
|
|
|
|
|
|
|
|
|
|
@Value("${rasa.shell.work:/home/rasa_manage/}")
|
|
|
|
|
@Value("${rasa.shell.work:/data/vp/rasa_shell/}")
|
|
|
|
|
private String shellWork;
|
|
|
|
|
|
|
|
|
|
private final RasaModeService rasaModeService;
|
|
|
|
@ -61,11 +61,12 @@ 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 = String.join(File.separator,dataPath,argument.getModelId(),"domain.yml");
|
|
|
|
|
|
|
|
|
|
String domain = replaceDuplicateSeparator(String.join(File.separator,dataPath,argument.getModelId(),"domain.yml"));
|
|
|
|
|
// /rasa/v3_jiazhuangxian/ yml文件的路径,应该是从zip文件中加压出来的文件的路径,在配置文件中配置
|
|
|
|
|
String localDataPath = String.join(File.separator,dataPath,argument.getModelId());
|
|
|
|
|
String localDataPath = replaceDuplicateSeparator(String.join(File.separator,dataPath,argument.getModelId()));
|
|
|
|
|
// /rasa/models 生成出来的模型的存放路径,也写在配置文件里面
|
|
|
|
|
String localModelsPath = String.join(File.separator,modelsPath,argument.getModelId());
|
|
|
|
|
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());
|
|
|
|
@ -97,7 +98,7 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
// 2. 运行模型
|
|
|
|
|
// 2.1 -m 参数对应的值 /rasa/models/aaa1111.tar.gz 指run的模型的路径,/rasa/models应该来自于配置文件,和训练时的--out是同一配置项;
|
|
|
|
|
// aaa1111.tar.gz这个,前面的文件名应该是--fixed-model-name指定的,.tar.gz是文件后缀,代码拼接
|
|
|
|
|
String localPath = String.join(File.separator,modelsPath,argument.getModelId(),argument.getFixedModelName(),".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));
|
|
|
|
@ -115,14 +116,6 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
return String.join("\r\n",outMessageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void test() {
|
|
|
|
|
RasaModelInfo rasaModelInfo = new RasaModelInfo();
|
|
|
|
|
rasaModelInfo.setId("1");
|
|
|
|
|
rasaModelInfo.setModelId("1");
|
|
|
|
|
rasaModelInfo.setTranStatus(1);
|
|
|
|
|
rasaModeService.saveOrUpdate(rasaModelInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<String> execCmd(List<String> cmds, Predicate<String> endPredicate, long timeOut) throws InterruptedException, ExecutionException, TimeoutException {
|
|
|
|
@ -178,4 +171,13 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
return messageList.stream().anyMatch(s->StrUtil.isNotEmpty(s) && s.contains(keyWord));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String replaceDuplicateSeparator(String path){
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(path)){
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path.replace(File.separator + File.separator, File.separator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|