Make key_source restrict-only: add key_source_restriction, deprecate parent-redefining overrides
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- python
研究方向
從 Autopopulate spec §2 以及其中參照的 how-to 頁面開始,接著追蹤 populate() 和 make(key),以了解目前 key_source 的行為。搭配 rollout 要求檢視協調進行的 datajoint-docs 任務。當支援 key_source_restriction、重新定義 parent 的覆寫會發出警告,且文件建議使用 restriction 和 master–part 批次處理時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Summary
Make key_source a restrict-only surface. Today key_source can be overridden freely, including in ways that redefine the parent join — and that is the source of subtle, hard-to-diagnose bugs. Introduce a first-class key_source_restriction that applies a restriction to the default key_source without changing the parents, and steer users (and the docs) toward it.
Background
key_source defaults to the join of the tables referenced by the foreign keys in a computed/imported table's primary key (Autopopulate → Key Source Calculation). populate() iterates over it, passing each key to make(key).
The default is almost always correct. In practice, the only legitimate reason to modify it is to restrict it — compute a subset of the default source (e.g. a completion barrier that fires only when all members of a batch have results). Restricting keeps the parents and the grain intact; each make(key) still receives a fully-formed primary key.
Overriding key_source to redefine the parent join — dropping a parent, adding one, or reconstructing the key from an aggregate — is a different and dangerous operation: it can change or drop primary-key attributes, so make(key) receives a key that is missing attributes or has attributes the table's primary key doesn't declare. The downstream effects (partial inserts, mismatched keys, silent miscomputation) are hard to reason about, and the framework was not designed for it.
Proposal
- Introduce
key_source_restriction— a declared restriction applied to the defaultkey_source. It may be any valid DataJoint restriction, including a restriction by another table (a dependency visible inkey_sourcebut not necessarily as a formal FK edge). The computed source isdefault_key_source & key_source_restriction; the parents and grain are never changed. - Deprecate user-facing redefinition of
key_source. Treatkey_sourceas an internal of the auto-populate machinery. Emit a warning when a subclass overrideskey_sourcein a way that changes the parent join. - Batching is a master–part concern, not a
key_sourceconcern. A run/cohort-level batch should be a master keyed on the batch with per-member results on a part — consistent with the DataJoint 2 rule that an auto-populated table introduces no new dimension (only its parts may). This removes the historical "batch by overridingkey_source" motivation.
Rollout (per the 2026-07-24 design discussion)
- 2.4: add
key_source_restriction; begin warning on parent-redefiningkey_sourceoverrides. - Docs now: remove
key_source-override guidance/recommendations from the documentation; documentkey_source_restrictionas the supported way to narrow a source. - Later: make
key_sourcerestriction-only (the override path removed as a user surface).
Docs task (coordinated)
datajoint-docs: pull any recommendation to override key_source, and document key_source_restriction + the "batch via master–part" guidance. (Autopopulate spec §2 and the how-to pages.)
cc @MilagrosMarin @ttngu207
- 主要語言
- Python
- 星號
- 197
- 分支
- 98
- 平均合併
- 6 天 10 小時
- 30 天內合併 PR
- 4
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
datajoint/datajoint-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 則留言 ·
-
dj.Diagram SVG output is not byte-reproducible: set iteration order leaks into node emission order 未關閉bug
難度 3/5 1-2 天 新手友好度 78/100
datajoint/datajoint-python#1551 ·
-
難度 5/5 一週以上 新手友好度 35/100
datajoint/datajoint-python#1550 ·
-
難度 5/5 一週以上 新手友好度 35/100
datajoint/datajoint-python#1547 ·
-
難度 4/5 3-5 天 新手友好度 52/100
datajoint/datajoint-python#1546 · 1 則留言 ·
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 74/100