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] Dataclass int field becomes float when passed to task #2839

Closed
2 tasks done
jacob-protectai opened this issue Sep 1, 2022 · 1 comment
Closed
2 tasks done
Assignees
Labels
bug Something isn't working flytekit FlyteKit Python related issue
Milestone

Comments

@jacob-protectai
Copy link

Describe the bug

It appears that when serializing/deserializing a dataclass, there is an issue where ints are cast to floats.

Dataclass

@dataclass_json
@dataclass
class Args(object):
    max_iter: int = 0
    init_eval: int = 0
    max_eval: int = 0

@dataclass_json
@dataclass
class Schema(object):
    name: str
    kwargs_list: List[str] = field(default_factory=list)
    kwargs: Optional[Args] = None
    extras: Optional[Dict[str, Any]] = None

@dataclass_json
@dataclass
class ConfigSchema(object):
    description: str
    schema: Schema

Workflow file

@task
def run_action(config: ConfigSchema, uuid: str) -> Schema:
    at = Action(config=config,
                uuid=uuid,
                persist=True)
    at.execute()

    return config.schema


@dynamic
def action_dynamic_workflow(config_file: str) -> typing.List[Schema]:
    uuid = str(uuid.uuid4())
    config_file = os.path.join(project.get_project_root(), config_file)
    aconfigs = Configure.build_action_configs(config_file)
    ret : typing.List[Schema] = []
    for aconfig in aconfigs:
        ret.append(run_action(config=aconfig, uuid=uuid))
    
    return ret

@workflow
def action_workflow(config_file: str) -> typing.List[Schema]:
    return action_dynamic_workflow(config_file = config_file)

When running the task run_action, the int args are float and the code below is erroring, as an int is expected and defined in the dataclass

Expected behavior

All inputs to run_action will have the type that was specified in the dataclass definition, especially int vs float

Additional context to reproduce

Using flytekit v1.2.0b0 (There was a recent fix for a type conversion problem that seemed related, but the issue persists)

Could be related to #2775, but I tried using the new flytekit version without success

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@jacob-protectai jacob-protectai added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Sep 1, 2022
@welcome
Copy link

welcome bot commented Sep 1, 2022

Thank you for opening your first issue here! 🛠

@pingsutw pingsutw self-assigned this Sep 5, 2022
@pingsutw pingsutw added flytekit FlyteKit Python related issue and removed untriaged This issues has not yet been looked at by the Maintainers labels Sep 5, 2022
@pingsutw pingsutw added this to the 1.2.0-candidate milestone Sep 8, 2022
@eapolinario eapolinario modified the milestones: 1.2.0-candidate, 1.3.0 Oct 5, 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

3 participants