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

Bundling Actions Together

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
backend

调研方向

从 AppBuilder 和 GraphBuilder 开始,然后追踪 actions、transitions、subgraphs 和 MappedStates 的表示方式。将提议的 MultiAction 和 ActionChain 入口点与现有的 builder API 进行比较,包括 with_subgraph 替代方案。完成的标准是项目拥有一个达成共识的可复用 action-graph 设计,包括任何输入/输出重映射以及验证行为。

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

描述

area/core kind/feature priority/medium

Is your feature request related to a problem? Please describe.

@gamarin2 asks:

Hey! While working with class-based actions, I ended up creating state transitions that must logically be split in two separate actions, but where the second one must always be preceded by the first one.

In my case, it's a FormatSummarizer action that formats messages before transitioning to a Summarizer action. These two actions form what I would call an "action bundle": the second one can't be separated from the first one. For now, I have documented that requirement in my class docstring, but it would be nice to have it more strictly enforced. 

I'm sure there are various ways we could achieve this, but perhaps the easiest would be to add a property to the action class where you could specify preceding/following action classes. The AppBuilder would then fail to build if you haven't added the proper transitions.

@mdrideout also suggests:

I would say that I have a very large number of use cases for this, and creating an entire sub-graph for it is painful.

To piggyback on this, I also have a very large number of use cases for running actions with high concurrency, and have been creating sub-graphs simply for the purpose of running a single action for ~10 items. 
but I may be doing this as a workaround because I had a some issues trying to use MappedStates (?) with either pydantic or async.

Describe the solution you'd like
A way to have an action represent a graph.

class MultiAction:
    @abc.abstractmethod
    def get_graph() -> Graph:
        ...

class ActionChain(MultiAction):
    @abc.abstractmethod
    def get_actions() -> List[[Tuple[str, Union[Action, Callable]]]:
        ...

    def get_graph() -> Graph:
        named_actions = self.get_actions()
        action_names = [name for name, _ in named_actions]
        return GraphBuilder().with_actions(**dict(actions)).with_transitions(zip(action_name, action_names[1:]))

Describe alternatives you've considered
Could also have with_subgraph in builder, similar thing. This allows for packaging at the action level for reusability. Might also want the ability to remap inputs/outputs:

def state_maps() -> Tuple[dict, dict]:
    ....

Additional context
Add any other context or screenshots about the feature request here.

主要语言
Python
星标
2.6k
派生
199
平均合并
3 天 10 小时
30 天内合并 PR
6

环境准备

从这里开始

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

apache/burr 的其他 Issue

查看 apache/burr 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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