[Core feature] Pydantic BaseModel V2 in Dataclass
- Dominant language
- Go
- Stars
- 7.5k
- Forks
- 886
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 120
Description
### Motivation: Why do you think this is important?
Some users want the below example works in a task/workflow.
```python
from dataclasses import dataclass, field
# Define InnerBM using Pydantic BaseModel
class InnerBM(BaseModel):
a: int = -1
b: float = 3.14
c: str = "Hello, Flyte"
d: bool = False
# Define the dataclass DC
@dataclass
class DC:
a: int = -1
b: float = 3.14
c: str = "Hello, Flyte"
d: bool = False
inner_bm: InnerBM = field(default_factory=lambda: InnerBM())
```
### Goal: What should the final outcome look like, ideally?
These 2 cases should work.
https://github.com/flyteorg/flytekit/pull/2792/files#diff-779944519da7ce37ef29492b53edb53d653884263629341e4721c22d2223dedd
### Describe alternatives you've considered
Keep it the same.
### Propose: Link/Inline OR Additional context
https://github.com/flyteorg/flytekit/pull/2792#discussion_r1817308484
### Are you sure this issue hasn't been raised already?
- [X] Yes
### Have you read the Code of Conduct?
- [X] Yes
Contributor guide
Assessment
This issue has not been assessed yet.