Browse Source

优化yaml导出测试

dev-lhz
chenzhihang 1 year ago
parent
commit
57f30f5e05
2 changed files with 2 additions and 21 deletions
  1. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  2. +1
    -20
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/YamlUtils.java

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java View File

@@ -534,7 +534,7 @@ public class ExperimentServiceImpl implements ExperimentService {
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i); JSONObject jsonObject = jsonArray.getJSONObject(i);
String paramName = jsonObject.getString("param_name"); String paramName = jsonObject.getString("param_name");
String paramValue = jsonObject.getString("param_value");
Object paramValue = jsonObject.get("param_value");
trainParam.put(paramName, paramValue); trainParam.put(paramName, paramValue);
} }
modelMetaVo.setParams(trainParam); modelMetaVo.setParams(trainParam);


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

@@ -23,28 +23,9 @@ public class YamlUtils {
DumperOptions options = new DumperOptions(); DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
options.setPrettyFlow(false);

Representer representer = new Representer() {
{
// 重写字符串表示方法
representers.put(String.class, new Represent() {
public Node representData(Object data) {
return representScalar(Tag.STR, (String) data, null);
}
});
}
};

// 去掉引号时使用PLAIN样式
representer.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);


// 创建Yaml实例 // 创建Yaml实例
Yaml yaml = new Yaml(representer, options);

String dump = yaml.dump(data);

// Yaml yaml = new Yaml(options);
Yaml yaml = new Yaml(options);


File directory = new File(path); File directory = new File(path);
if (!directory.exists()) { if (!directory.exists()) {


Loading…
Cancel
Save