Skip to content

Commit

Permalink
Support non-any type as any input in workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier committed May 22, 2024
1 parent cfaedce commit 4546eb4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion flytepropeller/pkg/compiler/validators/typing.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,27 @@ func getTypeChecker(t *flyte.LiteralType) typeChecker {
}
}

func AreTypesCastable(upstreamType, downstreamType *flyte.LiteralType) bool {
func isTypeAny(t *flyte.LiteralType) bool {
if t.GetMetadata() != nil {
if t.GetMetadata().GetFields() != nil {
pythonClassName := t.GetMetadata().GetFields()["python_class_name"]
if pythonClassName != nil {
if strVal, ok := pythonClassName.GetKind().(*structpb.Value_StringValue); ok && strVal.StringValue == "typing.Any" {
return true

Check warning on line 365 in flytepropeller/pkg/compiler/validators/typing.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/compiler/validators/typing.go#L364-L365

Added lines #L364 - L365 were not covered by tests
}
}
}
}
return false
}

func AreTypesCastable(upstreamType *flyte.LiteralType, downstreamType *flyte.LiteralType) bool {
typeChecker := getTypeChecker(downstreamType)

if isTypeAny(upstreamType) || isTypeAny(downstreamType) {
return true

Check warning on line 377 in flytepropeller/pkg/compiler/validators/typing.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/compiler/validators/typing.go#L377

Added line #L377 was not covered by tests
}

// if upstream is a singular union we check if the downstream type is castable from the union variant
if upstreamType.GetUnionType() != nil && len(upstreamType.GetUnionType().GetVariants()) == 1 {
variants := upstreamType.GetUnionType().GetVariants()
Expand Down

0 comments on commit 4546eb4

Please sign in to comment.