@@ -610,16 +610,26 @@ def _literal_map_to_python_input(
610610 ) -> Dict [str , Any ]:
611611 return TypeEngine .literal_map_to_kwargs (ctx , literal_map , self .python_interface .inputs )
612612
613- async def _output_to_literal_map (self , native_outputs : Union [Tuple [Any ], List [Any ], Dict [str , Any ]], ctx : FlyteContext ):
613+ async def _output_to_literal_map (
614+ self , native_outputs : Union [Tuple [Any ], List [Any ], Dict [str , Any ]], ctx : FlyteContext
615+ ) -> Tuple [_literal_models .LiteralMap , Dict [str , Any ]]:
614616 """
615- Convert output to LiteralMap.
617+ Convert task output to a Flyte LiteralMap.
616618
617619 Args:
618- native_outputs: The output from task. Can be:
619- 1. Tuple[Any]: Outputs from normal tasks
620- 2. List[Any]: Outputs from array node map tasks
621- 3. Dict[str, Any]: Outputs from container tasks
622- ctx: The Flyte context object
620+ native_outputs (Union[Tuple[Any], List[Any], Dict[str, Any]]): The output from the task. Can be:
621+ 1. Tuple[Any]: Outputs from normal tasks.
622+ 2. List[Any]: Outputs from array node map tasks.
623+ 3. Dict[str, Any]: Outputs from container tasks.
624+ ctx (FlyteContext): The Flyte context object.
625+
626+ Returns:
627+ Tuple[_literal_models.LiteralMap, Dict[str, Any]]: A tuple containing the converted LiteralMap and the
628+ native outputs mapped by output variable names.
629+
630+ Raises:
631+ TypeError: If an output value is a tuple where it shouldn't be.
632+ BaseException: If conversion to a literal fails. The original exception is re-raised with additional context.
623633 """
624634 expected_output_names = list (self ._outputs_interface .keys ())
625635 if len (expected_output_names ) == 1 :
@@ -640,7 +650,9 @@ async def _output_to_literal_map(self, native_outputs: Union[Tuple[Any], List[An
640650 if isinstance (native_outputs , dict ):
641651 native_outputs_as_map = native_outputs
642652 else :
643- native_outputs_as_map = {expected_output_names [i ]: native_outputs [i ] for i , _ in enumerate (native_outputs )}
653+ native_outputs_as_map = {
654+ expected_output_names [i ]: native_outputs [i ] for i , _ in enumerate (native_outputs )
655+ }
644656
645657 # We manually construct a LiteralMap here because task inputs and outputs actually violate the assumption
646658 # built into the IDL that all the values of a literal map are of the same type.
@@ -669,7 +681,8 @@ async def _output_to_literal_map(self, native_outputs: Union[Tuple[Any], List[An
669681 f"Failed to convert type { type (native_outputs_as_map [expected_output_names [i ]])} to type { py_type } .\n "
670682 f"Error Message: { e .args [0 ]} ." ,
671683 )
672- raise e
684+ raise BaseException (* e .args ) from e
685+
673686 literals [k2 ] = v2 .result ()
674687
675688 if omt is not None :
0 commit comments