|
@@ -15,18 +15,22 @@ import com.taais.biz.domain.vo.AlgorithmDataProcessVo;
|
|
|
import com.taais.biz.domain.vo.AlgorithmSubtaskVo;
|
|
|
import com.taais.biz.mapper.AlgorithmSubtaskMapper;
|
|
|
import com.taais.biz.service.*;
|
|
|
+import com.taais.common.core.constant.Constants;
|
|
|
import com.taais.common.core.core.page.PageResult;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.core.utils.StringUtils;
|
|
|
-import com.taais.common.core.utils.http.HttpUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
|
import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
+import com.taais.system.domain.vo.SysOssVo;
|
|
|
+import com.taais.system.service.ISysOssService;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.reactive.function.client.WebClient;
|
|
|
+import reactor.core.publisher.Mono;
|
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.util.*;
|
|
@@ -44,6 +48,8 @@ public class AlgorithmSubtaskServiceImpl extends BaseServiceImpl<AlgorithmSubtas
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(AlgorithmSubtaskServiceImpl.class);
|
|
|
@Resource
|
|
|
+ private WebClient.Builder webClientBuilder;
|
|
|
+ @Resource
|
|
|
private AlgorithmSubtaskMapper algorithmSubtaskMapper;
|
|
|
@Resource
|
|
|
private IAlgorithmDataSetService dataSetService;
|
|
@@ -55,6 +61,8 @@ public class AlgorithmSubtaskServiceImpl extends BaseServiceImpl<AlgorithmSubtas
|
|
|
private IAlgorithmConfigService algorithmConfigService;
|
|
|
@Resource
|
|
|
private IAlgorithmModelService modelService;
|
|
|
+ @Resource
|
|
|
+ private ISysOssService ossService;
|
|
|
|
|
|
@Override
|
|
|
public QueryWrapper query() {
|
|
@@ -227,17 +235,22 @@ public class AlgorithmSubtaskServiceImpl extends BaseServiceImpl<AlgorithmSubtas
|
|
|
if (StringUtils.isNotEmpty(parameters)) {
|
|
|
List<AlgorithmConfigParamDto> paramDtoList = gson.fromJson(parameters, listType);
|
|
|
Map<String, Object> otherParams = new HashMap<>(paramDtoList.size());
|
|
|
- // todo allen 模型没加载进去
|
|
|
if (model == null) {
|
|
|
log.error("模型配置未找到!!!modelId:{}", modelId);
|
|
|
errorMsg.add("模型配置未找到!!!");
|
|
|
} else {
|
|
|
- otherParams.put("pretrained_model", model.getModelAddress());
|
|
|
+ SysOssVo modelOss = ossService.getById(Long.valueOf(model.getModelAddress()));
|
|
|
+ otherParams.put("pretrained_model", BizConstant.DOCKER_BASE_PATH + StringUtils.substringAfter(modelOss.getFileName(), Constants.RESOURCE_PREFIX));
|
|
|
+ // 找到训练的模型地址
|
|
|
+ String trainModelPath = mapper.getTrainModelPath(bizProcessVo.getId(), bizProcessVo.getAlgorithmId());
|
|
|
+ if (StringUtils.isNotEmpty(trainModelPath)){
|
|
|
+ otherParams.put("weight_path", BizConstant.DOCKER_BASE_PATH + trainModelPath + BizConstant.DOCKER_PT_PATH);
|
|
|
+ }
|
|
|
}
|
|
|
for (AlgorithmConfigParamDto algorithmConfigParamDto : paramDtoList) {
|
|
|
String value = StringUtils.isNotEmpty(algorithmConfigParamDto.getValue()) ? algorithmConfigParamDto.getValue() : algorithmConfigParamDto.getDefaultValue();
|
|
|
- if(NumberUtils.isDigits(value)){
|
|
|
- otherParams.put(algorithmConfigParamDto.getAgName(), NumberUtils.createFloat(value));
|
|
|
+ if(NumberUtils.isCreatable(value)){
|
|
|
+ otherParams.put(algorithmConfigParamDto.getAgName(), NumberUtils.createNumber(value));
|
|
|
} else {
|
|
|
otherParams.put(algorithmConfigParamDto.getAgName(), value);
|
|
|
}
|
|
@@ -248,7 +261,13 @@ public class AlgorithmSubtaskServiceImpl extends BaseServiceImpl<AlgorithmSubtas
|
|
|
if (StringUtils.isEmpty(url)) {
|
|
|
errorMsg.add("url是空!!!");
|
|
|
} else {
|
|
|
- httpResult = HttpUtils.sendPost(url, gson.toJson(algorithmRequestDto));
|
|
|
+ WebClient webClient = webClientBuilder.build();
|
|
|
+ Mono<String> response = webClient.post()
|
|
|
+ .uri(url)
|
|
|
+ .bodyValue(algorithmRequestDto)
|
|
|
+ .retrieve()
|
|
|
+ .bodyToMono(String.class);
|
|
|
+ httpResult = response.block();
|
|
|
}
|
|
|
// process httpResult
|
|
|
log.info("httpResult:{}", httpResult);
|
|
@@ -311,7 +330,14 @@ public class AlgorithmSubtaskServiceImpl extends BaseServiceImpl<AlgorithmSubtas
|
|
|
if (StringUtils.isEmpty(url)) {
|
|
|
errorMsg.add("url是空!!!");
|
|
|
} else {
|
|
|
- httpResult = HttpUtils.sendPost(url, gson.toJson(algorithmRequestDto));
|
|
|
+// httpResult = HttpUtils.sendPost(url, gson.toJson(algorithmRequestDto));
|
|
|
+ WebClient webClient = webClientBuilder.build();
|
|
|
+ Mono<String> response = webClient.post()
|
|
|
+ .uri(url)
|
|
|
+ .bodyValue(algorithmRequestDto)
|
|
|
+ .retrieve()
|
|
|
+ .bodyToMono(String.class);
|
|
|
+ httpResult = response.block();
|
|
|
}
|
|
|
// process httpResult
|
|
|
log.info("httpResult:{}", httpResult);
|