Replace IO and IORefs with getters/setters
维护者通常 6 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
Start by reading the existing AttributeIO and AttributeIORef implementations and controller attribute APIs; this issue does not name their file paths or tests. Review the linked prerequisite issue #442 and trace how attributes are read, written, polled, and mirrored to transports. Done means replacing IO and IORef usage with per attribute getters and setters and meeting the acceptance criteria.
由索引模型根据 Issue 内容生成。
描述
IOs and IORefs make writing simple controllers verbose:
@dataclass
class HelloIORef(AttributeIORef):
key: str
_: KW_ONLY
update_period: float | None = 0.5
class HelloIO(AttributeIO[Any, HelloIORef]):
def __init__(self, device): super().__init__(); self._device = device
async def update(self, attr):
await attr.update(await self._device.get(attr.io_ref.key))
async def send(self, attr, value):
await self._device.set(attr.io_ref.key, value)
class HelloController(Controller):
message = AttrR(String(), io_ref=HelloIORef("message"))
def __init__(self):
self._device = HelloDevice()
super().__init__(ios=[HelloIO(self._device)])
We should replace AttributeIO/AttributeIORef with per-attribute getter/setter callables:
class HelloController(Controller):
def __init__(self, device):
self._device = device
super().__init__()
self.message = AttrRW(
String(), # optional: would be inferred from `-> str`
getter=Polled(self._get_message, period=1.0),
setter=self._set_message,
)
async def _get_message(self) -> str:
return await self._device.get("message")
async def _set_message(self, message: str) -> None:
await self._device.set("message", message)
- Scheduling: bare getter → read once on connect;
Polled(fn, period=...)→ polled;
NotPolled(fn)→ only onawait attr.poll() - Datatype inferred from getter return / setter parameter (int, float, bool, str, Enum)
- Getters/setters may return
Update(readback, setpoint=...); a setter's bare return
value is the device-accepted value - Attribute owns the setpoint; all transports mirror it via
add_setpoint_callback
(removes per-transport seeding)
Breaking changes
ios=removed from controllers;AttributeIO,AttributeIORefremovedAttribute[T, Ref]→Attribute[T], as no reference requiredget()→.readback,put()→set(), callback renames, removed methods (list)update_period=Nonerefs should migrate toNotPolled
Depends on https://github.com/DiamondLightSource/fastcs/issues/442.
Acceptance Criteria
- IOs and IORefs are replaced with getter/setter
- 主要语言
- Python
- 星标
- 6
- 派生
- 8
- 平均合并
- 3 天 22 小时
- 30 天内合并 PR
- 3
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DiamondLightSource/fastcs 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
DiamondLightSource/fastcs#443 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
DiamondLightSource/fastcs#437 ·
维护者通常 6 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
DiamondLightSource/fastcs#416 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
DiamondLightSource/fastcs#345 ·
维护者通常 6 天内回复
-
难度 1/5 1-3 小时 新手友好度 62/100
DiamondLightSource/fastcs#341 ·
维护者通常 6 天内回复
查看 DiamondLightSource/fastcs 的全部 Issue
相似的 Issue
-
eegprep-lean: set channel types from the Zarr group's channel_type可能已有人在做 @claude 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
blacklanternsecurity/bbot#3679 ·
维护者通常 2 天内回复
-
Bot Type: Bug Type: Documentation
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 80/100
speakeasy-api/speakeasy#2159 ·
维护者通常 1 天内回复