Skip to content

Commit 9de6d9a

Browse files
committed
update nodeschema and text2graph
1 parent aaf8cf3 commit 9de6d9a

File tree

2 files changed

+126
-109
lines changed

2 files changed

+126
-109
lines changed

muagent/schemas/ekg/ekg_graph.py

Lines changed: 26 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pydantic import BaseModel
22
from typing import List, Dict
33
from enum import Enum
4+
import copy
45
import json
56

67

@@ -19,6 +20,7 @@
1920
############################ Base Schema #############################
2021
#####################################################################
2122
class NodeSchema(BaseModel):
23+
type: str
2224
ID: int = None # depend on id-str
2325
id: str
2426
# depend on user's difine
@@ -27,20 +29,32 @@ class NodeSchema(BaseModel):
2729
description: str
2830
gdb_timestamp: int
2931

32+
def attributes(self, ):
33+
attrs = copy.deepcopy(vars(self))
34+
for k in ["ID", "type", "id"]:
35+
attrs.pop(k)
36+
attrs.update(json.loads(attrs.pop("extra", '{}') or '{}'))
37+
return attrs
3038

3139

3240
class EdgeSchema(BaseModel):
41+
type: str
3342
# entity_id, ekg_node:{graph_id}:{node_type}:{content_md5}
3443
SRCID: int = None
3544
original_src_id1__: str
3645
# entity_id, ekg_node:{graph_id}:{node_type}:{content_md5}
3746
DSTID: int = None
3847
original_dst_id2__: str
3948
#
40-
timestamp: int
49+
timestamp: int = None
4150
gdb_timestamp: int
4251

43-
52+
def attributes(self, ):
53+
attrs = copy.deepcopy(vars(self))
54+
for k in ["SRCID", "DSTID", "type", "timestamp", "original_src_id1__", "original_dst_id2__"]:
55+
attrs.pop(k)
56+
attrs.update(json.loads(attrs.pop("extra", '{}') or '{}'))
57+
return attrs
4458
#####################################################################
4559
############################ EKG Schema #############################
4660
#####################################################################
@@ -64,47 +78,20 @@ class EKGNodeSchema(NodeSchema):
6478
extra: str = ''
6579

6680

67-
6881
class EKGEdgeSchema(EdgeSchema):
6982
# teamids: str
7083
# version:str # yyyy-mm-dd HH:MM:SS
7184
extra: str = ''
7285

73-
def attrbutes(self, ):
74-
extra_attr = json.loads(self.extra)
75-
return extra_attr
76-
7786

7887
class EKGIntentNodeSchema(EKGNodeSchema):
79-
# path: str = ''
80-
81-
def attrbutes(self, ):
82-
extra_attr = json.loads(self.extra)
83-
return {
84-
**{
85-
"name": self.name,
86-
"description": self.description,
87-
"teamids": self.teamids,
88-
"path": self.path
89-
},
90-
**extra_attr
91-
}
88+
pass
89+
9290

9391
class EKGScheduleNodeSchema(EKGNodeSchema):
9492
# do action or not
9593
enable: bool
9694

97-
def attrbutes(self, ):
98-
extra_attr = json.loads(self.extra)
99-
return {
100-
**{
101-
"name": self.name,
102-
"description": self.description,
103-
"teamids": self.teamids,
104-
"enable": self.enable
105-
},
106-
**extra_attr
107-
}
10895

10996
class EKGTaskNodeSchema(EKGNodeSchema):
11097
# tool: str
@@ -114,20 +101,6 @@ class EKGTaskNodeSchema(EKGNodeSchema):
114101
executetype: str
115102
#
116103
# owner: str
117-
118-
def attrbutes(self, ):
119-
extra_attr = json.loads(self.extra)
120-
return {
121-
**{
122-
"name": self.name,
123-
"description": self.description,
124-
"teamids": self.teamids,
125-
"accesscriteria": self.accesscriteria,
126-
"executetype": self.executetype,
127-
# "tool": self.tool
128-
},
129-
**extra_attr
130-
}
131104

132105

133106
class EKGAnalysisNodeSchema(EKGNodeSchema):
@@ -138,33 +111,9 @@ class EKGAnalysisNodeSchema(EKGNodeSchema):
138111
# summary template
139112
dsltemplate: str
140113

141-
def attrbutes(self, ):
142-
extra_attr = json.loads(self.extra)
143-
return {
144-
**{
145-
"name": self.name,
146-
"description": self.description,
147-
"teamids": self.teamids,
148-
"accesscriteria": self.accesscriteria,
149-
"summaryswtich": self.summaryswtich,
150-
"dsltemplate": self.dsltemplate
151-
},
152-
**extra_attr
153-
}
154-
155114

156115
class EKGPhenomenonNodeSchema(EKGNodeSchema):
157-
158-
def attrbutes(self, ):
159-
extra_attr = json.loads(self.extra)
160-
return {
161-
**{
162-
"name": self.name,
163-
"description": self.description,
164-
"teamids": self.teamids,
165-
},
166-
**extra_attr
167-
}
116+
pass
168117

169118

170119
# Ekg Tool Schemas
@@ -196,13 +145,17 @@ class EKGGraphSlsSchema(BaseModel):
196145
# ADD/DELETE
197146
operation_type: str = ''
198147
# {tool_id},{tool_id},{tool_id}
199-
tool: str = ''
200-
access_criteria: str = ''
148+
executetype: str = ''
149+
accesscriteria: str = ''
201150
teamids: str = ''
202151
extra: str = ''
203152
enable: bool = False
204-
dslTemplate: str = ''
153+
dsltemplate: str = ''
154+
summaryswtich: bool = False
205155

156+
gdb_timestamp: int
157+
original_src_id1__: str = ""
158+
original_dst_id2__: str = ""
206159

207160
class EKGNodeTbaseSchema(BaseModel):
208161
node_id: str

0 commit comments

Comments
 (0)