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] Dataclasses with list attributes don't always serialize/deserialize correctly. #5593

Closed
2 tasks done
JackUrb opened this issue Jul 26, 2024 · 1 comment
Closed
2 tasks done
Assignees
Labels
bug Something isn't working hacktoberfest

Comments

@JackUrb
Copy link

JackUrb commented Jul 26, 2024

Describe the bug

There are cases where, when passing dataclass promises around between workflows and tasks, they fail to deserialize properly. This appears to be related to a bug in the protobuf Message parsing, namely that _MessageToDict doesn't always return a dict when deserializing, it can return a list if that's what the input should deserialize to.

Expected behavior

It should be possible to use dataclasses that contain lists without issue.

Additional context to reproduce

# simple_list_repro.py
from flytekit import task, workflow
from dataclasses import dataclass
from mashumaro.mixins.json import DataClassJSONMixin


@dataclass(kw_only=True)
class DataclassWithList(DataClassJSONMixin):
    some_strings: list[str]

@task
def create_dataclass_with_list(
    some_strings: list[str],
) -> DataclassWithList:
    return DataclassWithList(
        some_strings=some_strings,
    )

@workflow
def convert_list_workflow(
    inputs: DataclassWithList,
) -> DataclassWithList:
    result_list = create_dataclass_with_list(some_strings=inputs.some_strings)
    return result_list


if __name__ == "__main__":
    workflow_input = DataclassWithList(
        some_strings=["hello", "world"],
    )
    print(convert_list_workflow(workflow_input))

The above throws an exception around trying to access a list like a dict.

Screenshots

No response

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

  • Yes

Have you read the Code of Conduct?

  • Yes
@JackUrb JackUrb added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Jul 26, 2024
Copy link

runllm bot commented Jul 26, 2024

This issue appears to be related to the known problem with Flyte's handling of dataclasses containing lists, particularly during serialization and deserialization. The root cause is that _MessageToDict can return a list instead of a dict, which Flyte's type system does not handle correctly.

According to this GitHub issue, the problem arises because _MessageToDict does not always return a dict when deserializing, leading to errors when Flyte tries to process the data. This issue has been acknowledged and is being tracked.

Would you like more detail on potential workarounds or further explanation of the 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants