<#4505 [BUG] Can't use int types on tasks, flyte c...
# flytekit
c
#4505 [BUG] Can't use int types on tasks, flyte casts to float between tasks Issue created by jiwidi Describe the bug I'm trying to use the int type along my workflow but it keeps being parsed as float and complaining about it when passing it downstream to other tasks. I even try to cast it within a task but it casts it back to float. Expected behavior For objects within tasks to remain typed as int or flyte to cast them properly (complains about not being able to cast a float with no decimals to int, which is possible) Additional context to reproduce I have this main.py file containing my workflow:
Copy code
from flytekit import task, workflow
import os
import yaml

@task
def read_yaml(yaml_path: str) -> dict:
    with open(yaml_path, "r") as file:
        config = yaml.safe_load(file)
        config['id'] = int(config['id'])
        return config

@task
def check_int(x: int) -> int:
    return x

@workflow
def workflow(yaml_path: str) -> int:
    config = read_yaml(yaml_path=yaml_path)
    return check_int(x=config['id'])
And a config.yaml where the int should be read from:
Copy code
id: !!int 1
When I run this with the command
Copy code
pyflyte run main.py workflow --yaml_path config.yaml
I get the error:
Copy code
Running Execution on local.
2023-11-30 15:36:01,527455 ERROR    {"asctime": "2023-11-30 15:36:01,527", "name": "flytekit", "levelname": "ERROR", "message": "Failed to convert inputs of task 'main.check_int':\n  Error  base_task.py:621
                                    converting input 'x' at position 0:\n  Cannot convert literal <FlyteLiteral scalar { primitive { float_value: 1 } }> to <class 'int'>"}
Failed with Unknown Exception <class 'flytekit.core.type_engine.TypeTransformerFailedError'> Reason: Encountered error while executing workflow 'main.workflow':
  Error encountered while executing 'workflow':
  Failed to convert inputs of task 'main.check_int':
  Error converting input 'x' at position 0:
  Cannot convert literal <FlyteLiteral scalar { primitive { float_value: 1 } }> to <class 'int'>
Encountered error while executing workflow 'main.workflow':
  Error encountered while executing 'workflow':
  Failed to convert inputs of task 'main.check_int':
  Error converting input 'x' at position 0:
  Cannot convert literal <FlyteLiteral scalar { primitive { float_value: 1 } }> to <class 'int'>
The yaml is typed to be int and i even cast it again within the read task but it still gets casted to float. Screenshots No response Are you sure this issue hasn't been raised already? • Yes Have you read the Code of Conduct? • Yes flyteorg/flyte