DiamondLightSource / DiamondLightSource/python-copier-template

Decide on a pydantic v3 BaseModel tagged union method and document it here

未關閉
#316 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Jinja
星號
25
分支
10
平均合併
4 小時 4 分鐘
30 天內合併 PR
6

描述

At the moment we have multiple ways of using pydantic and tagged unions:
- `scanspec` using pydantic dataclasses and a decorator to make a tagged union of subclasses, it requires positional args
- `FastCS` using plain dataclasses and a pydantic BaseModel creation function to do serialization and deserialization
- `pvi` uses an explicitly created union of BaseModels
- `ibek` uses automatically created Entity BaseModels from EntityModel instances
- `blueapi` does something with BaseModels too, but I can't remember what

With the advent of pydantic v3, now would be a good time to look at investigating a common approach for all these usecases. Standardising on BaseModel instances would probably give us the most tool support for things like documenting models in sphinx, FastAPI and GraphQL support, and downstream serialization

@GDYendell @gilesknap @DiamondJoseph @tpoliaw @abbiemery FYI

@hyperrealist I'm hoping you'll take this on at some point in the new year

貢獻指南

開啟貢獻指南

研究方向

首先比較 scanspec、FastCS、pvi、ibek 和 blueapi 所採用的 tagged-union 方法,同時考量 pydantic v3 中提議的變更。當各專案就通用的 BaseModel 方法達成共識,且該方法(包括相關取捨)已在此處記錄時,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
developer-experience, documentation
Issue 類型
文件
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。