Skip to content

Commit 37d6536

Browse files
graph: rename add_subgraph/add_conditional to add_subgraph_node/add_conditional_edge (#2)
Align method names with what they add. `add_subgraph_node` pairs with `add_node` as the non-default node variant; `add_conditional_edge` pairs with `add_edge` as the non-default edge variant. The implicit "a subgraph is added as a node" and "a conditional is an edge" framings become explicit at the call site. Pre-1.0 rename with no deprecation aliases per rough-edges.md.
1 parent e8f5de8 commit 37d6536

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/openarmature/graph/builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def add_node(
4343
self._nodes[name] = FunctionNode(name=name, fn=fn)
4444
return self
4545

46-
def add_subgraph(
46+
def add_subgraph_node(
4747
self,
4848
name: str,
4949
compiled: CompiledGraph,
@@ -59,7 +59,7 @@ def add_edge(self, source: str, target: str | EndSentinel) -> Self:
5959
self._edges.append(StaticEdge(source=source, target=target))
6060
return self
6161

62-
def add_conditional(
62+
def add_conditional_edge(
6363
self,
6464
source: str,
6565
fn: Callable[[Any], str | EndSentinel],

tests/conformance/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def build_graph(
211211
builder.add_edge(source, _resolve_target(edge_spec["to"]))
212212
elif "condition" in edge_spec:
213213
cond = edge_spec["condition"]
214-
builder.add_conditional(
214+
builder.add_conditional_edge(
215215
source,
216216
_make_conditional_fn(cond["if_field"], cond["equals"], cond["then"], cond["else"]),
217217
)

tests/unit/test_compile_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ def test_duplicate_subgraph_name_raises_value_error() -> None:
3636
inner = GraphBuilder(S).add_node("x", _noop).add_edge("x", END).set_entry("x").compile()
3737
builder = GraphBuilder(S).add_node("a", _noop)
3838
with pytest.raises(ValueError, match="already declared"):
39-
builder.add_subgraph("a", inner)
39+
builder.add_subgraph_node("a", inner)

tests/unit/test_runtime_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def node_a(_state: Any) -> dict[str, Any]:
3535
def bad_edge(_state: Any) -> str | EndSentinel:
3636
raise RuntimeError("edge boom")
3737

38-
g = GraphBuilder(S).add_node("a", node_a).add_conditional("a", bad_edge).set_entry("a").compile()
38+
g = GraphBuilder(S).add_node("a", node_a).add_conditional_edge("a", bad_edge).set_entry("a").compile()
3939

4040
with pytest.raises(EdgeException) as excinfo:
4141
await g.invoke(S())

tests/unit/test_subgraph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The conformance adapter routes around `SubgraphNode` via a function-node
44
wrapper (so it can record outer-graph execution order in the parent trace).
55
These tests exercise `SubgraphNode.run` directly, plus the
6-
`builder.add_subgraph` path that constructs one internally.
6+
`builder.add_subgraph_node` path that constructs one internally.
77
"""
88

99
from typing import Annotated, Any
@@ -42,7 +42,7 @@ async def x(_s: Any) -> dict[str, Any]:
4242
assert dict(result) == {"msg": "hello", "trace": ["x"]}
4343

4444

45-
async def test_outer_graph_composes_subgraph_via_add_subgraph() -> None:
45+
async def test_outer_graph_composes_subgraph_via_add_subgraph_node() -> None:
4646
async def x(_s: Any) -> dict[str, Any]:
4747
return {"msg": "from-x", "trace": ["x"]}
4848

@@ -68,7 +68,7 @@ async def outer_b(_s: Any) -> dict[str, Any]:
6868
outer = (
6969
GraphBuilder(Outer)
7070
.add_node("outer_a", outer_a)
71-
.add_subgraph("outer_sub", inner)
71+
.add_subgraph_node("outer_sub", inner)
7272
.add_node("outer_b", outer_b)
7373
.add_edge("outer_a", "outer_sub")
7474
.add_edge("outer_sub", "outer_b")

0 commit comments

Comments
 (0)