cuddly-jelly-27016
02/04/2025, 4:15 PMfrom 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:
id: !!int 1
When I run this with the command
pyflyte run main.py workflow --yaml_path config.yaml
I get the error:
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/flytecuddly-jelly-27016
02/04/2025, 4:15 PM