https://flyte.org logo
#flytekit
Title
# flytekit
g

Greg Gydush

05/19/2022, 5:32 PM
Jeev helped me find a very interesting bug this morning when using dictionaries on Flyte. The order of the keys seems to be non-deterministic, issue is here!
k

Ketan (kumare3)

05/19/2022, 6:51 PM
cc ohh no, this means that the caching fails?
cc @Eduardo Apolinario (eapolinario)
j

jeev

05/19/2022, 7:18 PM
damn didn't even think about the effect on caching.
k

Ketan (kumare3)

05/20/2022, 3:59 AM
then what was the problem?
j

jeev

05/20/2022, 4:25 AM
the output (xml doc) depended on the order of the keys of the input dict, so was not as expected.
k

Ketan (kumare3)

05/20/2022, 4:26 AM
hmm i think caching actually already sorts maps
i do not know if it sorts recursively
e

Eduardo Apolinario (eapolinario)

05/20/2022, 7:15 PM
Jeev, this is not an easy problem to solve. There are some languages, like python, that guarantee the order of keys in a dictionary in the same context (e.g. in the case of python: the runtime environment), but that's not the execution model that Flyte uses, right? Data is communicated between tasks using Flyte types, which under the covers uses protobufs. We map python dictionaries to protobuf maps and that is not guaranteed to be stable:
Wire format ordering and map iteration ordering of map values are undefined, so you cannot rely on your map items being in a particular order.
Is there any way you can specify the order separately?
k

Ketan (kumare3)

05/21/2022, 1:11 AM
Like use list. Orderedmap is not supported
j

jeev

05/21/2022, 1:25 AM
the interesting thing is that the order looks right in the printed LiteralMap after reading it back in from the protobuf. is that just my eyes playing tricks on me? :P
but that's good to know @Eduardo Apolinario (eapolinario) . @Greg Gydush fyi.
👍 1
29 Views