Browse Source

新建版本时保存参数和指标为yaml

dev-lhz
chenzhihang 1 year ago
parent
commit
8a29722c2c
3 changed files with 16 additions and 9 deletions
  1. +8
    -5
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java
  2. +6
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java
  3. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ModelMetaVo.java

+ 8
- 5
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java View File

@@ -675,10 +675,6 @@ public class ModelsServiceImpl implements ModelsService {
String gitLinkUsername = loginUser.getSysUser().getGitLinkUsername();
String gitLinkPassword = loginUser.getSysUser().getGitLinkPassword();

// String ci4sUsername = "admin";
// String gitLinkUsername = "fanshuai";
// String gitLinkPassword = "h1n2x3j4y5@";

Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkUsername, gitLinkPassword);

String repositoryName = modelsVo.getIdentifier() == null ? ci4sUsername + "_model_" + DateUtils.dateTimeNow() : modelsVo.getIdentifier();
@@ -712,7 +708,7 @@ public class ModelsServiceImpl implements ModelsService {
dvcUtils.dvcCheckout(rootPath);
//干掉目标文件夹
dvcUtils.deleteDirectory(modelPath);
if (modelsVo.getModelVersionVos()!= null && modelsVo.getModelVersionVos().size() != 0) {
if (modelsVo.getModelVersionVos() != null && modelsVo.getModelVersionVos().size() != 0) {
String sourcePath = modelsVo.getModelVersionVos().get(0).getUrl();

if (Constant.Source_Export.equals(modelsVo.getModelSource())) {
@@ -750,6 +746,13 @@ public class ModelsServiceImpl implements ModelsService {
YamlUtils.generateYamlFile(metaMap, metaPath, "metadata");
String meta = JSON.toJSONString(modelMetaVo);

//保存指标
Map<String, Object> metrics = modelMetaVo.getMetrics();
YamlUtils.generateYamlFile(metrics, rootPath, "metrics");
//保存参数
Map<String, Object> params = modelMetaVo.getParams();
YamlUtils.generateYamlFile(params, rootPath, "params");

//保存模型依赖
modelDependency.setRepoId(modelsVo.getId());
modelDependency.setIdentifier(repositoryName);


+ 6
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java View File

@@ -1,8 +1,10 @@
package com.ruoyi.platform.utils;

import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.util.Iterator;
import java.util.Map;

public class YamlUtils {
@@ -15,8 +17,10 @@ public class YamlUtils {
* @param fileName 文件名
*/
public static void generateYamlFile(Map<String, Object> data, String path, String fileName) {
Yaml yaml = new Yaml();

DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true);
Yaml yaml = new Yaml(options);
File directory = new File(path);
if (!directory.exists()) {
boolean isCreated = directory.mkdirs();


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ModelMetaVo.java View File

@@ -54,10 +54,10 @@ public class ModelMetaVo implements Serializable {
private List<NewDatasetVo> testDatasets;

@ApiModelProperty(value = "参数")
private HashMap<String, String> params;
private HashMap<String, Object> params;

@ApiModelProperty(value = "指标")
private HashMap<String, String> metrics;
private HashMap<String, Object> metrics;

@ApiModelProperty(value = "训练任务")
private TrainTaskDepency trainTask;


Loading…
Cancel
Save