Skip to content

Commit ab463c3

Browse files
authored
stripping metadata from dataclass types (#626) (#6177)
* stripping metadata from dataclass types (#626) * stripping metadata from dataclass types Signed-off-by: Daniel Rammer <hamersaw@protonmail.com> * actually setting on Structure Signed-off-by: Daniel Rammer <hamersaw@protonmail.com> * added unit test Signed-off-by: Daniel Rammer <hamersaw@protonmail.com> --------- Signed-off-by: Daniel Rammer <hamersaw@protonmail.com> * fixed lint Signed-off-by: Daniel Rammer <hamersaw@protonmail.com> --------- Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
1 parent 729e71a commit ab463c3

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

flytepropeller/pkg/compiler/transformers/k8s/utils.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ func StripTypeMetadata(t *core.LiteralType) *core.LiteralType {
9797
}
9898
}
9999

100-
// Note that we cannot strip `Structure` from the type because the dynamic node output type is used to validate the
101-
// interface of the dynamically compiled workflow. `Structure` is used to extend type checking information on
102-
// different Flyte types and is therefore required to ensure correct type validation.
100+
// strip metadata from dataclass types
101+
if c.GetStructure() != nil && len(c.GetStructure().GetDataclassType()) > 0 {
102+
dataclassTypes := make(map[string]*core.LiteralType, len(c.GetStructure().GetDataclassType()))
103+
for k, v := range c.GetStructure().GetDataclassType() {
104+
dataclassTypes[k] = StripTypeMetadata(v)
105+
}
106+
107+
c.GetStructure().DataclassType = dataclassTypes
108+
}
103109

104110
switch underlyingType := c.GetType().(type) {
105111
case *core.LiteralType_UnionType:

flytepropeller/pkg/compiler/transformers/k8s/utils_test.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,25 @@ func TestStripTypeMetadata(t *testing.T) {
224224
},
225225
},
226226
},
227-
Structure: &core.TypeStructure{Tag: "str"},
227+
Structure: &core.TypeStructure{
228+
DataclassType: map[string]*core.LiteralType{
229+
"foo": {
230+
Type: &core.LiteralType_Simple{
231+
Simple: core.SimpleType_STRING,
232+
},
233+
Metadata: &_struct.Struct{
234+
Fields: map[string]*_struct.Value{
235+
"foo": {
236+
Kind: &_struct.Value_StringValue{
237+
StringValue: "bar",
238+
},
239+
},
240+
},
241+
},
242+
},
243+
},
244+
Tag: "str",
245+
},
228246
},
229247
},
230248
},
@@ -241,7 +259,16 @@ func TestStripTypeMetadata(t *testing.T) {
241259
Type: &core.LiteralType_Simple{
242260
Simple: core.SimpleType_STRING,
243261
},
244-
Structure: &core.TypeStructure{Tag: "str"},
262+
Structure: &core.TypeStructure{
263+
DataclassType: map[string]*core.LiteralType{
264+
"foo": {
265+
Type: &core.LiteralType_Simple{
266+
Simple: core.SimpleType_STRING,
267+
},
268+
},
269+
},
270+
Tag: "str",
271+
},
245272
},
246273
},
247274
},

0 commit comments

Comments
 (0)