Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highflip-editor:init and add access log aop for web api #5

Open
wants to merge 17 commits into
base: 1.0.0
Choose a base branch
from
Open
24 changes: 23 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,30 @@ jobs:
java-version: '11'
distribution: 'temurin'
cache: maven
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Build with Maven
run: mvn -B package --file pom.xml
run: mvn -B -Prelease -DskipTests package --file pom.xml
- name: Create release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "${{ github.workspace }}/target/*.jar"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to the Maven Central Repository
run: |
mvn clean \
--no-transfer-progress \
--batch-mode \
-Prelease \
-DskipTests \
deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
Expand Down
2 changes: 1 addition & 1 deletion highflip-clients/highflip-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.baidu</groupId>
<artifactId>highflip-proto</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public HighFlipClient() {
this.blockingStub = null;
}

public static HighFlipClient newHighFlipClient(String target) {
HighFlipClient highFlipClient = new HighFlipClient();
highFlipClient.connect(target);
return highFlipClient;
}

public void connect(String target) {
close();

Expand Down Expand Up @@ -578,4 +584,11 @@ public String createPartner(String name, String description){

return response.getPartnerId();
}

public Highflip.GetServiceConfigResponse getServiceConfig() {
final Highflip.GetServiceConfigResponse serviceConfig =
getBlockingStub().getServiceConfig(
Highflip.Void.getDefaultInstance());
return serviceConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.baidu.highflip.core.adaptor;

public interface ServiceAdaptor {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以考虑放到config中


String getUrl();

String getPartyId();

String getRole();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,16 @@ public class AdaptorPropsList {

public static final String PROPS_HIGHFLIP_ADAPTOR_PLATFORM_VERSION_DEFAULT = "0.0.0";

public static final String PROPS_HIGHFLIP_ADAPTOR_SERVICE_URL = "highflip.adaptor.service.url";

public static final String PROPS_HIGHFLIP_ADAPTOR_SERVICE_URL_DEFAULT = "http://127.0.0.1:9380";

public static final String PROPS_HIGHFLIP_ADAPTOR_SERVICE_PARTY_ID = "highflip.adaptor.service.party.id";

public static final String PROPS_HIGHFLIP_ADAPTOR_SERVICE_PARTY_ID_DEFAULT = "9999";

public static final String PROPS_HIGHFLIP_ADAPTOR_SERVICE_ROLE = "highflip.adaptor.service.role";

public static final String PROPS_HIGHFLIP_ADAPTOR_SERVICE_ROLE_DEFAULT = "guest";

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ public class InstanceNameList {
public static final String HIGHFLIP_ADAPTOR_PARTNER = "highflip.adaptor.partner";

public static final String HIGHFLIP_ADAPTOR_USER = "highflip.adaptor.user";

public static final String HIGHFLIP_ADAPTOR_SERVICE = "highflip.adaptor.service";

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ public interface HighFlipRuntime {
User getUser(String userId);

Operator getOperator(String operatorId);

Data registerData(Data data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.baidu.highflip.core.entity.dag.codec.AttributeMap;
import com.baidu.highflip.core.entity.dag.common.NamedAttributeObject;
import com.baidu.highflip.core.utils.ProtoUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

import highflip.HighflipMeta;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -96,7 +98,7 @@ public Iterable<String> listParties() {
return getParties().keySet();
}


@JsonIgnore
protected void setNodeCategory() {
calcMiddleNodes();
calcOutputNodes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
import com.baidu.highflip.core.entity.dag.common.NodeInputRef;
import com.baidu.highflip.core.entity.dag.common.NodeOutputRef;
import com.baidu.highflip.core.utils.ProtoUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

import highflip.HighflipMeta;
import lombok.Data;

import javax.persistence.Transient;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.springframework.data.annotation.Transient;

@Data
public class Node extends NamedAttributeObject implements Serializable {

Expand All @@ -25,7 +28,7 @@ public class Node extends NamedAttributeObject implements Serializable {

String description;

@Transient
@JsonIgnore
Graph graph;

Category category;
Expand Down Expand Up @@ -108,6 +111,7 @@ public Node getInputNode(String name) {
getInputs().get(name).getFromNode());
}

@JsonIgnore
public List<Node> getInputNodes() {
return getInputs()
.values()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.baidu.highflip.core.entity.dag.codec.AttributeMap;
import com.baidu.highflip.core.entity.dag.common.NamedAttributeObject;
import com.baidu.highflip.core.utils.ProtoUtils;

import highflip.HighflipMeta;
import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.baidu.highflip.core.entity.dag.codec;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.protobuf.ByteString;

import highflip.HighflipMeta;

public class TypeValue {
Expand All @@ -17,11 +24,76 @@ public static Object fromProto(HighflipMeta.TypedValueProto value) {
return value.getValue().getFloat();
} else if (typeValue == HighflipMeta.TypedValueProto.TypeProto.STRING.getNumber()) {
return value.getValue().getString();
} else if (typeValue == HighflipMeta.TypedValueProto.TypeProto.BYTES.getNumber()) {
return value.getValue().getBytes();
} else if (typeValue == HighflipMeta.TypedValueProto.TypeProto.LIST.getNumber()) {
return listProtoConvert2List(value.getValue().getList());
} else if (typeValue == HighflipMeta.TypedValueProto.TypeProto.MAP.getNumber()) {
return mapProtoConvert2Map(value.getValue().getMap());
} else {
throw new IllegalArgumentException();
}
}

private static List<Object> listProtoConvert2List(
HighflipMeta.ListProto listProto) {
if (listProto == null) {
return new ArrayList<>();
}
List<Object> result = new ArrayList<>();
List<HighflipMeta.ValueProto> listProtoList = listProto.getListList();
for (HighflipMeta.ValueProto valueProto : listProtoList) {
result.add(convertValueProto(valueProto));
}
return result;
}

private static Map<String, Object> mapProtoConvert2Map(HighflipMeta.MapProto mapProto) {
if (mapProto == null) {
return new HashMap<>();
}
Map<String, HighflipMeta.ValueProto> map = mapProto.getMapMap();
Map<String, Object> result = new HashMap<>();
for (Map.Entry<String, HighflipMeta.ValueProto> entry :
map.entrySet()) {
String key = entry.getKey();
HighflipMeta.ValueProto value = entry.getValue();
result.put(key, convertValueProto(value));
}
return result;
}

private static Object convertValueProto(HighflipMeta.ValueProto value) {
switch (value.getValueCase()) {
case BOOL:
return value.getBool();
case INT:
return value.getInt();
case LONG:
return value.getLong();
case FLOAT:
return value.getFloat();
case DOUBLE:
return value.getDouble();
case STRING:
return value.getString();
case BYTES:
return value.getBytes();
case LIST:
List<HighflipMeta.ValueProto> list =
value.getList().getListList();
List<Object> resultList = new ArrayList<>();
for(HighflipMeta.ValueProto listValue: list) {
resultList.add(convertValueProto(listValue));
}
return resultList;
case MAP:
return mapProtoConvert2Map(value.getMap());
default:
throw new RuntimeException("NOT_SUPPORTED_TYPE");
}
}

public static HighflipMeta.TypedValueProto toProto(Object object) {
HighflipMeta.TypedValueProto.Builder builder = HighflipMeta.TypedValueProto
.newBuilder();
Expand Down Expand Up @@ -56,14 +128,31 @@ public static HighflipMeta.TypedValueProto toProto(Object object) {
.newBuilder()
.setDouble((Double) object)
.build());
} else {
} else if (object instanceof String) {
builder.setType(HighflipMeta.TypedValueProto.TypeProto.STRING);
builder.setValue(HighflipMeta.ValueProto
.newBuilder()
.setString(object.toString())
.build());
} else if (object instanceof ByteString) {
builder.setType(HighflipMeta.TypedValueProto.TypeProto.BYTES);
builder.setValue(HighflipMeta.ValueProto
.newBuilder()
.setBytes((ByteString) object)
.build());
} else if (object instanceof HighflipMeta.ListProto) {
builder.setType(HighflipMeta.TypedValueProto.TypeProto.LIST);
builder.setValue(HighflipMeta.ValueProto
.newBuilder()
.setList((HighflipMeta.ListProto) object)
.build());
} else if (object instanceof HighflipMeta.MapProto) {
builder.setType(HighflipMeta.TypedValueProto.TypeProto.MAP);
builder.setValue(HighflipMeta.ValueProto
.newBuilder()
.setMap((HighflipMeta.MapProto) object)
.build());
}

return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import lombok.Data;

import javax.persistence.Transient;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.springframework.data.annotation.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Data
public class NamedAttributeObject implements Comparable<NamedAttributeObject> {

@Transient
@JsonIgnore
List<NamedAttributeObject> parents = List.of();

String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public class NodeInputRef {

String fromOutput;

String value;

public static HighflipMeta.NodeInputProto toProto(com.baidu.highflip.core.entity.dag.common.NodeInputRef ref) {
HighflipMeta.NodeInputProto.Builder builder = HighflipMeta.NodeInputProto
.newBuilder()
.setName(ref.getName())
.setFromNode(ref.getFromNode())
.setFromOutput(ref.getFromOutput());
.setFromOutput(ref.getFromOutput())
.setValue(ref.getValue());

ProtoUtils.setOptional(builder, "Description", ProtoUtils.ofString(ref.getDescription()));
return builder.build();
Expand All @@ -37,6 +40,7 @@ public static com.baidu.highflip.core.entity.dag.common.NodeInputRef fromProto(H
.setDescription(proto.getDescription())
.setFromNode(proto.getFromNode())
.setFromOutput(proto.getFromOutput())
.setValue(proto.getValue())
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ public class NodeOutputRef {

String description;

String value;

public static HighflipMeta.NodeOutputProto toProto(NodeOutputRef ref) {
HighflipMeta.NodeOutputProto.Builder builder = HighflipMeta.NodeOutputProto
.newBuilder()
.setName(ref.getName());
.setName(ref.getName())
.setValue(ref.getValue());

ProtoUtils.setOptional(builder, "Description", ProtoUtils.ofString(ref.getDescription()));
return builder.build();
Expand All @@ -29,6 +32,7 @@ public static NodeOutputRef fromProto(HighflipMeta.NodeOutputProto proto) {
.builder()
.setName(proto.getName())
.setDescription(proto.getDescription())
.setValue(proto.getValue())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
public class Data {

@Id
@Column(name = "data_id", length = 36)
@GenericGenerator(name = "id_gen", strategy = "uuid2")
@Column(name = "data_id", length = 72)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

长度是不是过长了

@GenericGenerator(name = "id_gen", strategy = "com.baidu.highflip.core.utils.CustomUuidGenerator")
@GeneratedValue(generator = "id_gen")
String dataId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Job {

@Id
@Column(name = "job_id", length = 36)
@GenericGenerator(name = "id_gen", strategy = "uuid2")
@GenericGenerator(name = "id_gen", strategy = "com.baidu.highflip.core.utils.CustomUuidGenerator")
@GeneratedValue(generator = "id_gen")
String jobId;

Expand All @@ -59,7 +59,7 @@ public class Job {
DateTime finishTime;

@Type(type = "json")
@Column(name = "graph")
@Column(name = "graph", length = 10240)
Graph graph;

@Column(name = "status")
Expand Down
Loading