<#4740 [BUG] Flyte automatically casts dict keys f...
# flytekit
c
#4740 [BUG] Flyte automatically casts dict keys from int to str without any instruction to do so. Issue created by jiwidi ### Describe the bug Hi! So flyte is automatically casting int keys to str when i pass a dictionary between workflows. This a a major bug imo which is likely coming from the way you work with json. Here is a workflow to replicate: from flytekit import task, workflow from typing import Dict @task def create_dict() -> Dict[int, float]: sample_dict = {1: 1.1, 2: 2.2, 3: 3.3} print(sample_dict.keys()) return sample_dict @task def process_dict(input_dict: Dict[int, float]): print(input_dict.keys()) @workflow def workflow() -> None: dict_created = create_dict() process_dict(input_dict=dict_created) Run it with
pyflyte run main.py workflow
The output right now to verify the undesired cast:
Copy code
dict_keys([1, 2, 3])
dict_keys(['3', '1', '2'])
As suggested in the flyte slack https://flyte-org.slack.com/archives/CP2HDHKE1/p1706113015835149?thread_ts=1706105850.505019&amp;cid=CP2HDHKE1 I've also tryied typing it as
dict
without the types for key/values but it still gets casted to string. ### Expected behavior Print from the workflow should instead be:
Copy code
dict_keys([1, 2, 3])
dict_keys([1, 2, 3])
### Additional context to reproduce Run my script ### Screenshots No response ### Are you sure this issue hasn't been raised already? • Yes ### Have you read the Code of Conduct? • Yes flyteorg/flyte