Open jiwidi opened 5 months ago
Flyte currently has issues with handling Pydantic models, particularly with type conversions. Boolean values within Pydantic models may be cast to scalar values due to serialization issues. This is a known problem and has been discussed in the community.
Would you like more detail on potential workarounds or ongoing efforts to address this issue?
Sources:
This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.
Mention @runllm to ask follow-up questions. See runllm.com for more!
Hi, @jiwidi
I guess this might relate to how flyte handles complex data types. Currently as a workaround, you can try the following:
from flytekit import task, workflow
from pydantic import BaseModel
class Config(BaseModel):
bool_var: bool
@task
def create_config() -> Config:
return Config(bool_var=True)
@task
def check_bool(x: bool) -> bool:
return x
@task
def bool_parser(x: Config) -> bool:
return x.bool_var
@workflow
def wf() -> bool:
config = create_config()
return check_bool(x=bool_parser(x=config))
Describe the bug
Describe the bug
Trying to pass a pydantic model between task but its converting bool variables to int. Is there a way to make flyte work with pydantic models?
Expected behavior
For bool types to stay as bool types
Additional context to reproduce
I have this main.py file containing my workflow:
When I run this with the command
I get the error:
The bool property in the Config object is converted to a scalar.
Screenshots
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?