-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: Add Package
definition on hugr-core
#1587
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1587 +/- ##
==========================================
- Coverage 85.79% 85.75% -0.04%
==========================================
Files 135 136 +1
Lines 24687 24746 +59
Branches 21623 21682 +59
==========================================
+ Hits 21180 21221 +41
- Misses 2405 2423 +18
Partials 1102 1102
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
btree_map::Entry::Occupied(mut prev) => { | ||
if prev.get().version() < extension.version() { | ||
*prev.get_mut() = extension.clone(); | ||
} | ||
Ok(prev.into_mut()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't appear to be tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📦
I added some Note that we are not enforcing that packages must only contain module-rooted HUGRs. |
Followup to #1587. Ensures that rust `Package`s only contain module-rooted hugrs. Returns errors at construction times if the condition is not met. This required fixing `hugr-cli`, as it should be able to load both packages and arbitrary hugrs. Added `Package::from_hugr{,s}` methods that try to wrap the hugrs if possible. We'll need these for tket2. Packages are not on the spec yet, their description should include this restriction. See #1388. This PR does only modify the (unpublished) API introduced in #1587, so I'm not marking it as breaking.
Replaces the breaking changes introduced in #1587 with non-breaking deprecations. We should be able to remove these on the next breaking release.
## 🤖 New release * `hugr`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-core`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-model`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-passes`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-cli`: 0.13.1 -> 0.13.2 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## [0.13.2](hugr-v0.13.1...hugr-v0.13.2) - 2024-10-22 ### Bug Fixes - Allocate ports on root nodes ([#1585](#1585)) ### New Features - Render function names in `mermaid`/`dot` ([#1583](#1583)) - Add filter_edge_kind to PortIterator ([#1593](#1593)) - make errors more readable with Display impls ([#1597](#1597)) - Ensure packages always have modules at the root ([#1589](#1589)) - Add `Package` definition on `hugr-core` ([#1587](#1587)) </blockquote> ## `hugr-core` <blockquote> ## [0.13.2](hugr-core-v0.13.1...hugr-core-v0.13.2) - 2024-10-22 ### Bug Fixes - Allocate ports on root nodes ([#1585](#1585)) ### New Features - Add `Package` definition on `hugr-core` ([#1587](#1587)) - Render function names in `mermaid`/`dot` ([#1583](#1583)) - Add filter_edge_kind to PortIterator ([#1593](#1593)) - make errors more readable with Display impls ([#1597](#1597)) - Ensure packages always have modules at the root ([#1589](#1589)) </blockquote> ## `hugr-model` <blockquote> ## [0.13.2](hugr-model-v0.13.1...hugr-model-v0.13.2) - 2024-10-22 ### New Features - make errors more readable with Display impls ([#1597](#1597)) </blockquote> ## `hugr-passes` <blockquote> ## [0.13.2](hugr-passes-v0.13.1...hugr-passes-v0.13.2) - 2024-10-22 ### New Features - make errors more readable with Display impls ([#1597](#1597)) </blockquote> ## `hugr-cli` <blockquote> ## [0.13.2](hugr-cli-v0.13.1...hugr-cli-v0.13.2) - 2024-10-22 ### New Features - Add `Package` definition on `hugr-core` ([#1587](#1587)) - Ensure packages always have modules at the root ([#1589](#1589)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
## 🤖 New release * `hugr`: 0.13.2 -> 0.13.3 (✓ API compatible changes) * `hugr-core`: 0.13.2 -> 0.13.3 (✓ API compatible changes) * `hugr-model`: 0.13.2 -> 0.14.0 (⚠️ API breaking changes) * `hugr-passes`: 0.13.2 -> 0.13.3 * `hugr-cli`: 0.13.2 -> 0.13.3 ###⚠️ `hugr-model` breaking changes ``` --- failure enum_variant_added: enum variant added on exhaustive enum --- Description: A publicly-visible enum without #[non_exhaustive] has a new variant. ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_variant_added.ron Failed in: variant RegionKind:Module in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:390 variant Operation:DeclareConstructor in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:349 variant Operation:DeclareOperation in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:357 ``` <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## [0.13.3](hugr-v0.13.2...hugr-v0.13.3) - 2024-11-06 ### Bug Fixes - Insert DFG directly as a funcdefn in `Package::from_hugr` ([#1621](#1621)) ### New Features - `HugrMut::remove_metadata` ([#1619](#1619)) - Operation and constructor declarations in `hugr-model` ([#1605](#1605)) - Add TailLoop::BREAK_TAG and CONTINUE_TAG ([#1626](#1626)) </blockquote> ## `hugr-core` <blockquote> ## [0.13.3](hugr-core-v0.13.2...hugr-core-v0.13.3) - 2024-11-06 ### Bug Fixes - Insert DFG directly as a funcdefn in `Package::from_hugr` ([#1621](#1621)) ### New Features - `HugrMut::remove_metadata` ([#1619](#1619)) - Operation and constructor declarations in `hugr-model` ([#1605](#1605)) - Add TailLoop::BREAK_TAG and CONTINUE_TAG ([#1626](#1626)) </blockquote> ## `hugr-model` <blockquote> ## [0.14.0](hugr-model-v0.13.2...hugr-model-v0.14.0) - 2024-11-06 ### New Features - Operation and constructor declarations in `hugr-model` ([#1605](#1605)) </blockquote> ## `hugr-passes` <blockquote> ## [0.13.2](hugr-passes-v0.13.1...hugr-passes-v0.13.2) - 2024-10-22 ### New Features - make errors more readable with Display impls ([#1597](#1597)) </blockquote> ## `hugr-cli` <blockquote> ## [0.13.2](hugr-cli-v0.13.1...hugr-cli-v0.13.2) - 2024-10-22 ### New Features - Add `Package` definition on `hugr-core` ([#1587](#1587)) - Ensure packages always have modules at the root ([#1589](#1589)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
Followup to #1587. Ensures that rust `Package`s only contain module-rooted hugrs. Returns errors at construction times if the condition is not met. This required fixing `hugr-cli`, as it should be able to load both packages and arbitrary hugrs. Added `Package::from_hugr{,s}` methods that try to wrap the hugrs if possible. We'll need these for tket2. Packages are not on the spec yet, their description should include this restriction. See #1388. This PR does only modify the (unpublished) API introduced in #1587, so I'm not marking it as breaking.
Replaces the breaking changes introduced in #1587 with non-breaking deprecations. We should be able to remove these on the next breaking release.
## 🤖 New release * `hugr`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-core`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-model`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-passes`: 0.13.1 -> 0.13.2 (✓ API compatible changes) * `hugr-cli`: 0.13.1 -> 0.13.2 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## [0.13.2](hugr-v0.13.1...hugr-v0.13.2) - 2024-10-22 ### Bug Fixes - Allocate ports on root nodes ([#1585](#1585)) ### New Features - Render function names in `mermaid`/`dot` ([#1583](#1583)) - Add filter_edge_kind to PortIterator ([#1593](#1593)) - make errors more readable with Display impls ([#1597](#1597)) - Ensure packages always have modules at the root ([#1589](#1589)) - Add `Package` definition on `hugr-core` ([#1587](#1587)) </blockquote> ## `hugr-core` <blockquote> ## [0.13.2](hugr-core-v0.13.1...hugr-core-v0.13.2) - 2024-10-22 ### Bug Fixes - Allocate ports on root nodes ([#1585](#1585)) ### New Features - Add `Package` definition on `hugr-core` ([#1587](#1587)) - Render function names in `mermaid`/`dot` ([#1583](#1583)) - Add filter_edge_kind to PortIterator ([#1593](#1593)) - make errors more readable with Display impls ([#1597](#1597)) - Ensure packages always have modules at the root ([#1589](#1589)) </blockquote> ## `hugr-model` <blockquote> ## [0.13.2](hugr-model-v0.13.1...hugr-model-v0.13.2) - 2024-10-22 ### New Features - make errors more readable with Display impls ([#1597](#1597)) </blockquote> ## `hugr-passes` <blockquote> ## [0.13.2](hugr-passes-v0.13.1...hugr-passes-v0.13.2) - 2024-10-22 ### New Features - make errors more readable with Display impls ([#1597](#1597)) </blockquote> ## `hugr-cli` <blockquote> ## [0.13.2](hugr-cli-v0.13.1...hugr-cli-v0.13.2) - 2024-10-22 ### New Features - Add `Package` definition on `hugr-core` ([#1587](#1587)) - Ensure packages always have modules at the root ([#1589](#1589)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
## 🤖 New release * `hugr`: 0.13.2 -> 0.13.3 (✓ API compatible changes) * `hugr-core`: 0.13.2 -> 0.13.3 (✓ API compatible changes) * `hugr-model`: 0.13.2 -> 0.14.0 (⚠️ API breaking changes) * `hugr-passes`: 0.13.2 -> 0.13.3 * `hugr-cli`: 0.13.2 -> 0.13.3 ###⚠️ `hugr-model` breaking changes ``` --- failure enum_variant_added: enum variant added on exhaustive enum --- Description: A publicly-visible enum without #[non_exhaustive] has a new variant. ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_variant_added.ron Failed in: variant RegionKind:Module in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:390 variant Operation:DeclareConstructor in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:349 variant Operation:DeclareOperation in /tmp/.tmpL1Ich1/hugr/hugr-model/src/v0/mod.rs:357 ``` <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## [0.13.3](hugr-v0.13.2...hugr-v0.13.3) - 2024-11-06 ### Bug Fixes - Insert DFG directly as a funcdefn in `Package::from_hugr` ([#1621](#1621)) ### New Features - `HugrMut::remove_metadata` ([#1619](#1619)) - Operation and constructor declarations in `hugr-model` ([#1605](#1605)) - Add TailLoop::BREAK_TAG and CONTINUE_TAG ([#1626](#1626)) </blockquote> ## `hugr-core` <blockquote> ## [0.13.3](hugr-core-v0.13.2...hugr-core-v0.13.3) - 2024-11-06 ### Bug Fixes - Insert DFG directly as a funcdefn in `Package::from_hugr` ([#1621](#1621)) ### New Features - `HugrMut::remove_metadata` ([#1619](#1619)) - Operation and constructor declarations in `hugr-model` ([#1605](#1605)) - Add TailLoop::BREAK_TAG and CONTINUE_TAG ([#1626](#1626)) </blockquote> ## `hugr-model` <blockquote> ## [0.14.0](hugr-model-v0.13.2...hugr-model-v0.14.0) - 2024-11-06 ### New Features - Operation and constructor declarations in `hugr-model` ([#1605](#1605)) </blockquote> ## `hugr-passes` <blockquote> ## [0.13.2](hugr-passes-v0.13.1...hugr-passes-v0.13.2) - 2024-10-22 ### New Features - make errors more readable with Display impls ([#1597](#1597)) </blockquote> ## `hugr-cli` <blockquote> ## [0.13.2](hugr-cli-v0.13.1...hugr-cli-v0.13.2) - 2024-10-22 ### New Features - Add `Package` definition on `hugr-core` ([#1587](#1587)) - Ensure packages always have modules at the root ([#1589](#1589)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
Moves the definition of packages out of
hugr-cli
. (We leave a re-export there to avoid breaking the API, it should be removed on the next breaking release).Adds some helper functions to load and validate the package.
Closes #1530
drive-by: Replace
hugr-core
dependency onhugr-cli
byhugr
. There's no need to access the internals there.