[1st version] Enable tuple and NamedTuple#2732
Conversation
Signed-off-by: Mecoli1219 <michaellai901026@gmail.com>
Signed-off-by: Mecoli1219 <michaellai901026@gmail.com>
Signed-off-by: Mecoli1219 <michaellai901026@gmail.com>
Signed-off-by: Mecoli1219 <michaellai901026@gmail.com>
Signed-off-by: Mecoli1219 <michaellai901026@gmail.com>
|
woah!!!!!!!! |
|
|
||
| def output_to_tuple(output: "Output") -> Tuple: # type: ignore | ||
| """ | ||
| This function is used to convert an output object to a tuple. This is used to convert the output object to a tuple |
There was a problem hiding this comment.
duplicated?
| This function is used to convert an output object to a tuple. This is used to convert the output object to a tuple | |
| This is used to convert the output object to a tuple |
| return getattr(pb_module, name) | ||
|
|
||
|
|
||
| def is_namedtuple(t: typing.Type[T]) -> bool: |
There was a problem hiding this comment.
It would be great to have a unit test for it.
| expected: LiteralType, | ||
| ) -> Literal: | ||
| if expected.tuple_type.tuple_name != TupleTransformer.default_tuple_name(): | ||
| # We are expected a NamedTuple |
There was a problem hiding this comment.
Do you think we need a separate transformer for NamedTuple? NamedTupleTransformer
There was a problem hiding this comment.
I have discussed that in Section 6 Alternatives of this RFC: flyteorg/flyte#5699
In Flytekit, we can separate the
NamedTupleandTupleinto two different transformers, and this will make the code more readable and maintainable. However, the main problem is that theNamedTupleis not a type in Python, it is a function that returns a type. Separating them will make the registries of the transformers more complex and harder to maintain.
There was a problem hiding this comment.
Also, I have tried it before (maybe you can see that in some commits in this Pull Request), and it is really hard to maintain that.
Tracking issue
Why are the changes needed?
Check out the RFC
What changes were proposed in this pull request?
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
Tuple
Setup process
Screenshots
Check all the applicable boxes
The tests require IDL to be merged.
Related PRs
Docs link