Skip to content
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: Simplify hugr-model #1893

Merged
merged 4 commits into from
Feb 4, 2025
Merged

feat: Simplify hugr-model #1893

merged 4 commits into from
Feb 4, 2025

Conversation

zrho
Copy link
Contributor

@zrho zrho commented Jan 27, 2025

This PR simplifies hugr_model by moving every operation and term that can be defined as an extension to a core extension. This way we do not need special cases in the binary format, text format, validation (future), codegen (future), documentation generation (future). Closes #1900.

@hugrbot
Copy link
Collaborator

hugrbot commented Jan 27, 2025

This PR contains breaking changes to the public Rust API.
Please deprecate the old API instead (if possible), or mark the PR with a ! to indicate a breaking change.

cargo-semver-checks summary

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_missing.ron

Failed in:
enum hugr_model::v0::ParamSort, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:767

--- 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.39.0/src/lints/enum_variant_added.ron

Failed in:
variant Term:Tuple in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/mod.rs:655

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_variant_missing.ron

Failed in:
variant Term::Type, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:547
variant Term::StaticType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:552
variant Term::Constraint, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:557
variant Term::ApplyFull, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:582
variant Term::Const, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:592
variant Term::ListType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:612
variant Term::StrType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:627
variant Term::NatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:637
variant Term::ExtSetType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:650
variant Term::Adt, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:655
variant Term::FuncType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:662
variant Term::Control, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:681
variant Term::ControlType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:689
variant Term::NonLinearConstraint, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:692
variant Term::ConstAdt, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:704
variant Term::BytesType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:718
variant Term::Meta, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:721
variant Term::FloatType, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:730
variant Operation::CallFunc, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:318
variant Operation::LoadFunc, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:323
variant Operation::CustomFull, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:342
variant Operation::Tag, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:382
variant Operation::Const, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:410

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_missing.ron

Failed in:
struct hugr_model::v0::ConstructorDecl, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:510
struct hugr_model::v0::OperationDecl, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:523
struct hugr_model::v0::FuncDecl, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:486
struct hugr_model::v0::AliasDecl, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:499

--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_pub_field_missing.ron

Failed in:
field sort of struct Param, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-model/src/v0/mod.rs:762

@zrho zrho force-pushed the zrho/model-simplify branch from 734502b to 20246ce Compare January 27, 2025 18:56
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 64.02116% with 272 lines in your changes missing coverage. Please review.

Project coverage is 86.70%. Comparing base (d6b8681) to head (c9e53cc).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/import.rs 52.28% 102 Missing and 96 partials ⚠️
hugr-model/src/v0/text/print.rs 60.00% 5 Missing and 19 partials ⚠️
hugr-model/src/v0/text/parse.rs 68.42% 3 Missing and 15 partials ⚠️
hugr-core/src/export.rs 88.33% 14 Missing ⚠️
hugr-model/src/v0/binary/read.rs 74.50% 2 Missing and 11 partials ⚠️
hugr-model/src/v0/mod.rs 50.00% 3 Missing ⚠️
hugr-model/src/v0/binary/write.rs 95.74% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1893      +/-   ##
==========================================
+ Coverage   86.56%   86.70%   +0.14%     
==========================================
  Files         195      195              
  Lines       35724    35538     -186     
  Branches    32537    32351     -186     
==========================================
- Hits        30925    30814     -111     
+ Misses       3012     2951      -61     
+ Partials     1787     1773      -14     
Flag Coverage Δ
python 92.34% <ø> (ø)
rust 86.15% <64.02%> (+0.15%) ⬆️

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.

@zrho zrho force-pushed the zrho/model-simplify branch from e8816bc to 510e008 Compare January 28, 2025 21:01
@zrho zrho marked this pull request as ready for review January 28, 2025 21:13
@zrho zrho requested a review from a team as a code owner January 28, 2025 21:13
@zrho zrho requested review from mark-koch and ss2165 January 28, 2025 21:13
@ss2165 ss2165 requested review from aborgna-q and removed request for ss2165 and mark-koch February 4, 2025 10:58
Copy link
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

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

