Skip to content

Task Output Attributes #1670

Answered by SandraGH5
SandraGH5 asked this question in Q&A
Oct 14, 2021 · 1 comments · 8 replies
Discussion options

You must be logged in to vote

Currently, dataclass converts the object to a flyteidl.struct / json type. And today flytepropeller cannot open up the struct to pass parts of it to downstream tasks. (This is a feature we have been thinking about, but are afraid that the engine will need to load arbitrary jsons).
Thus you can only pass dataclasses as one complete object and cannot access individual variables from it. You can change your code to:

Person = typing.NamedTuple(
    "Person", name=str, nationality=str)

@task
def create_person(name: str, nationality: str) -> Person:
    return Person(name=name, nationality=nationality)

@task
def say_hello(name: str) -> str:
    greeting = f"hello {name}"
    print(greeting)
 …

Replies: 1 comment 8 replies

Comment options

SandraGH5
Oct 14, 2021
Collaborator Author

You must be logged in to vote
8 replies
@main2adwitiya
Comment options

@yubofredwang
Comment options

@samhita-alla
Comment options

@yubofredwang
Comment options

@samhita-alla
Comment options

Answer selected by SandraGH5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants