@@ -347,9 +347,12 @@ def get_input_index(block: Block, edge: dict, block_to_input_index: dict) -> int
347347 Returns:
348348 The input index for the block.
349349 """
350- if hasattr (block , "name_to_input_port" ):
351- return block .name_to_input_port [edge ["targetHandle" ]]
352- elif isinstance (block , Function ):
350+
351+ if edge ["targetHandle" ] is not None :
352+ if block ._port_map_in :
353+ return block ._port_map_in [edge ["targetHandle" ]]
354+
355+ if isinstance (block , Function ):
353356 return int (edge ["targetHandle" ].replace ("target-" , "" ))
354357 else :
355358 # make sure that the target block has only one input port (ie. that targetHandle is None)
@@ -372,9 +375,11 @@ def get_output_index(block: Block, edge: dict) -> int:
372375 Returns:
373376 The output index for the block.
374377 """
375- if hasattr (block , "name_to_output_port" ):
376- return block .name_to_output_port [edge ["sourceHandle" ]]
377- elif isinstance (block , Splitter ):
378+ if edge ["sourceHandle" ] is not None :
379+ if block ._port_map_out :
380+ return block ._port_map_out [edge ["sourceHandle" ]]
381+
382+ if isinstance (block , Splitter ):
378383 # Splitter outputs are always in order, so we can use the handle directly
379384 assert edge ["sourceHandle" ], edge
380385 output_index = int (edge ["sourceHandle" ].replace ("source" , "" )) - 1
@@ -428,7 +433,7 @@ def make_connections(nodes, edges, blocks) -> list[Connection]:
428433 if edge ["sourceHandle" ]:
429434 label += f" ({ edge ['sourceHandle' ]} )"
430435 target_block .labels .append (label )
431-
436+ print ( f"Connecting { source_block . id } output { output_index } to { target_block . id } input { input_index } " )
432437 connection = Connection (
433438 source_block [output_index ],
434439 target_block [input_index ],
0 commit comments