Looking clean!

My main request is taking it out of the default features.

hugr-core/Cargo.toml Outdated Show resolved Hide resolved
hugr-model/capnp/hugr-v0.capnp Outdated Show resolved Hide resolved
hugr-model/capnp/hugr-v0.capnp Outdated Show resolved Hide resolved
hugr-core/src/export.rs Outdated Show resolved Hide resolved
@aborgna-q
Copy link
Collaborator

Btw, I'm fine with not marking this PR as breaking since it's only an unstable -model change and -core doesn't need the mayor bump.

@zrho zrho added this pull request to the merge queue Feb 4, 2025
Merged via the queue into main with commit 2630e3d Feb 4, 2025
21 of 23 checks passed
@zrho zrho deleted the zrho/model-simplify branch February 4, 2025 18:12
@hugrbot hugrbot mentioned this pull request Feb 4, 2025
@hugrbot hugrbot mentioned this pull request Feb 5, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
## 🤖 New release

* `hugr`: 0.14.3
* `hugr-core`: 0.14.3
* `hugr-model`: 0.17.1
* `hugr-llvm`: 0.14.3
* `hugr-passes`: 0.14.3
* `hugr-cli`: 0.14.3

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr`

<blockquote>

##
[0.14.3](hugr-v0.14.2...hugr-v0.14.3)
- 2025-02-05

### Bug Fixes

- Export `RemoveDeadFuncsError` (#1883)
- const-folding Module keeps at least "main" (#1901)
- determine correct bounds of custom types (#1888)
- Exporting converging control flow edges (#1890)

### Documentation

- Fix deprecation warning messages (#1891)
- Explain why `ConstF64` is not PartialEq (#1829)

### New Features

- Special cased array, float and int constants in hugr-model export
(#1857)
- Simplify hugr-model (#1893)
</blockquote>

## `hugr-core`

<blockquote>

##
[0.14.3](hugr-core-v0.14.2...hugr-core-v0.14.3)
- 2025-02-05

### Bug Fixes

- determine correct bounds of custom types (#1888)
- Exporting converging control flow edges (#1890)

### Documentation

- Explain why `ConstF64` is not PartialEq (#1829)

### New Features

- Special cased array, float and int constants in hugr-model export
(#1857)
- Simplify hugr-model (#1893)
</blockquote>

## `hugr-model`

<blockquote>

##
[0.17.1](hugr-model-v0.17.0...hugr-model-v0.17.1)
- 2025-02-05

### Bug Fixes

- determine correct bounds of custom types (#1888)

### New Features

- Special cased array, float and int constants in hugr-model export
(#1857)
- Simplify hugr-model (#1893)
- Do not require `capnp` to be installed to compile `hugr-model` (#1907)
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.14.2](hugr-llvm-v0.14.1...hugr-llvm-v0.14.2)
- 2025-01-20

### New Features

- *(hugr-llvm)* Emit more int ops (#1835)
- Constant values in `hugr-model` (#1838)
- *(hugr-llvm)* Emit ipow (#1839)

### Refactor

- *(hugr-llvm)* [**breaking**] Optimise the llvm types used to represent
hugr sums. (#1855)

### Testing

- Fix failing inot test (#1841)
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.14.3](hugr-passes-v0.14.2...hugr-passes-v0.14.3)
- 2025-02-05

### Bug Fixes

- Export `RemoveDeadFuncsError` (#1883)
- const-folding Module keeps at least "main" (#1901)

### Documentation

- Fix deprecation warning messages (#1891)
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.14.1](hugr-cli-v0.14.0...hugr-cli-v0.14.1)
- 2024-12-18

### New Features

- Print `hugr-cli`'s correct version when using '--version' (#1790)
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: Agustín Borgna <agustin.borgna@quantinuum.com>
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.

Simplification of hugr-model
3 participants