[Core feature] Support `typing.Literal` as flyte type in tasks
Motivation: Why do you think this is important?
I am using in our pipelines quite a few Literal definitions in our functions. When putting a @task decorator from Flyte onto these functions, it also works, but in the UI it shows up as feature: "single (PythonPickle) blob" in the "input"-tab.
When changing this to str it shows up as a simple string: feature:"outcome".
Goal: What should the final outcome look like, ideally?
It would be nice to have the typing.Literal parameter also render as string in the UI.
Describe alternatives you've considered
Instead of using the more strict typing.Literal we could use a normal str type, but this removes stricter typing.
Propose: Link/Inline OR Additional context
No response
Are you sure this issue hasn't been raised already?
- [x] Yes
Have you read the Code of Conduct?
- [x] Yes
It seems likely that Flyte currently does not support typing.Literal as a native type for task inputs, which results in it being displayed as a "PythonPickle" blob in the UI. This is because Flyte's type system may not recognize Literal as a distinct type and defaults to a generic serialization method. The goal of having Literal render as a string in the UI would require Flyte to extend its type system to recognize and handle Literal types specifically.
My understanding is that a potential workaround is to use str instead of Literal, but this sacrifices the stricter typing benefits that Literal provides. Implementing support for Literal would involve changes to Flyte's type engine to recognize Literal as a distinct type and render it appropriately in the UI. Would you like more detail on how Flyte's type system could be extended to support this feature?
Sources:
- https://github.com/flyteorg/flyte/issues/1300
- https://github.com/flyteorg/flyte/blob/master/rfc/system/1855-type-metadata.md
This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.
Mention @runllm to ask follow-up questions. See runllm.com for more!
This should a very simple plugin. We should follow Enum example for this.
you can get all Literal variants using `get_args`