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] Accessing attributes fails on complex types #5427

Closed
2 tasks done
architrathore opened this issue May 29, 2024 · 5 comments
Closed
2 tasks done

[BUG] Accessing attributes fails on complex types #5427

architrathore opened this issue May 29, 2024 · 5 comments
Labels
backlogged For internal use. Reserved for contributor team workflow. bug Something isn't working

Comments

@architrathore
Copy link

architrathore commented May 29, 2024

Describe the bug

As per Accessing Attributes documentation, accessing attributes on promises is supported in workflows.
This works for simple types like str or int, but fails during workflow compilation for complex types such as accessing inner dataclass on a nested dataclasses.

Expected behavior

Accessing attributes should work for all types, not just primitive ones.

Additional context to reproduce

  • flytekit version==1.11.0
from __future__ import annotations

from dataclasses import dataclass

from flytekit import task, workflow
from mashumaro.mixins.json import DataClassJSONMixin


@dataclass
class Fruit(DataClassJSONMixin):
    name: str


@dataclass
class NestedFruit(DataClassJSONMixin):
    sub_fruit: Fruit
    name: str


@task
def dataclass_task() -> Fruit:
    return Fruit(name="banana")


@task
def dataclass_task_nested() -> NestedFruit:
    return NestedFruit(sub_fruit=Fruit(name="banana"), name="nested_name")


@task
def print_message(message: str):
    print(message)
    return


@task
def print_message_fruit(fruit_instance: Fruit):
    print(fruit_instance.name)
    print(fruit_instance)
    return


@task
def print_message_nested(nested_fruit: NestedFruit):
    print(nested_fruit.sub_fruit.name)
    print(nested_fruit.name)
    return


@workflow
def dataclass_wf():
    fruit_instance = dataclass_task()
    nested_fruit_instance = dataclass_task_nested()

    # ✅ accessing attribute of type=str 
    print_message(message=fruit_instance.name)
    # ✅ non attribute access 
    print_message_nested(nested_fruit=nested_fruit_instance)
    # ✅ accessing attribute of type=str on a nested dataclass
    print_message(message=nested_fruit_instance.sub_fruit.name)
    # ❌ accessing attribute of type=dataclass
    print_message_fruit(fruit_instance=nested_fruit_instance.sub_fruit)

When registering the workflow, this fails with the following error:

Error 0: Code: MismatchingTypes, Node Id: n4, Description: Variable [o0] (type [simple:STRING]) doesn't match expected type [simple:STRUCT  metadata:{fields:{key:"additionalProperties"  value:{bool_value:false}}  fields:{key:"properties"  value:{struct_value:{fields:{key:"name"  value:{struct_value:{fields:{key:"type"  value:{string_value:"string"}}}}}}}}  fields:{key:"required"  value:{list_value:{values:{string_value:"name"}}}}  fields:{key:"title"  value:{string_value:"Fruit"}}  fields:{key:"type"  value:{string_value:"object"}}}  structure:{dataclass_type:{key:"name"  value:{simple:STRING}}}].
Error 1: Code: ParameterNotBound, Node Id: n4, Description: Parameter not bound [fruit_instance]

Screenshots

No response

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

  • Yes

Have you read the Code of Conduct?

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

welcome bot commented May 29, 2024

Thank you for opening your first issue here! 🛠

Copy link

runllm bot commented May 29, 2024

The issue you're encountering is related to Flyte's handling of complex types, particularly nested dataclasses. According to this GitHub issue, nested dataclasses are not fully supported in Flyte's type system, which can lead to type mismatches during workflow compilation.

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!

@kumare3
Copy link
Contributor

kumare3 commented May 29, 2024

Cc @ByronHsu

@eapolinario eapolinario added backlogged For internal use. Reserved for contributor team workflow. and removed untriaged This issues has not yet been looked at by the Maintainers labels May 30, 2024
@kumare3
Copy link
Contributor

kumare3 commented Sep 11, 2024

covered by #5318

@Future-Outlier
Copy link
Member

I think this is the bug of propeller, but not related to the JSON IDL.
I'm investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlogged For internal use. Reserved for contributor team workflow. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants