I am running into a predicament when I use datacla...
# ask-the-community
I am running into a predicament when I use dataclasses for params. Sometimes, I want to pass in the entire dataclass into a task, other times I want to reference a specific field. I have explored two options: • Have a task that converts a dataclass to a named tuple • Use @dynamic workflows Using dynamic workflows works, but maybe there are side effects? I would love to learn from folks who have gone down this path before.
Copy code
from flytekit import workflow, dynamic, task

class Params:
    color: str

def print_color(c: str):
def wf(params: Params) -> Params:
    return inner
Cc @Ankit Goyal I think Ankit and team offered to implement this in Flyte
So @Evan Sadler I think we will support this in native Flyte in sometime
For some context - this conversation. Basically, we could encode the Flyte
as a field of the dataclass rather than just the dataclass itself, then propeller internally can parse and retrieve the field when passing input values. I'm convinced it would be possible.
Then you wouldn't need to use a dynamic workflow here and incur the overhead of starting a separate Pod just to retrieve the field value from your Params dataclass. Propeller could parse it directly.
Oh nice! Looking forward to it 🙂.