Jeev helped me find a very interesting bug this mo...
# flytekit
g
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
cc ohh no, this means that the caching fails?
cc @Eduardo Apolinario (eapolinario)
j
damn didn't even think about the effect on caching.
k
then what was the problem?
j
the output (xml doc) depended on the order of the keys of the input dict, so was not as expected.
k
hmm i think caching actually already sorts maps
i do not know if it sorts recursively
e
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
Like use list. Orderedmap is not supported
j
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
166 Views