MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _determine_start_nodes

Method _determine_start_nodes

workflow/graph_manager.py:273–319  ·  view source on GitHub ↗

Determine the effective set of start nodes (explicit only).

(self)

Source from the content-addressed store, hash-verified

271 }
272
273 def _determine_start_nodes(self) -> None:
274 """Determine the effective set of start nodes (explicit only)."""
275 definition = self.graph.config.definition
276 explicit_ordered = list(definition.start_nodes)
277 explicit_set = set(explicit_ordered)
278
279 # if explicit_ordered and not self.graph.has_cycles:
280 # raise ConfigError(
281 # "start nodes can only be specified for graphs that contain cycles",
282 # extend_path(definition.path, "start"),
283 # )
284
285 if explicit_set:
286 cycle_path = extend_path(definition.path, "start")
287 for node_id in explicit_ordered:
288 if node_id not in self.graph.nodes:
289 raise ConfigError(
290 f"start node '{node_id}' not defined in nodes",
291 cycle_path,
292 )
293
294 cycle_id = self.cycle_manager.node_to_cycle.get(node_id)
295 if cycle_id is None:
296 continue
297 cycle_info = self.cycle_manager.cycles.get(cycle_id)
298 if cycle_info is None:
299 raise ConfigError(
300 f"cycle data missing for start node '{node_id}'",
301 cycle_path,
302 )
303
304 if cycle_info.configured_entry_node and cycle_info.configured_entry_node != node_id:
305 raise ConfigError(
306 f"cycle '{cycle_id}' already has start node '{cycle_info.configured_entry_node}'",
307 cycle_path,
308 )
309
310 cycle_info.configured_entry_node = node_id
311
312 if not explicit_ordered:
313 raise ConfigError(
314 "Unable to determine a start node for this graph. Configure at least one Start Node via Configure Graph > Advanced Settings > Start Node > input node ID.",
315 extend_path(definition.path, "start"),
316 )
317
318 self.graph.start_nodes = explicit_ordered
319 self.graph.explicit_start_nodes = explicit_ordered
320
321 def _warn_on_untriggerable_nodes(self) -> None:
322 """Emit warnings for nodes that cannot be triggered by any predecessor."""

Callers 1

build_graph_structureMethod · 0.95

Calls 3

extend_pathFunction · 0.90
ConfigErrorClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected