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: Operation and constructor declarations in hugr-model #1605

Merged
merged 9 commits into from
Oct 31, 2024

Conversation

zrho
Copy link
Contributor

@zrho zrho commented Oct 22, 2024

This PR adds the ability to declare custom operations and constructors (so static types, runtime types, constraints, etc.) to hugr-model. In the case of operations this is used for deduplication when exporting.

@zrho zrho changed the title Operation and constructor declarations in hugr-model feat: Operation and constructor declarations in hugr-model Oct 22, 2024
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 78.37838% with 48 lines in your changes missing coverage. Please review.

Project coverage is 85.77%. Comparing base (fed74b5) to head (33e180e).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/import.rs 45.00% 13 Missing and 9 partials ⚠️
hugr-model/src/v0/text/parse.rs 74.46% 0 Missing and 12 partials ⚠️
hugr-model/src/v0/text/print.rs 78.57% 3 Missing and 6 partials ⚠️
hugr-model/src/v0/binary/read.rs 82.60% 0 Missing and 4 partials ⚠️
hugr-core/src/export.rs 98.21% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1605      +/-   ##
==========================================
+ Coverage   85.62%   85.77%   +0.14%     
==========================================
  Files         136      136              
  Lines       24929    25114     +185     
  Branches    21855    22040     +185     
==========================================
+ Hits        21346    21541     +195     
+ Misses       2476     2425      -51     
- Partials     1107     1148      +41     
Flag Coverage Δ
python 92.45% <ø> (ø)
rust 84.84% <78.37%> (+0.17%) ⬆️

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.

@hugrbot
Copy link
Collaborator

hugrbot commented Oct 22, 2024

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_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 /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/mod.rs:390
variant Operation:DeclareConstructor in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/mod.rs:349
variant Operation:DeclareOperation in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/mod.rs:357

@zrho zrho marked this pull request as ready for review October 29, 2024 18:56
@zrho zrho requested a review from a team as a code owner October 29, 2024 18:56
@zrho zrho requested a review from ss2165 October 29, 2024 18:56
hugr-core/src/export.rs Show resolved Hide resolved
hugr-core/src/export.rs Show resolved Hide resolved
hugr-model/tests/fixtures/model-decl-exts.edn Show resolved Hide resolved
@zrho
Copy link
Contributor Author

zrho commented Oct 31, 2024

CI indicates a breaking change, but the change is confined to the model which is considered unstable. Also while patch coverage is slightly low, this PR overall slightly improves test coverage.

@zrho zrho added this pull request to the merge queue Oct 31, 2024
Merged via the queue into main with commit 9962f97 Oct 31, 2024
20 of 22 checks passed
@zrho zrho deleted the zrho/model-declarative branch October 31, 2024 16:10
@hugrbot hugrbot mentioned this pull request Oct 31, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 6, 2024
## 🤖 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/).
@hugrbot hugrbot mentioned this pull request Nov 8, 2024
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.

3 participants