Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] int values in Optional[int] dataclass fields are converted to floats when passed into Flyte tasks #2775

Closed
2 tasks done
cellweaver opened this issue Aug 16, 2022 · 1 comment
Assignees
Labels
bug Something isn't working flytekit FlyteKit Python related issue
Milestone

Comments

@cellweaver
Copy link

cellweaver commented 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 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
@cellweaver cellweaver added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Aug 16, 2022
@welcome
Copy link

welcome bot commented Aug 16, 2022

Thank you for opening your first issue here! 🛠

@cellweaver cellweaver changed the title [BUG] [BUG] int values in Optional[int] dataclass fields are converted to floats when passed into Flyte Aug 16, 2022
@pingsutw pingsutw self-assigned this Aug 16, 2022
@cellweaver 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
@pingsutw pingsutw added this to the 1.2.0 milestone Aug 17, 2022
@wild-endeavor wild-endeavor added flytekit FlyteKit Python related issue and removed untriaged This issues has not yet been looked at by the Maintainers labels Aug 17, 2022
@kumare3 kumare3 closed this as completed Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flytekit FlyteKit Python related issue
Projects
None yet
Development

No branches or pull requests

4 participants