diff --git a/flytekit/models/literals.py b/flytekit/models/literals.py index 1bc69ae41b..4f06c3d3c6 100644 --- a/flytekit/models/literals.py +++ b/flytekit/models/literals.py @@ -464,7 +464,9 @@ def to_literal_model(self): ) ) elif self.map: - return Literal(map=LiteralMap(literals={k: binding.to_literal_model() for k, binding in self.map.bindings})) + return Literal( + map=LiteralMap(literals={k: binding.to_literal_model() for k, binding in self.map.bindings.items()}) + ) class Binding(_common.FlyteIdlEntity): diff --git a/tests/flytekit/unit/core/test_dynamic.py b/tests/flytekit/unit/core/test_dynamic.py index 668ca97dfd..d19f47ff75 100644 --- a/tests/flytekit/unit/core/test_dynamic.py +++ b/tests/flytekit/unit/core/test_dynamic.py @@ -153,3 +153,25 @@ def wf() -> str: return dynamic_wf() assert wf() == "hello" + + +def test_dynamic_return_dict(): + @dynamic + def t1(v: str) -> typing.Dict[str, str]: + return {"a": v} + + @dynamic + def t2(v: str) -> typing.Dict[str, typing.Dict[str, str]]: + return {"a": {"b": v}} + + @dynamic + def t3(v: str) -> (str, typing.Dict[str, typing.Dict[str, str]]): + return v, {"a": {"b": v}} + + @workflow + def wf(): + t1(v="a") + t2(v="b") + t3(v="c") + + wf()