Decode an edge and create a link between source and destination nodes. Args: outputs: List of output dictionaries from source node inputs: List of input dictionaries from destination node candidate_inputs: List of candidate inputs that can be added link_coun
(
outputs: list[dict],
inputs: list[dict],
candidate_inputs: list[dict],
link_count: int,
src_id: int,
dst_id: int,
output_name: str,
input_name: str,
dst_node_type: str = None,
)
| 348 | |
| 349 | |
| 350 | def decode_edge( |
| 351 | outputs: list[dict], |
| 352 | inputs: list[dict], |
| 353 | candidate_inputs: list[dict], |
| 354 | link_count: int, |
| 355 | src_id: int, |
| 356 | dst_id: int, |
| 357 | output_name: str, |
| 358 | input_name: str, |
| 359 | dst_node_type: str = None, |
| 360 | ) -> tuple[list[dict], list[dict], list, int]: |
| 361 | """ |
| 362 | Decode an edge and create a link between source and destination nodes. |
| 363 | |
| 364 | Args: |
| 365 | outputs: List of output dictionaries from source node |
| 366 | inputs: List of input dictionaries from destination node |
| 367 | candidate_inputs: List of candidate inputs that can be added |
| 368 | link_count: Current link count |
| 369 | src_id: Source node ID |
| 370 | dst_id: Destination node ID |
| 371 | output_name: Name of the output port |
| 372 | input_name: Name of the input port |
| 373 | |
| 374 | Returns: |
| 375 | Tuple of (updated outputs, updated inputs, link, link_count) |
| 376 | """ |
| 377 | output_names = get_output_info(outputs) |
| 378 | |
| 379 | if output_name not in output_names: |
| 380 | raise NAME_EXCEPTION(f"Output name '{output_name}' not found") |
| 381 | |
| 382 | src_port = output_names[output_name] |
| 383 | output = outputs[src_port] |
| 384 | |
| 385 | links = output.get("links", []) |
| 386 | links.append(link_count) |
| 387 | output["links"] = links |
| 388 | outputs[src_port] = output |
| 389 | |
| 390 | input = None |
| 391 | dst_port = None |
| 392 | |
| 393 | for i, _input in enumerate(inputs): |
| 394 | if _input.get("name") == input_name: |
| 395 | input = _input |
| 396 | input["link"] = link_count |
| 397 | dst_port = i |
| 398 | break |
| 399 | |
| 400 | # If not found, try candidate inputs |
| 401 | if input is None: |
| 402 | for _input in candidate_inputs: |
| 403 | if _input.get("name") == input_name: |
| 404 | input = { |
| 405 | "name": input_name, |
| 406 | "type": _input["type"], |
| 407 | "link": link_count, |
no test coverage detected