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

[1st version] Add Tuple idl #5720

Closed
wants to merge 7 commits into from
Closed

Conversation

Mecoli1219
Copy link

@Mecoli1219 Mecoli1219 commented Sep 3, 2024

Tracking issue

#5908
#1337
#3158
#4358

Why are the changes needed?

What changes were proposed in this pull request?

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

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

Related PRs

RFC: #5699

Docs link

@Mecoli1219 Mecoli1219 changed the title Add Tuple idl [WIP] Add Tuple idl Sep 3, 2024
@pingsutw pingsutw marked this pull request as ready for review September 3, 2024 21:33
@Mecoli1219 Mecoli1219 changed the title [WIP] Add Tuple idl Add Tuple idl Sep 7, 2024
Comment on lines +670 to +681
case *core.LiteralType_TupleType:
// TO_DISCUSS: How to handle the tuple interface in Inputs field of flytectl?
//
// [Example usage]
// inputs:
// tuple_data:
// key1: "foo"
// key2: 123

vMap, ok := v.(map[string]interface{})
if !ok {
return nil, errors.Errorf("Expected a map[string]interface{} for tuple type, got [%v]", v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain more?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this part, the LiteralType is already given, so the name of the tuple and the order of each field should be already defined. The only thing that is missing is the value of each field.
Therefore, we only need to provide the value of each tuple field (via the key-value pair of each field) in flytectl for the registered task or workflow for further execution needs.

Signed-off-by: Mecoli1219 <[email protected]>
Signed-off-by: Mecoli1219 <[email protected]>
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 79.59184% with 30 lines in your changes missing coverage. Please review.

Project coverage is 51.00%. Comparing base (28f65b3) to head (fa27e1a).
Report is 50 commits behind head on master.

Files with missing lines Patch % Lines
flytepropeller/pkg/compiler/validators/bindings.go 58.69% 14 Missing and 5 partials ⚠️
...ytepropeller/pkg/controller/nodes/dynamic/utils.go 0.00% 5 Missing ⚠️
flytepropeller/pkg/controller/nodes/resolve.go 80.00% 2 Missing and 1 partial ⚠️
flytepropeller/pkg/visualize/visualize.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5720       +/-   ##
===========================================
+ Coverage   36.30%   51.00%   +14.70%     
===========================================
  Files        1305     1159      -146     
  Lines      110000    75156    -34844     
===========================================
- Hits        39932    38332     -1600     
+ Misses      65912    32845    -33067     
+ Partials     4156     3979      -177     
Flag Coverage Δ
unittests-datacatalog 51.37% <ø> (ø)
unittests-flyteadmin 55.59% <ø> (-0.04%) ⬇️
unittests-flytecopilot 12.17% <ø> (ø)
unittests-flytectl 62.40% <ø> (+0.18%) ⬆️
unittests-flyteidl ?
unittests-flyteplugins 53.35% <ø> (ø)
unittests-flytepropeller 42.11% <79.59%> (+0.22%) ⬆️
unittests-flytestdlib 55.19% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

repeated string order = 2;

// A map of literals.
map<string, Literal> literals = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use Literal.collection?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literal.collection is not enough to store the name of the fields for NamedTuple.

message TupleType {
string tuple_name = 1;
repeated string order = 2;
map<string, LiteralType> fields = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use repeated here, like

message TupleEntry {
  string name = 1;
  LiteralType literal_type = 2;
}
message TupleType {
    string tuple_name = 1;
    repeated TupleEntry = 2;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other Considerations
An alternative approach to storing the literal values for NamedTuple and Tuple would be combining the order and the map into a list of messages, as shown below:

// !!! This is not the proposed implementation !!!
message FakeLiteralTupleField {
string name = 1;
Literal value = 2;
}

message FakeLiteralTupleMap {
string tuple_name = 1;
repeated FakeLiteralTupleField fields = 2;
}
While this structure may seem more straightforward, it has a drawback: looking up a field’s value by name requires iterating through the list, which results in O(n) complexity. In contrast, using a map allows for more efficient O(1) lookup times when retrieving the value of a field by its name. Although in practice the tuple size is usually small, the map-based approach is more scalable and efficient.

@Mecoli1219 Mecoli1219 changed the title Add Tuple idl [1st version] Add Tuple idl Oct 24, 2024
@Mecoli1219 Mecoli1219 closed this Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants