Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Mecoli1219 <[email protected]>
  • Loading branch information
Mecoli1219 committed Oct 17, 2024
1 parent 38ba736 commit 6b67687
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions flytekit/core/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ def my_wf(in1: int, in2: int) -> int:
var = flyte_interface_types[k]
t = native_types[k]
try:
if type(v) is Promise:
v = await resolve_attr_path_in_promise(v)
elif type(v) is list:
v = await resolve_attr_path_in_list(v)
v = await resolve_attr_path_recursively(v)
result[k] = await TypeEngine.async_to_literal(ctx, v, t, var.type)
except TypeTransformerFailedError as exc:
exc.args = (f"Failed argument '{k}': {exc.args[0]}",)
Expand Down Expand Up @@ -173,13 +170,16 @@ async def resolve_attr_path_in_promise(p: Promise) -> Promise:
return p


async def resolve_attr_path_in_list(l: List[Any]) -> List[Any]:
for i, elem in enumerate(l):
if type(elem) is Promise:
l[i] = await resolve_attr_path_in_promise(elem)
elif type(elem) is list:
l[i] = await resolve_attr_path_in_list(elem)
return l
async def resolve_attr_path_recursively(v: Any) -> Any:
"""
This function resolves the attribute path in a nested structure recursively.
"""
if isinstance(v, Promise):
v = await resolve_attr_path_in_promise(v)
elif isinstance(v, list):
for i, elem in enumerate(v):
v[i] = await resolve_attr_path_recursively(elem)
return v


def resolve_attr_path_in_dict(d: dict, attr_path: List[Union[str, int]]) -> Any:
Expand Down

0 comments on commit 6b67687

Please sign in to comment.