flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[Core feature] Add support Literal Transformer

Open pingsutw opened this issue 1 year ago • 3 comments

Motivation: Why do you think this is important?

Currently, the Literal will be serialized to a pickle file instead of proto.

from pydantic import BaseModel
from typing import Literal


class People(BaseModel):
    name: Literal["a"]

Goal: What should the final outcome look like, ideally?

Use the literal transformer to serialize the Literal to a literal primitive

Describe alternatives you've considered

NA

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

pingsutw avatar Jun 18 '25 19:06 pingsutw

Flyte currently does not natively support Python's typing.Literal as a distinct Flyte type for task inputs/outputs. When used, it is serialized as a "PythonPickle" blob, not as a Flyte primitive, and appears as such in the UI. The desired behavior—mapping Literal to a Flyte primitive (e.g., string)—would require Flyte to extend its type system and type transformers to recognize and handle Literal types directly, similar to how Enums are handled. This is a known feature request and not yet implemented as of the latest discussions and issues.

A workaround is to use str instead of Literal, but this sacrifices strict typing. Implementing proper support would involve changes to Flyte's type engine to extract the allowed values from Literal and serialize them as primitives, not pickles. Would you like more detail on how such a transformer could be implemented or tracked in Flyte?

Sources:


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!

runllm avatar Jun 18 '25 19:06 runllm

#take

BarryWu0812 avatar Jul 23 '25 19:07 BarryWu0812

Related to #6410

machichima avatar Aug 25 '25 07:08 machichima