<#6333 [Core feature] Allow node attr_path derefer...
# flyte-github
c
#6333 [Core feature] Allow node attr_path dereferences in uploaded workflows. Issue created by JackUrb ### Motivation: Why do you think this is important? The Binary IDL with MessagePack change (flyteorg/flytekit#2760) has allowed us to use complex dataclasses rather cleanly in Flyte. Unfortunately, these are still rather unwieldy, as we can't use
attr_path
dereferencing for constructing primitive collections in the same way that we can for standard promises. See the following example: from dataclasses import dataclass from flytekit import task, workflow from flytekit.configuration import Config from flytekit.remote import FlyteRemote from mashumaro.mixins.json import DataClassJSONMixin @dataclass(kw_only=True) class NestedStrOutputs(DataClassJSONMixin): nested_str: str @task def produces_nested_string() -> NestedStrOutputs: return NestedStrOutputs(nested_str="hello") @task def produces_string() -> str: return "hello" @task def consumes_string_list(inputs: list[str]) -> str: return " ".join(inputs) @workflow def test_repro() -> str: produced_string1 = produces_string() produced_string2 = produces_string() joined_string = consumes_string_list([produced_string1, produced_string2]) return joined_string @workflow def test_nested_repro() -> str: produced_string1 = produces_nested_string() produced_string2 = produces_nested_string() joined_string = consumes_string_list([produced_string1.nested_str, produced_string2.nested_str]) return joined_string if name == "__main__": config = Config.auto() remote = FlyteRemote(config=config) workflow = test_repro # or test_nested_repro execution = remote.execute( entity=test_nested_repro, project="flytesnacks", domain="development", inputs={}, version='latest', ) print(f"Execution started with ID {execution.id.name}") print(f"to view it, visit {remote.generate_console_url(execution)}") In the above,
test_repro
works entirely fine, but
test_nested_repro
fails:
Copy code
FlyteSystemException: SYSTEM:Unknown: error=None, cause=<_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INTERNAL
        details = "failed to compile workflow for [resource_type:WORKFLOW project:"flytesnacks" domain:"development" 
name:"workflows.minimum_nested_repro.test_nested_repro" version:"latest" ] with err failed to compile workflow with err
Collected Errors: 2
        Error 0: Code: MismatchingTypes, Node Id: n2, Description: Variable [o0] (type [simple:STRUCT 
metadata:<fields:<key:"additionalProperties" value:<bool_value:false > > fields:<key:"properties" 
value:<struct_value:<fields:<key:"nested_str" value:<struct_value:<fields:<key:"type" value:<string_value:"string" > > > > > > > > 
fields:<key:"required" value:<list_value:<values:<string_value:"nested_str" > > > > fields:<key:"title" 
value:<string_value:"NestedStrOutputs" > > fields:<key:"type" value:<string_value:"object" > > > 
annotation:<annotations:<fields:<key:"cache-key-metadata" value:<struct_value:<fields:<key:"serialization-format" 
value:<string_value:"msgpack" > > > > > > > structure:<2:"\n\nnested_str\x12\x02\b\x03" > ]) doesn't match expected type 
[simple:STRING ].
        Error 1: Code: ParameterNotBound, Node Id: n2, Description: Parameter not bound [inputs].
"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"failed to compile workflow for 
[resource_type:WORKFLOW project:\"flytesnacks\" domain:\"development\" 
name:\"workflows.flat_graphs.minimum_nested_repro.test_nested_repro\" version:\"latest\" ] with err failed to compile workflow with
err Collected Errors: 2\n\tError 0: Code: MismatchingTypes, Node Id: n2, Description: Variable [o0] (type [simple:STRUCT 
metadata:<fields:<key:\"additionalProperties\" value:<bool_value:false > > fields:<key:\"properties\" 
value:<struct_value:<fields:<key:\"nested_str\" value:<struct_value:<fields:<key:\"type\" value:<string_value:\"string\" > > > > > 
> > > fields:<key:\"required\" value:<list_value:<values:<string_value:\"nested_str\" > > > > fields:<key:\"title\" 
value:<string_value:\"NestedStrOutputs\" > > fields:<key:\"type\" value:<string_value:\"object\" > > > 
annotation:<annotations:<fields:<key:\"cache-key-metadata\" value:<struct_value:<fields:<key:\"serialization-format\" 
value:<string_value:\"msgpack\" > > > > > > > structure:<2:\"\\n\\nnested_str\\x12\\x02\\b\\x03\" > ]) doesn\'t match expected type
[simple:STRING ].\n\tError 1: Code: ParameterNotBound, Node Id: n2, Description: Parameter not bound [inputs].\n", grpc_status:13, 
created_time:"2025-03-11T16:32:09.9104-07:00"}"
>
Given that it would seem that the Binary IDL for dataclasses change would allow for the full dataclass typing to be available at resolution time, I'd expect it should be possible for this to be resolved on the
workflow
backend in the same way that it ends up being resolved for dereferencing promise inputs passed to `@task`s. ### Goal: What should the final outcome look like, ideally? Ideally, both of the above examples work in the same way. The
resolve_attr_path_in_promise
method suggests that this should be the case on the flytepropeller side. ### Describe alternatives you've considered The main way we deal with this right now is that we have a significant number of dataclass attribute extractors and restructuring
@task
methods which handle the part of splitting and repackaging these pieces where needed, however this ends up costing ~1.5-3 minutes of runtime per required extraction or wrap as a node needs to be initialized to do this conversion. ### Propose: Link/Inline OR Additional context No response ### Are you sure this issue hasn't been raised already? • Yes ### Have you read the Code of Conduct? • Yes flyteorg/flyte