You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to pass a dataclass that has a field with type Optional[int] to a Flyte task. When I pass the dataclass to the task, the field is converted to type float and becomes 1.0 instead of remaining type int and 1 as I expect. This is a problem for things like RNG seeds that expect either None or an int.
Input:
from typing import Optional
from dataclasses import dataclass
from dataclasses_json import DataClassJsonMixin
from flytekit import task
@dataclass
class MyDataclass(DataClassJsonMixin):
value: Optional[int] = None
my_dataclass = MyDataclass(value=1)
print(my_dataclass.value, type(my_dataclass.value))
@task
def return_types(my_dc: MyDataclass):
print(my_dc.value, type(my_dc.value))
return_types(my_dc=my_dataclass)
Output:
1 <class 'int'>
1.0 <class 'float'>
Expected behavior
int values passed into Optional[int] fields should remain type int.
Additional context to reproduce
Screenshots
No response
Are you sure this issue hasn't been raised already?
Yes
Have you read the Code of Conduct?
Yes
The text was updated successfully, but these errors were encountered:
cellweaver
changed the title
[BUG] int values in Optional[int] dataclass fields are converted to floats when passed into Flyte
[BUG] int values in Optional[int] dataclass fields are converted to floats when passed into Flyte tasks
Aug 16, 2022
Describe the bug
i'm trying to pass a dataclass that has a field with type
Optional[int]
to a Flyte task. When I pass the dataclass to the task, the field is converted to typefloat
and becomes1.0
instead of remaining typeint
and1
as I expect. This is a problem for things like RNG seeds that expect eitherNone
or anint
.Input:
Output:
Expected behavior
int
values passed intoOptional[int]
fields should remain typeint
.Additional context to reproduce
Screenshots
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: