MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / run

Method run

KVCOMM/graph/graph.py:213–259  ·  view source on GitHub ↗

Execute nodes topologically for `num_rounds` and return final answers.

(
        self,
        inputs: Any,
        num_rounds:int = 1,
        max_tries: int = 3,
        max_time: int = 600,
    )

Source from the content-addressed store, hash-verified

211 out_node.add_successor(in_node,'temporal')
212
213 def run(
214 self,
215 inputs: Any,
216 num_rounds:int = 1,
217 max_tries: int = 3,
218 max_time: int = 600,
219 ) -> List[Any]:
220 """Execute nodes topologically for `num_rounds` and return final answers."""
221 for round in range(num_rounds):
222 self.construct_spatial_connection()
223 self.construct_temporal_connection(round)
224
225 in_degree = {node_id: len(node.spatial_predecessors) for node_id, node in self.nodes.items()}
226 zero_in_degree_queue = [node_id for node_id, deg in in_degree.items() if deg == 0]
227
228 while zero_in_degree_queue:
229 current_node_id = zero_in_degree_queue.pop(0)
230 tries = 0
231 while tries < max_tries:
232 try:
233 self.nodes[current_node_id].execute(inputs)
234 break
235 except Exception as e:
236 logger.exception(
237 "Error during execution of node {}: {}",
238 current_node_id,
239 e,
240 )
241 tries += 1
242 for successor in self.nodes[current_node_id].spatial_successors:
243 if successor.id not in self.nodes.keys():
244 continue
245 in_degree[successor.id] -= 1
246 if in_degree[successor.id] == 0:
247 zero_in_degree_queue.append(successor.id)
248
249 self.update_memory()
250 if self.decision_node:
251 self.connect_decision_node()
252 self.decision_node.execute(inputs)
253 final_answers = self.decision_node.outputs
254 if len(final_answers) == 0:
255 final_answers.append("No answer of the decision node")
256 else:
257 final_answers = self.nodes[list(self.nodes.keys())[-1]].outputs
258
259 return final_answers
260
261 async def arun(
262 self,

Callers 10

_executeMethod · 0.45
_executeMethod · 0.45
_executeMethod · 0.45
_executeMethod · 0.45
_executeMethod · 0.45
_executeMethod · 0.45
run_humaneval.pyFile · 0.45
run_mmlu.pyFile · 0.45
benchmark_TTFT.pyFile · 0.45
run_gsm8k.pyFile · 0.45

Calls 8

update_memoryMethod · 0.95
connect_decision_nodeMethod · 0.95
itemsMethod · 0.80
popMethod · 0.80
executeMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected