-
Notifications
You must be signed in to change notification settings - Fork 8
feat!: Add Hugr entrypoints #2147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-rs-v0.16.0
Are you sure you want to change the base?
Conversation
fix some root/entrypoint mixups snap! petgraph wrapper fix more things insert_hugr
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-rs-v0.16.0 #2147 +/- ##
======================================================
- Coverage 83.01% 82.70% -0.32%
======================================================
Files 219 218 -1
Lines 41331 41077 -254
Branches 37479 37225 -254
======================================================
- Hits 34310 33971 -339
- Misses 5194 5296 +102
+ Partials 1827 1810 -17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #2147 will degrade performances by 25.68%Comparing Summary
Benchmarks breakdown
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary
|
Adds the concept of "entrypoint" to the HUGRs, detaching the "main node of interest" from the hierarchy root.
Now hugrs will always have a
Module
at their root (appropriately calledHugrView::module_root
), and any manipulation is mostly focused around the entrypoint instead.Closes #2029
Closes #2010
before:
after:
How does this affect...
...HugrView?
::root
has been split intomodule_root
andentrypoint
. In general, you'll want to use the latter (as described in the docs).nodes()
is still defined, but now there's alsodescendants(node)
andentry_descendants()
, which should be preferred....builders?
The change should be transparent for hugr building operations. When you start an specific builder or call
Hugr::new(op)
we add additional nodes as necessary so that the new entrypoint is correctly defined inside a module;op
is a module, we just leave it at the top.op
can be defined in a module, we put it below the root.op
is a dataflow operation, we define a "main" function with the same signature and put it there....SiblingGraph, SiblingMut, and DescendantsGraph?
The structs are no more. Instead,
HugrView
has two new methods:with_entrypoint(&self, Node) -> Rerooted<&Self>
with_entrypoint_mut(&mut self, Node) -> Rerooted<&mut Self>
The new wrapper implements
HugrMut
, so it can be used transparently.The main benefit of this is that
Rerooted
still contains all the nodes that are not descendants from the entrypoint. So external edges are still well-defined, and rewrite operations may still put look at the root module and define things there if needed....serialization?
The hugr json now has an
entrypoint
field. If missing, we assume it's the root.For backwards compatibility, if the serialized root is not a module we will transparently wrap it as described before so older jsons will continue working without modifications.
hugr-module encoding is left as a TODO
...packages and envelopes?
Now every HUGR can be put in a package without modifications!
Ideally we'll now be able to remove the hugr <-> json methods and only use envelopes. (That's a TODO).
...mermaid/dot renders?
The entrypoint node is now highlighted in purple, and its title shown in bold between brackets. See the example above.
...passes?
Things should work as normal. New passes should look at the entrypoint and its descendants when looking for things to rewrite, instead of the whole hugr.
TODOs not in this PR:
hugr-py
#2148hugr-module
supportBREAKING CHANGE:
Hugr
s now have an entrypoint node.BREAKING CHANGE: Removed
SiblingGraph
/SiblingMut
/DescendantsGraph