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

Enable tuple and NamedTuple #2732

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Mecoli1219
Copy link
Contributor

@Mecoli1219 Mecoli1219 commented Sep 5, 2024

Tracking issue

Why are the changes needed?

Check out the RFC

What changes were proposed in this pull request?

  • Run local test
  • Run remote test
    Currently, the flyte Console doesn't support tuple type on UI, we will open another PR to address that.

How was this patch tested?

NamedTuple

import typing
from typing import NamedTuple

class TupleClass(NamedTuple):
    keyi: int
    keys: str

@task(container_image=image)
def nt_t1_1(a1: TupleClass, b1: str) -> typing.Tuple[TupleClass, str]:
    return TupleClass(a1[0], a1[1]), b1

@task(container_image=image)
def nt_t2_1(a2: TupleClass, b2: str) -> typing.Tuple[TupleClass, str]:
    return TupleClass(a2[0], b2), a2[1]

@workflow
def nt_wf1_1(b: str) -> typing.Tuple[TupleClass, str]:
    t, s = nt_t1_1(a1=TupleClass(12345, "NamedTupleData"), b1=b)
    return nt_t2_1(a2=TupleClass(t[0], t[1]), b2=s)

@workflow
def nt_wf2_1(b: str) -> typing.Tuple[TupleClass, str]:
    (at, bt), s = nt_t1_1(a1=TupleClass(12345, "NamedTupleData"), b1=b)
    return nt_t2_1(a2=TupleClass(at, bt), b2=s)

Tuple

@task
def t_t1(
    a1: typing.Tuple[int, str], b1: str
) -> typing.Tuple[typing.Tuple[int, str], str]:
    return (a1[0], a1[1]), b1

@task
def t_t2(
    a2: typing.Tuple[str, int], b2: str
) -> typing.Tuple[typing.Tuple[int, str], str]:
    return (a2[1], b2), a2[0]

@workflow
def t_wf1(b: str) -> typing.Tuple[typing.Tuple[int, str], str]:
    t, s = t_t1(a1=(54321, "tuple_data"), b1=b)
    return t_t2(a2=(t[1], t[0]), b2=s)

@workflow
def t_wf2(b: str) -> typing.Tuple[typing.Tuple[int, str], str]:
    (at, bt), s = t_t1(a1=(54321, "tuple_data"), b1=b)
    return t_t2(a2=(bt, at), b2=s)

Setup process

Screenshots

image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • [] All new and existing tests passed.
  • All commits are signed-off.

The tests require IDL to be merged.

Related PRs

Docs link

@Mecoli1219 Mecoli1219 changed the title [WIP] Enable tuple and NamedTuple Enable tuple and NamedTuple Sep 7, 2024
@Mecoli1219 Mecoli1219 marked this pull request as ready for review September 7, 2024 08:21
@Mecoli1219 Mecoli1219 marked this pull request as draft September 7, 2024 08:21
@Mecoli1219 Mecoli1219 marked this pull request as ready for review September 7, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant