|
|
|
@ -5,7 +5,7 @@ import cn.hutool.core.collection.ListUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.supervision.model.RasaModelInfo;
|
|
|
|
|
import com.supervision.rasa.config.ThreadPoolExecutorConfig;
|
|
|
|
|
import com.supervision.rasa.pojo.vo.RasaArgumentVo;
|
|
|
|
|
import com.supervision.rasa.pojo.vo.RasaCmdArgumentVo;
|
|
|
|
|
import com.supervision.rasa.service.RasaCmdService;
|
|
|
|
|
import com.supervision.rasa.util.PortUtil;
|
|
|
|
|
import com.supervision.service.RasaModeService;
|
|
|
|
@ -59,7 +59,7 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public String trainExec(RasaArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
|
|
|
|
|
public String trainExec(RasaCmdArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
|
|
|
|
|
|
|
|
|
|
String domain = dataPath+"domain.yml";
|
|
|
|
|
List<String> cmds = ListUtil.toList(shellEnv, trainShell,config,dataPath,domain,modelsPath);
|
|
|
|
@ -82,24 +82,16 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String runExec(RasaArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 查找模型信息是否为空
|
|
|
|
|
RasaModelInfo dbRasaModelInfo = rasaModeService.queryByModelId(argument.getModelId());
|
|
|
|
|
int unusedPort;
|
|
|
|
|
if (null == dbRasaModelInfo || null == dbRasaModelInfo.getPort()){
|
|
|
|
|
unusedPort = PortUtil.findUnusedPort(5050, 100000);
|
|
|
|
|
log.info("runExec findUnusedPort is : {}",unusedPort);
|
|
|
|
|
argument.setPort(String.valueOf(unusedPort));
|
|
|
|
|
}else {
|
|
|
|
|
argument.setPort(String.valueOf(dbRasaModelInfo.getPort()));
|
|
|
|
|
// todo:杀掉该端口对应的进程
|
|
|
|
|
}
|
|
|
|
|
public String runExec(RasaCmdArgumentVo argument) throws ExecutionException, InterruptedException, TimeoutException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 查找可用端口
|
|
|
|
|
int port = PortUtil.findUnusedPort(5050, 100000,rasaModeService.listActivePort());
|
|
|
|
|
log.info("runExec findUnusedPort is : {}",port);
|
|
|
|
|
|
|
|
|
|
// 2. 运行模型
|
|
|
|
|
String mPath = modelsPath+argument.getFixedModelName()+".tar.gz";
|
|
|
|
|
List<String> cmds = ListUtil.toList(shellEnv, runShell,mPath,endpoints,argument.getPort());
|
|
|
|
|
List<String> cmds = ListUtil.toList(shellEnv, runShell,mPath,endpoints,String.valueOf(port));
|
|
|
|
|
|
|
|
|
|
log.info("runExec cmd : {}",StrUtil.join(" ",cmds));
|
|
|
|
|
|
|
|
|
@ -108,7 +100,7 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
// 3. 更新模型信息
|
|
|
|
|
RasaModelInfo rasaModelInfo = new RasaModelInfo();
|
|
|
|
|
rasaModelInfo.setModelId(argument.getModelId());
|
|
|
|
|
rasaModelInfo.setPort(0);
|
|
|
|
|
rasaModelInfo.setPort(port);
|
|
|
|
|
rasaModelInfo.setServerStatus(runIsSuccess(outMessageList)?1:0);
|
|
|
|
|
rasaModeService.saveOrUpdateByModelId(rasaModelInfo);
|
|
|
|
|
|
|
|
|
@ -147,7 +139,7 @@ public class RasaCmdServiceImpl implements RasaCmdService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bufferedReader.close();
|
|
|
|
|
return outString;
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return future.get(timeOut, TimeUnit.SECONDS);
|
|
|
|
|