This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
Literal Transformations from a string or an interface based on literalTypes #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Ketan Umare [email protected]
TL;DR
Supports converting to flyte literal from string/interface based simple type or an [] interface for collection and map[string] interface for map type. This is useful for flytectl eg in creating executions where the task/workflow params /variables and there types are know with there definitions and the input is in form of string / yaml structure.
MakeLiteralForType(t *core.LiteralType, v interface{}) (*core.Literal, error)
The input value v can be converted to the flyte Literal using the type definition t. If the conversion is not possible it would throw an error.
Earlier code would support string to SimpleType conversion using
MakeLiteralForSimpleType(t core.SimpleType, s string) (*core.Literal, error)
The following PR wraps this to support LiteralType_MapValueType and LiteralType_CollectionType
Support for LiteralType_Blob and LiteralType_Schema would be added as a followup.
At the top level following value types are supported without type erasure.
interface{} -> SimpleType map[string]interface{} -> MapValueType []interface{} - CollectionType
An input value not adhering to these types would be rejected.
eg :
strArray := map[string][]interface{}{"hello1": {"world11", "world12"}, "hello2": {"world21", "world22"}}
wont be supported since map[string][]interface isn't a direct type supported for converting to literal.
Instead the same input can be given using type erasure to its supported type.
This allows for complex type conversion
Type
Are all requirements met?
Complete description
How did you fix the bug, make the feature etc. Link to any design docs etc
Tracking Issue
flyteorg/flyte#316
Follow-up issue
flyteorg/flyte#316