Params language: one language at every depth

已关闭
#135 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@SimonHeybrock 已经在做这个了。

开始于 2026年11月3日。

  • #136 来自 @SimonHeybrock —— 已合并

评估

这个 Issue 还没有评估数据。

描述

With #133, a spec marks each field that a reference fills as Referenced[T]. Most rules that set a parameter apart from a field of a group existed because a reference inside a group was costly. They include: references only at a parameter or a row, flat groups, a "data value" that made a group reference-only, and "every parameter is a group". This issue makes the params language the same at every depth.

The language

A field of the params model, or of a group nested to any depth, is typed from a closed list:

int, float, str, bool, datetime, an enum, a Literal   # scalars
RunFile                                               # a file model
Specimen                                              # a group: its fields typed the same way
Annotated[A | B, Field(discriminator='kind')]         # a union of groups, tagged
Referenced[T]                                         # T a group; the framework does not look inside
X | None, list[X]                                     # X not a list, not X | None
Annotated[A | B, ...] | Referenced[C]                 # inline members and referenced members

Any other type is refused, such as a tuple, a dict, int | str, or sc.DataArray outside Referenced[T]. A group that contains itself is refused.

class Sample(BaseModel):
    run: SampleRun
    thickness: float = 1.0
    window: Window | None = None
    transmission: Referenced[Transmission]   # a reference at a field of a table row

class Params(BaseModel):
    samples: list[Sample]

How a group with a reference is validated

When A file A reference to an output
submit resolved to its identity through the validation context checked against history, at its position
run given its local path through the validation context replaced by its data through the validation context

When the request runs, the params model itself validates what the record stores, and the marker of Referenced[T] reads the data. A group that holds a reference runs its validators then; every other group is validated whole at submit.

Decisions

  • No "data value": a type outside the list is refused.
  • A parameter need not be a group. By convention it still is: a group is a tab of the form and a key of the binding. PipelineBinding requires keys= for any other parameter.
  • X | None at any depth: a choice with a "None" way in the form, files included.
  • Lists at any depth. Only a table is validated a row at a time, and only a table is limited to length constraints.
  • Table rows are distinct by their stored form only: a file by its identity, a reference by its record and output.
  • The discriminator sits on the union written inline, since a reference has no tag.
  • The term "place" goes, and ess.spec.places is folded into field_types and request_types.
主要语言
Python
星标
0
派生
1
平均合并
8 小时 48 分钟
30 天内合并 PR
70

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

scipp/essapps 的其他 Issue

查看 scipp/essapps 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。