Skip to content

Commit 2c2bd66

Browse files
committed
refactor: format and lint
-e Signed-off-by: machichima <nary12321@gmail.com>
1 parent 0ae8f2d commit 2c2bd66

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

flytekit/core/array_node_map_task.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from flytekit.core.context_manager import ExecutionState, FlyteContext, FlyteContextManager
1818
from flytekit.core.interface import transform_interface_to_list_interface
1919
from flytekit.core.launch_plan import LaunchPlan
20-
from flytekit.core.promise import Promise, create_native_named_tuple, create_task_output
2120
from flytekit.core.python_function_task import PythonFunctionTask, PythonInstanceTask
2221
from flytekit.core.task import ReferenceTask
2322
from flytekit.core.type_engine import TypeEngine

flytekit/core/base_task.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

flytekit/core/container_task.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ def execute(self, **kwargs) -> LiteralMap:
260260
except ImportError:
261261
raise ImportError(DOCKER_IMPORT_ERROR_MESSAGE)
262262

263-
from flytekit.core.type_engine import TypeEngine
264-
265263
ctx = FlyteContext.current_context()
266264

267265
# Normalize the input and output directories

0 commit comments

Comments
 (0)