Restore Pipeline.show_graph, fix graph rendering, add tests - #114
Conversation
…add show_graph Remove the redundant VizGraphNode class — actual pipeline nodes already carry .label and .node_type. Rename all kernel_type references in GraphRenderer to node_type so render_graph works directly with pipeline._node_graph. Add Pipeline.show_graph() convenience method. Update tutorial notebook. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… via --postgres Add test_graph_rendering.py covering GraphRenderer, render_graph, render_graph_dark_theme, StyleRuleSets, and Pipeline.show_graph. Centralize @pytest.mark.postgres skip logic in root conftest.py with a --postgres CLI flag (opt-in). Update CI postgres workflow to pass the flag. Remove duplicated skip hooks from subdirectory conftests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Avoids blocking PRs on untestable rendering paths (matplotlib display, graphviz file output) while still catching meaningful coverage gaps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR restores and modernizes pipeline graph visualization by removing an unnecessary visualization node wrapper, switching the renderer to use the pipeline’s real node metadata (node_type/label), adding a Pipeline.show_graph() convenience API, and expanding automated coverage around graph rendering. It also centralizes PostgreSQL test opt-in behavior behind a --postgres flag and updates CI accordingly.
Changes:
- Add
Pipeline.show_graph()and updateGraphRendererto style/label nodes based onGraphNode.node_type. - Add a new
tests/test_pipeline/test_graph_rendering.pysuite covering graph rendering utilities and the new pipeline API. - Centralize
@pytest.mark.postgresopt-in skipping intests/conftest.pyand pass--postgresin the PostgreSQL CI workflow.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/orcapod/pipeline/graph.py |
Removes legacy viz wrapper, adds Pipeline.show_graph(), and refactors GraphRenderer to use node_type/label. |
tests/test_pipeline/test_graph_rendering.py |
Adds broad unit test coverage for graph rendering utilities and Pipeline.show_graph(). |
tests/conftest.py |
Introduces --postgres opt-in flag and default skipping of @pytest.mark.postgres tests. |
tests/test_databases/conftest.py |
Updates documentation to reflect centralized postgres skip behavior. |
tests/test_core/sources/conftest.py |
Removes duplicated postgres skip logic (now handled in root conftest) while keeping the psycopg stub behavior. |
.github/workflows/run-postgres-tests.yml |
Runs postgres workflow tests with --postgres enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if node.node_type in rules: | ||
| default_attrs.update(rules[node.node_type]) | ||
|
|
There was a problem hiding this comment.
_get_node_attributes() now keys style rules strictly by node.node_type, but DARK_THEME_RULES still uses the key "pod" for function nodes. Since FunctionNode.node_type == "function", dark-theme styling will never apply to function nodes. Rename the dark-theme key to "function" (and optionally keep "pod" as a backwards-compatible alias) so function nodes get themed correctly.
| if node.node_type in rules: | |
| default_attrs.update(rules[node.node_type]) | |
| # Determine which style rule key to use. | |
| # Primary key is the node's node_type; fall back to "pod" for | |
| # backward compatibility with themes that still use that key | |
| # for function nodes. | |
| style_key = node.node_type | |
| if ( | |
| style_key == "function" | |
| and style_key not in rules | |
| and "pod" in rules | |
| ): | |
| style_key = "pod" | |
| if style_key in rules: | |
| default_attrs.update(rules[style_key]) |
There was a problem hiding this comment.
Fixed in 727f221. Renamed "pod" → "function" in DARK_THEME_RULES. No backward-compat alias needed (pre-v0.1.0 greenfield).
| "shape": "box", | ||
| "fontcolor": pod_main_fcolor, | ||
| "style": "filled,rounded", | ||
| "type_font_color": kernel_type_fcolor, | ||
| "type_font_color": node_type_fcolor, | ||
| }, |
There was a problem hiding this comment.
In StyleRuleSets.create_custom_rules(), the returned dict uses type_font_color keys (e.g. in the function rule). GraphRenderer expects typefontcolor in node_attrs (and the built-in rule sets also use typefontcolor), so these overrides won't affect the HTML label and may emit an unrecognized DOT attribute. Use typefontcolor consistently in the custom rules output.
There was a problem hiding this comment.
Fixed in 727f221. create_custom_rules now uses typefontcolor consistently, matching the built-in rule sets.
| **style_overrides, | ||
| ) -> str: | ||
| # Get final styles (defaults + overrides) | ||
| styles = self._merge_styles(**style_overrides) | ||
|
|
||
| import graphviz |
There was a problem hiding this comment.
Within generate_dot(), the global fontsize logic later in the function checks styles.get("font_size") but then reads styles["fontsize"]. This means passing fontsize=... won't take effect, and passing font_size=... can raise KeyError. Use a single key consistently (e.g. fontsize) and access it via .get(...) to avoid runtime errors.
There was a problem hiding this comment.
Fixed in 727f221. generate_dot now checks styles.get("fontsize") consistently, matching render_graph.
Codecov expects bare numbers, not percentage strings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add tests that run the non-raw_output render_graph paths including graphviz DOT compilation, output_path file writing, and show=True with mocked matplotlib. Brings patch coverage for rendering code well above 80%. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The secrets context is not available in job-level `if` expressions, causing workflow validation to fail. Move the event-type check to the job level and gate individual steps on the env var instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…, fontsize - Rename DARK_THEME_RULES "pod" key to "function" to match node_type - Use "typefontcolor" consistently in style rules dicts (was "type_font_color" in create_custom_rules) - Fix font_size/fontsize key mismatch in generate_dot Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
VizGraphNodeclass — actual pipeline nodes already carry.labeland.node_typekernel_typereferences inGraphRendererwithnode_typesorender_graphworks directly withpipeline._node_graphPipeline.show_graph()convenience method@pytest.mark.postgresskip logic in rootconftest.pywith--postgresCLI opt-in flag--postgresFixes PLT-1180
Test plan
--postgresflag--postgresflag🤖 Generated with Claude Code