Skip to content

fix(core): accept edge_attr and other attribute dicts in visualize() - #938

Open
breken-ai wants to merge 1 commit into
apache:mainfrom
breken-ai:fix/visualize-edge-attr
Open

breken-ai wants to merge 1 commit into
apache:mainfrom
breken-ai:fix/visualize-edge-attr

Conversation

@breken-ai

Copy link
Copy Markdown

Application.visualize() and Graph.visualize() pass **engine_kwargs through to graphviz.Digraph. Dict values are merged into Burr's default attributes. Only graph_attr and node_attr have defaults, so any other attribute dict fails. For example, styling edges:

app.visualize(edge_attr={"color": "red"})
# KeyError: 'edge_attr'
#   burr/core/graph.py, in visualize: digraph_attr[g_key].update(**g_value)

Changes

  • burr/core/graph.py: merge into digraph_attr.setdefault(g_key, {}), so a dict kwarg with no Burr default is passed to graphviz as given. graph_attr / node_attr still merge over Burr's defaults, as before.
  • tests/core/test_graphviz_display.py: a regression that passes graph_attr, node_attr and edge_attr, and checks that each reaches the Digraph with Burr's defaults kept.

How I tested this

  • On main (8161159), the new test fails with KeyError: 'edge_attr'. With the fix, it passes.
  • End to end, ApplicationBuilder()...build().visualize(edge_attr={"color": "red"}) raises KeyError on main. On this branch it returns a Digraph with edge_attr == {"color": "red"}.
  • pytest tests/core: 401 passed (with graphviz installed).
  • black 23.11.0 (--line-length=100), isort 5.12.0 and flake8 6.1.0 at the pre-commit pins are clean on the changed files.

Notes

This is a one-line change. The merge loop has been in place since f1d935b (2024-06).

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output) (no new functions)
  • Placeholder code is flagged / future TODOs are captured in comments (none added)
  • Project documentation has been updated if adding/changing functionality (no documented behavior changes; engine_kwargs is already documented as passed to the engine)

AI disclosure (per the ASF Generative Tooling guidance): an AI coding tool (Claude Code, Claude Opus 5.5) wrote this change through the breken-ai account. The tool found the bug, wrote the fix and the test, and wrote this description. The commit carries a Generated-by: trailer. The diff is a small original change to existing Burr code and includes no third-party material. The red/green runs above are real, and you can re-run them from the diff. If you would rather not take AI-assisted contributions here, say so and I will close this.

🤖 Generated with Claude Code

Graph.visualize() (and Application.visualize()) pass **engine_kwargs to
graphviz.Digraph, merging dict values into Burr's defaults. Only
graph_attr and node_attr have defaults, so passing any other dict such
as edge_attr={"color": "red"} raised KeyError: 'edge_attr'.

Merge into an empty dict when Burr has no default for that key.

Generated-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the area/core Application, State, Graph, Actions label Sep 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Application, State, Graph, Actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant