Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Redesign plan argument handling

未关闭
#1,624 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
活跃
技术栈
python

调研方向

未指定任何文件或测试。首先跟踪当前的 pydantic 模型转换和 inject 方法,然后查看链接的 issue 以及现有讨论,以比较提出的设计。当确定一种既能保留现有计划,又能支持 injection、非设备对象、组合覆盖、类型检查以及位置参数或 vararg 参数,同时不产生所列依赖问题的方法时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

We currently build a pydantic model from the plan args and use that model to convert from the JSON params sent as part of a TaskRequest. This leads to several issues

  • All arguments must be addressable via keywords. Positional only args and varargs are not supported
  • Devices need special handling to convert from strings to devices #154
  • Composite devices (built at runtime from existing devices) have their handling intertwined with the device name to device handling
  • The inject method we currently use to provide default arguments to plans means plans can't be run outside blueapi but this is not restricted by python. Eg, calling a plan defined as def foo(mov: Movable = inject("bar")): ... fails with a run time error when trying to move the string instead of giving a type error. Type-checkers can't pick this up.
  • Non-devices are not supported (eg plans or clients for external services.)

Not directly related to using a model for validation but plan args are validated twice, once on submission and again when the plan is actually started.

Redesigning the way args are handled has been discussed several times and the general consensus was for the following requirements

  • We shouldn't have to change every existing plan. This would need a huge amount of churn and introduce new version dependencies
  • No new dependencies between blueapi and dodal/plan repo in either direction. A third API only package is not out of the question. (This may also be useful for utilities like the DeviceManager)
  • Devices built by a device manager should be injectable in a similar way to the current system
  • Non-devices should be available. Eg a config service client should be usable by plans without relying on global state
  • Composite devices should be built at runtime with overrides of individual components if possible
  • Type-checking should work
  • Vararg and positional only args should be supported (#1185)
  • Plan definitions should remain as simple as possible. A bit subjective but the current inject method is fairly concise.
    • If possible, less duplication than the current system would be good, eg foo: Movable = inject("foo") could be reduced to something like foo: Injected(Movable) and the name would not need to be duplicated.
主要语言
Python
星标
13
派生
14
平均合并
2 天 13 小时
30 天内合并 PR
18

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

DiamondLightSource/blueapi 的其他 Issue

查看 DiamondLightSource/blueapi 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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