|
1 | | -from typing import Any |
| 1 | +from typing import Any, List, Sequence |
2 | 2 |
|
3 | 3 | from arango.typings import Headers, Json |
4 | 4 |
|
@@ -1072,26 +1072,105 @@ def format_pregel_job_data(body: Json) -> Json: |
1072 | 1072 | """ |
1073 | 1073 | result: Json = {} |
1074 | 1074 |
|
1075 | | - if "aggregators" in body: |
1076 | | - result["aggregators"] = body["aggregators"] |
| 1075 | + if "id" in body: |
| 1076 | + result["id"] = body["id"] |
| 1077 | + if "algorithm" in body: |
| 1078 | + result["algorithm"] = body["algorithm"] |
| 1079 | + if "created" in body: |
| 1080 | + result["created"] = body["created"] |
| 1081 | + if "expires" in body: |
| 1082 | + result["expires"] = body["expires"] |
| 1083 | + if "ttl" in body: |
| 1084 | + result["ttl"] = body["ttl"] |
| 1085 | + if "algorithm" in body: |
| 1086 | + result["algorithm"] = body["algorithm"] |
| 1087 | + if "state" in body: |
| 1088 | + result["state"] = body["state"] |
| 1089 | + if "gss" in body: |
| 1090 | + result["gss"] = body["gss"] |
| 1091 | + if "totalRuntime" in body: |
| 1092 | + result["total_runtime"] = body["totalRuntime"] |
| 1093 | + if "startupTime" in body: |
| 1094 | + result["startup_time"] = body["startupTime"] |
1077 | 1095 | if "computationTime" in body: |
1078 | 1096 | result["computation_time"] = body["computationTime"] |
| 1097 | + if "storageTime" in body: |
| 1098 | + result["storageTime"] = body["storageTime"] |
| 1099 | + if "gssTimes" in body: |
| 1100 | + result["gssTimes"] = body["gssTimes"] |
| 1101 | + if "reports" in body: |
| 1102 | + result["reports"] = body["reports"] |
| 1103 | + if "vertexCount" in body: |
| 1104 | + result["vertex_count"] = body["vertexCount"] |
1079 | 1105 | if "edgeCount" in body: |
1080 | 1106 | result["edge_count"] = body["edgeCount"] |
1081 | | - if "gss" in body: |
1082 | | - result["gss"] = body["gss"] |
| 1107 | + |
| 1108 | + # The detail element was introduced in 3.10 |
| 1109 | + if "detail" in body: |
| 1110 | + d: Json = {} |
| 1111 | + detail = body["detail"] |
| 1112 | + if "workerStatus" in detail: |
| 1113 | + d["workerStatus"] = detail["workerStatus"] |
| 1114 | + if "aggregatedStatus" in detail: |
| 1115 | + aggregatedStatus = detail["aggregatedStatus"] |
| 1116 | + aStat: Json = {} |
| 1117 | + if "timeStamp" in aggregatedStatus: |
| 1118 | + aStat["timeStamp"] = aggregatedStatus["timeStamp"] |
| 1119 | + if "graphStoreStatus" in aggregatedStatus: |
| 1120 | + graphStoreStatus = aggregatedStatus["graphStoreStatus"] |
| 1121 | + gsStat: Json = {} |
| 1122 | + if "verticesLoaded" in graphStoreStatus: |
| 1123 | + gsStat["verticesLoaded"] = graphStoreStatus["verticesLoaded"] |
| 1124 | + if "edgesLoaded" in graphStoreStatus: |
| 1125 | + gsStat["edgesLoaded"] = graphStoreStatus["edgesLoaded"] |
| 1126 | + if "memoryBytesUsed" in graphStoreStatus: |
| 1127 | + gsStat["memoryBytesUsed"] = graphStoreStatus["memoryBytesUsed"] |
| 1128 | + if "verticesStored" in graphStoreStatus: |
| 1129 | + gsStat["verticesStored"] = graphStoreStatus["verticesStored"] |
| 1130 | + aStat["graphStoreStatus"] = gsStat |
| 1131 | + if "allGssStatus" in aggregatedStatus: |
| 1132 | + allGssStatus = aggregatedStatus["allGssStatus"] |
| 1133 | + agStat: Json = {} |
| 1134 | + if "items" in allGssStatus: |
| 1135 | + items = allGssStatus["items"] |
| 1136 | + itemList: List[Json] = [] |
| 1137 | + for i in items: |
| 1138 | + ri: Json = {} |
| 1139 | + if "verticesProcessed" in i: |
| 1140 | + ri["verticesProcessed"] = i["verticesProcessed"] |
| 1141 | + if "messagesSent" in i: |
| 1142 | + ri["messagesSent"] = i["messagesSent"] |
| 1143 | + if "messagesReceived" in i: |
| 1144 | + ri["messagesReceived"] = i["messagesReceived"] |
| 1145 | + if "memoryBytesUsedForMessages" in i: |
| 1146 | + ri["memoryBytesUsedForMessages"] = i[ |
| 1147 | + "memoryBytesUsedForMessages" |
| 1148 | + ] |
| 1149 | + itemList.append(ri) |
| 1150 | + agStat["items"] = itemList |
| 1151 | + aStat["allGssStatus"] = agStat |
| 1152 | + d[aggregatedStatus] = aStat |
| 1153 | + result["detail"] = d |
| 1154 | + |
| 1155 | + if "aggregators" in body: |
| 1156 | + result["aggregators"] = body["aggregators"] |
1083 | 1157 | if "receivedCount" in body: |
1084 | 1158 | result["received_count"] = body["receivedCount"] |
1085 | 1159 | if "sendCount" in body: |
1086 | 1160 | result["send_count"] = body["sendCount"] |
1087 | | - if "startupTime" in body: |
1088 | | - result["startup_time"] = body["startupTime"] |
1089 | | - if "state" in body: |
1090 | | - result["state"] = body["state"] |
1091 | | - if "totalRuntime" in body: |
1092 | | - result["total_runtime"] = body["totalRuntime"] |
1093 | | - if "vertexCount" in body: |
1094 | | - result["vertex_count"] = body["vertexCount"] |
| 1161 | + |
| 1162 | + return verify_format(body, result) |
| 1163 | + |
| 1164 | + |
| 1165 | +def format_pregel_job_list(body: Sequence[Json]) -> Json: |
| 1166 | + """Format Pregel job list data. |
| 1167 | +
|
| 1168 | + :param body: Input body. |
| 1169 | + :type body: dict |
| 1170 | + :return: Formatted body. |
| 1171 | + :rtype: dict |
| 1172 | + """ |
| 1173 | + result: Json = {"jobs": [format_pregel_job_data(j) for j in body]} |
1095 | 1174 |
|
1096 | 1175 | return verify_format(body, result) |
1097 | 1176 |
|
|
0 commit comments