<@U06RKAMK0UC> I get the following error when init...
# ask-ai
s
@ancient-wolf-19325 I get the following error when initializing a pydantic model that uses enums:
add_flyte_validators_for_type.<locals>.validator() takes 1 positional argument but 2 were given
Interestingly only when I try run it with flyte. When I run it outside of Flyte it works. Here is the code:
Copy code
class FeatureType(StrEnum):
    """Enum for feature types."""

    OUTCOME = "outcome"
    SCORE = "score"

class DataSequenceConfig(BaseModel):
    feature_type: FeatureType

my_config = DataSequenceConfig(feature_type="outcome") # or FeatureType.OUTCOME
Why is that the case?
j
Reasoning Complete! 🤖 🔍 Searched knowledge base: I want to check if there are any known issues or special considerations when using Pydantic Enums with Flyte, since the error only appears in that environment. This will help me explain why the error occurs and how to resolve it. • Searching over 10 data sources from the following: File, Github File, Github Issue, Web • Found 52 documents that could be relevant from the following data sources: Github File, Github Issue, Github Pull Request. • Filtered down to the top 30 most relevant documents. ✍️ Generated answer: I have enough information to explain why this error occurs: Flyte adds its own validation logic to Pydantic models, and if the injected validators don't match Pydantic's expected signature, you get this error. This is a known issue when using Enums with Pydantic models in Flyte.
It seems likely that this error is related to Flyte's internal type validation and how it interacts with Pydantic models containing Enums. Flyte adds custom validators to handle type conversions, but these can sometimes conflict with Pydantic's own validation logic, especially for Enums. This issue does not occur outside Flyte because the extra Flyte-specific validation is not present in standard Pydantic usage. Recent Flyte versions (>=1.14) have improved Pydantic and Enum support, but there have been known issues with Enum handling in Pydantic models, particularly with custom or string-based Enums. If you are using an older Flyte version, upgrading may resolve the problem. If the issue persists, it may be due to a bug in Flyte's type transformer logic for Pydantic models with Enums, as discussed in related issues and PRs. See Flytekit Pydantic BaseModel docs and Enum/validation issues. Would you like more detail on workarounds or how to structure your code to avoid this error? Sources: - Flytekit Pydantic BaseModel docs - Enum/validation issues 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
hi @sparse-carpenter-66912 So it works locally for you?
s
Hi! Locally, without flyte, yes
a
what flytekit version are you using?
s
1.16.1
I opened a bug report as well: https://github.com/flyteorg/flyte/issues/6572