Skip to content

feat(hugr_py)!: operation parameter rendering in HUGR visualizations#2995

Merged
nicolaassolini-qntm merged 2 commits intomainfrom
na/2890-show-operation-parameters-when-rendering-hugrs
Mar 30, 2026
Merged

feat(hugr_py)!: operation parameter rendering in HUGR visualizations#2995
nicolaassolini-qntm merged 2 commits intomainfrom
na/2890-show-operation-parameters-when-rendering-hugrs

Conversation

@nicolaassolini-qntm
Copy link
Copy Markdown
Contributor

@nicolaassolini-qntm nicolaassolini-qntm commented Mar 30, 2026

close #2890

Changed the hugr rendering in hugr-py/render.py to render in the node the type args of the operation.

BREAKING CHANGE: Substituted hugr-py/src/hugr/tys.py::_type_str with hugr-py/src/hugr/utils.py::name_w_args

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates HUGR graphviz rendering in hugr-py to display operation parameters (type args) directly in node labels, aligning operation rendering with existing type parameter rendering and addressing #2890.

Changes:

  • Render AsExtOp and Custom operation type arguments in node labels during HUGR visualization.
  • Introduce hugr.utils.name_w_args() as a shared formatter for name<type_args> strings.
  • Replace the private _type_str helper in tys.py with name_w_args, updating relevant __str__ implementations and snapshots.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
hugr-py/src/hugr/hugr/render.py Adds operation-argument rendering for node labels (via name_w_args) using pattern matching on op types.
hugr-py/src/hugr/utils.py Introduces name_w_args() helper for consistent name<args> formatting.
hugr-py/src/hugr/tys.py Switches type string formatting to use name_w_args (removing _type_str).
hugr-py/tests/__snapshots__/test_hugr_build.ambr Updates expected rendered output to include operation parameters in node labels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.29%. Comparing base (3bd7a88) to head (faca4b1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
hugr-py/src/hugr/hugr/render.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2995      +/-   ##
==========================================
- Coverage   81.29%   81.29%   -0.01%     
==========================================
  Files         239      239              
  Lines       45350    45354       +4     
  Branches    39160    39160              
==========================================
+ Hits        36866    36869       +3     
- Misses       6493     6494       +1     
  Partials     1991     1991              
Flag Coverage Δ
python 88.90% <95.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicolaassolini-qntm nicolaassolini-qntm added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit d619148 Mar 30, 2026
29 checks passed
@nicolaassolini-qntm nicolaassolini-qntm deleted the na/2890-show-operation-parameters-when-rendering-hugrs branch March 30, 2026 12:32
github-merge-queue bot pushed a commit that referenced this pull request Apr 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.16.0](hugr-py-v0.15.4...hugr-py-v0.16.0)
(2026-04-01)

This release changes the default text serialization format from JSON to
`MODEL_WITH_EXTS` (the JSON format is now deprecated).
It also adds the ability to link packages and modules from Python,
renders operation type arguments in HUGR visualizations, introduces a
new `debug_info` module for attaching source-level debug metadata to
nodes,
and introduces multi-version support in `ExtensionRegistry`, allowing
different versions of the same extension to coexist in the same
registry.


### ⚠ BREAKING CHANGES

* `ExtensionRegistry` may now contain multiple versions of the same
extension. `.extensions` is now an iterator of the latest versions
instead of a dictionary. `.register_updated` and `.add_extension` have
been replaced with a singular `.register`.
* Default `EnvelopeConfig` changed from `EnvelopeFormat.JSON` to
`EnvelopeFormat.MODEL_WITH_EXTS`.
* Substituted `hugr-py/src/hugr/tys.py::_type_str` with
`hugr-py/src/hugr/utils.py::name_w_args`.

### Features

* Add debug info metadata specification in `hugr-py`
([#2971](#2971))
([a4da8ef](a4da8ef))
* Allow multiple versions of an extension in an ExtensionRegistry
([#3005](#3005))
([ee90cd1](ee90cd1))
* Deprecate JSON serialization format
([#2991](#2991))
([0f7a880](0f7a880))
* Operation parameter rendering in HUGR visualizations
([#2995](#2995))
([d619148](d619148))
* Allow linking packages and modules from Python
([#2947](#2947))
([329c243](329c243))
* Make `_composable_pass` and `_scope` public modules
([#2962](#2962))
([1d6af9a](1d6af9a)),
closes [#2961](#2961)
* Allow missing ext versions ExtensionDesc metadata
([#2979](#2979))
([bc1c445](bc1c445))
* Allow dfg conversion in to TrackedDfg
([#2993](#2993))
([3bd7a88](3bd7a88))


### Bug Fixes

* Allow both _composable_pass and composable_pass imports
([#2965](#2965))
([0a5664d](0a5664d))
* Allow both _scope and scope imports
([#3003](#3003))
([de0458c](de0458c))
* Always do extension resolution when loading packages and hugrs
([#2953](#2953))
([0086d2a](0086d2a))
* Correct pyo3 module definitions and add missing exception class export
([#2964](#2964))
([3df73f4](3df73f4))
* Include extensions during link serialization
([#2992](#2992))
([9236e89](9236e89))
* Prefix names with underscores during serialization
([#2989](#2989))
([8aab636](8aab636))
* Use valid identifiers when constructing AST model
([#2973](#2973))
([8750a6b](8750a6b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Agustín Borgna <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Show operation parameters when rendering hugrs

3 participants