From 505f72b6db564755180dd118ec051d85b1cce8a8 Mon Sep 17 00:00:00 2001
From: TingSty <615874106@qq.com>
Date: Tue, 8 Aug 2023 11:10:50 +0800
Subject: [PATCH] add highflip fate vendors
---
.../highflip-adaptor-fate/pom.xml | 58 ++-
.../webank/ai/fate/adaptor/DataAdaptor.java | 159 ++++++-
.../webank/ai/fate/adaptor/JobAdaptor.java | 129 ++++--
.../ai/fate/adaptor/OperatorAdaptor.java | 28 +-
.../webank/ai/fate/adaptor/TaskAdaptor.java | 84 +++-
.../com/webank/ai/fate/client/FateClient.java | 124 ++---
.../ai/fate/client/form/FateStatus.java | 45 ++
.../webank/ai/fate/client/form/data/Data.java | 21 +
.../ai/fate/client/form/data/DataId.java | 12 +
.../ai/fate/client/form/dsl/Component.java | 14 +
.../client/form/dsl/ComponentParameters.java | 17 +
.../ai/fate/client/form/dsl/Components.java | 12 +
.../webank/ai/fate/client/form/dsl/Dsl.java | 15 +
.../ai/fate/client/form/dsl/DslConf.java | 22 +
.../webank/ai/fate/client/form/dsl/Input.java | 23 +
.../ai/fate/client/form/dsl/Output.java | 21 +
.../ai/fate/client/form/dsl/RoleConf.java | 21 +
.../webank/ai/fate/client/form/dsl/Site.java | 12 +
.../form/job/Adaptation_parameters.java | 22 +
.../ai/fate/client/form/job/Common.java | 14 +
.../ai/fate/client/form/job/Components.java | 49 ++
.../ai/fate/client/form/job/Computing.java | 16 +
.../ai/fate/client/form/job/Dataio.java | 19 +
.../ai/fate/client/form/job/Eggroll_run.java | 9 +
.../fate/client/form/job/Engines_address.java | 18 +
.../ai/fate/client/form/job/FateJob.java | 133 ++++++
.../ai/fate/client/form/job/Federation.java | 16 +
.../form/job/Hetero_feature_binning.java | 19 +
.../webank/ai/fate/client/form/job/Input.java | 21 +
.../ai/fate/client/form/job/Intersection.java | 39 ++
.../ai/fate/client/form/job/JobData.java | 18 +
.../fate/client/form/job/Job_parameters.java | 50 ++
.../ai/fate/client/form/job/Output.java | 21 +
.../ai/fate/client/form/job/Pulsar_run.java | 9 +
.../ai/fate/client/form/job/QueryJob.java | 106 +++++
.../ai/fate/client/form/job/Rabbitmq_run.java | 9 +
.../ai/fate/client/form/job/Reader.java | 19 +
.../webank/ai/fate/client/form/job/Roles.java | 18 +
.../ai/fate/client/form/job/Runtime_conf.java | 34 ++
.../form/job/Runtime_conf_on_party.java | 33 ++
.../ai/fate/client/form/job/Spark_run.java | 9 +
.../ai/fate/client/form/job/Storage.java | 16 +
.../webank/ai/fate/client/form/job/Table.java | 17 +
.../client/form/job/Train_runtime_conf.java | 9 +
.../fate/client/form/job/Transform_param.java | 14 +
.../webank/ai/fate/client/form/job/User.java | 18 +
.../form/task/Adaptation_parameters.java | 14 +
.../ai/fate/client/form/task/Class_path.java | 16 +
.../ai/fate/client/form/task/Common.java | 28 ++
.../fate/client/form/task/ComponentParam.java | 31 ++
.../form/task/Component_parameters.java | 21 +
.../ai/fate/client/form/task/Eggroll_run.java | 7 +
.../fate/client/form/task/Encrypt_param.java | 13 +
.../ai/fate/client/form/task/Engine_conf.java | 12 +
.../client/form/task/Engines_address.java | 7 +
.../webank/ai/fate/client/form/task/Env.java | 11 +
.../ai/fate/client/form/task/FFateTask.java | 64 +++
.../ai/fate/client/form/task/FateTask.java | 69 +++
.../ai/fate/client/form/task/Initiator.java | 13 +
.../fate/client/form/task/Job_parameters.java | 12 +
.../ai/fate/client/form/task/Local.java | 13 +
.../form/task/Optimal_binning_param.java | 18 +
.../fate/client/form/task/Provider_info.java | 15 +
.../ai/fate/client/form/task/Pulsar_run.java | 7 +
.../fate/client/form/task/Rabbitmq_run.java | 7 +
.../webank/ai/fate/client/form/task/Role.java | 14 +
.../ai/fate/client/form/task/Spark_run.java | 7 +
.../ai/fate/client/form/task/TaskData.java | 14 +
.../client/form/task/Transform_param.java | 14 +
.../webank/ai/fate/common/ConfigConst.java | 7 +
.../ai/fate/common/DataMultipartFile.java | 76 +++
.../ai/fate/common/DecompressUtils.java | 39 ++
.../webank/ai/fate/common/FateConstants.java | 7 +
.../com/webank/ai/fate/common/GZIPUtils.java | 84 ++++
.../deserializer/FeignSpringFormEncoder.java | 255 ++++++++++
.../deserializer/JsonListDeserializer.java | 34 ++
.../JsonMapComponentsDeserializer.java | 36 ++
.../JsonMapListStringDeserializer.java | 38 ++
.../deserializer/JsonMapMapDeserializer.java | 44 ++
.../JsonMapMapObjectDeserializer.java | 38 ++
.../JsonMapMapStringDeserializer.java | 44 ++
.../JsonMapStringDeserializer.java | 33 ++
.../deserializer/JsonStringDeserializer.java | 23 +
.../common/deserializer/SerializerUtils.java | 416 +++++++++++++++++
.../webank/ai/fate/context/FateContext.java | 14 +-
.../ai/fate/translator/DSLTranslator.java | 352 +++++++++++++-
.../ai/fate/adaptor/DataAdaptorTest.java | 44 ++
.../webank/ai/fate/client/FateClientTest.java | 138 +++++-
.../ai/fate/translator/DSLTranslatorTest.java | 434 ++++++++++++++++++
89 files changed, 4070 insertions(+), 105 deletions(-)
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/FateStatus.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/data/Data.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/data/DataId.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/Component.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/ComponentParameters.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/Components.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/Dsl.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/DslConf.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/Input.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/Output.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/RoleConf.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/dsl/Site.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Adaptation_parameters.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Common.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Components.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Computing.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Dataio.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Eggroll_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Engines_address.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/FateJob.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Federation.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Hetero_feature_binning.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Input.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Intersection.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/JobData.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Job_parameters.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Output.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Pulsar_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/QueryJob.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Rabbitmq_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Reader.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Roles.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Runtime_conf.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Runtime_conf_on_party.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Spark_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Storage.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Table.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Train_runtime_conf.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/Transform_param.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/job/User.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Adaptation_parameters.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Class_path.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Common.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/ComponentParam.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Component_parameters.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Eggroll_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Encrypt_param.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Engine_conf.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Engines_address.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Env.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/FFateTask.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/FateTask.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Initiator.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Job_parameters.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Local.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Optimal_binning_param.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Provider_info.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Pulsar_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Rabbitmq_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Role.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Spark_run.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/TaskData.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/client/form/task/Transform_param.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/ConfigConst.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/DataMultipartFile.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/DecompressUtils.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/FateConstants.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/GZIPUtils.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/FeignSpringFormEncoder.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonListDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonMapComponentsDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonMapListStringDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonMapMapDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonMapMapObjectDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonMapMapStringDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonMapStringDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/JsonStringDeserializer.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/common/deserializer/SerializerUtils.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/test/java/com/webank/ai/fate/adaptor/DataAdaptorTest.java
create mode 100644 highflip-vendors/highflip-adaptor-fate/src/test/java/com/webank/ai/fate/translator/DSLTranslatorTest.java
diff --git a/highflip-vendors/highflip-adaptor-fate/pom.xml b/highflip-vendors/highflip-adaptor-fate/pom.xml
index 3fbcc3d..c6622a8 100644
--- a/highflip-vendors/highflip-adaptor-fate/pom.xml
+++ b/highflip-vendors/highflip-adaptor-fate/pom.xml
@@ -17,6 +17,16 @@
+
+ com.baidu.highflip
+ highflip-proto
+ 1.0.0-SNAPSHOT
+
+
+ com.baidu.highflip
+ highflip-core
+ 1.0.0-SNAPSHOT
+
org.junit.jupiter
junit-jupiter
@@ -30,21 +40,42 @@
test
- com.baidu.highflip
- highflip-core
- 1.0.0-SNAPSHOT
- compile
+ com.google.protobuf
+ protobuf-java
+ 3.21.1
io.github.openfeign
feign-core
11.10
+
+ org.slf4j
+ slf4j-api
+ 1.7.36
+
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.36
+
io.github.openfeign
feign-jackson
11.10
+
+ io.github.openfeign
+ feign-httpclient
+ 11.10
+
+
+
+ org.apache.commons
+ commons-compress
+ 1.21
+
@@ -54,6 +85,25 @@
maven-surefire-plugin
2.22.2
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.3.0
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
diff --git a/highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/adaptor/DataAdaptor.java b/highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/adaptor/DataAdaptor.java
index 52b367f..45952eb 100644
--- a/highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/adaptor/DataAdaptor.java
+++ b/highflip-vendors/highflip-adaptor-fate/src/main/java/com/webank/ai/fate/adaptor/DataAdaptor.java
@@ -1,10 +1,167 @@
package com.webank.ai.fate.adaptor;
+import static com.webank.ai.fate.common.FateConstants.DATA_ID_SEPARATOR;
+
+import com.baidu.highflip.core.entity.runtime.Data;
+import com.baidu.highflip.core.entity.runtime.basic.DataCategory;
+import com.baidu.highflip.core.entity.runtime.basic.KeyPair;
+import com.baidu.highflip.core.utils.Foreach;
+import com.webank.ai.fate.client.form.ResultForm;
+import com.webank.ai.fate.common.DataMultipartFile;
+import com.webank.ai.fate.common.DecompressUtils;
import com.webank.ai.fate.context.FateContext;
+import feign.Response;
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Getter
+public class DataAdaptor implements com.baidu.highflip.core.adaptor.DataAdaptor {
-public class DataAdaptor {
+ private final FateContext context;
+
+ private final String DEFAULT_NAMESPACES = "HIGH-FLIP";
+
+ private final String DEFAULT_DELIMITER = ",";
public DataAdaptor(FateContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public Data updateData(Data data) {
+ return null;
+ }
+
+ @Override
+ public int getDataCount() {
+ return 0;
+ }
+
+ @Override
+ public Data getDataByIndex(int index, Data data) {
+ return null;
+ }
+
+ @Override
+ public void deleteData(Data data) {
+ getContext().getClient().deleteData(data.getBingingId(), DEFAULT_NAMESPACES);
+ }
+
+ @Override
+ public InputStream readDataRaw(Data data) {
+ return null;
+ }
+
+ @Override
+ public Iterator> readDataDense(Data data) {
+ if(data == null) {
+ throw new RuntimeException("data is null.");
+ }
+ log.info("data:{}", data);
+
+ if (DataCategory.RESULT_DATA.equals(data.getCategory())) {
+ String jobId = (String) data.getBinding().get("jobId");
+ String componentName = (String) data.getBinding().get("componentName");
+ String role = (String) data.getBinding().get("role");
+ String partyId = (String) data.getBinding().get("partyId");
+ log.info("jobId: {}, componentName: {}, role: {}, partyId: {}",
+ jobId, componentName, role, partyId);
+
+ try (Response response = getContext().getClient()
+ .downloadComponentResultData(jobId, componentName,
+ role, partyId)) {
+ String content = DecompressUtils.decompressTarGzToStringMap(
+ response.body().asInputStream(),
+ s -> s.contains("csv")).get("data.csv");
+ return Arrays.stream(content.split("\n"))
+ .map(s -> Arrays.stream(s.split(DEFAULT_DELIMITER))
+ .map(d -> (Object) d)
+ .collect(Collectors.toList()))
+ .collect(Collectors.toList()).iterator();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ try (Response response = getContext().getClient()
+ .downloadData(data.getName(),
+ DEFAULT_NAMESPACES)) {
+ String content = DecompressUtils.decompressTarGzToStringMap(
+ response.body().asInputStream(),
+ s -> s.contains("csv")).get("table.csv");
+ return Arrays.stream(content.split("\n"))
+ .map(s -> Arrays.stream(s.split(DEFAULT_DELIMITER))
+ .map(d -> (Object) d)
+ .collect(Collectors.toList()))
+ .collect(Collectors.toList()).iterator();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ @Override
+ public Iterator> readDataSparse(Data data) {
+ return null;
+ }
+
+ @Override
+ public Data createData(Data data) {
+ return null;
+ }
+
+ @Override
+ public void writeDataRaw(Data data, InputStream body) {
+
+ }
+
+ @Override
+ public void writeDataDense(Data data, Iterator> body) {
+ StringBuilder stringBuilder = new StringBuilder();
+ try {
+ String headers =
+ data.getColumns().stream().map(c -> c.getName())
+ .collect(Collectors.joining(DEFAULT_DELIMITER));
+ stringBuilder.append(headers).append("\n");
+ final Foreach> foreach = Foreach.from(body);
+ for (List