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: Special cased array, float and int constants in hugr-model export #1857

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

zrho
Copy link
Contributor

@zrho zrho commented Jan 13, 2025

This PR special cases the import/export of array, float and int constants so that they are represented as terms in hugr-model. This representation is a lot more efficient to handle than the encoding as JSON. In the future we should do this for all constants.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 74.03846% with 27 lines in your changes missing coverage. Please review.

Project coverage is 86.52%. Comparing base (b38a2e8) to head (b588731).

Files with missing lines Patch % Lines
hugr-core/src/import.rs 58.49% 10 Missing and 12 partials ⚠️
hugr-model/src/v0/text/print.rs 66.66% 2 Missing ⚠️
hugr-model/src/v0/binary/read.rs 75.00% 1 Missing ⚠️
hugr-model/src/v0/binary/write.rs 50.00% 1 Missing ⚠️
hugr-model/src/v0/text/parse.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1857      +/-   ##
==========================================
- Coverage   86.52%   86.52%   -0.01%     
==========================================
  Files         194      194              
  Lines       35250    35352     +102     
  Branches    32063    32165     +102     
==========================================
+ Hits        30501    30588      +87     
- Misses       2973     2975       +2     
- Partials     1776     1789      +13     
Flag Coverage Δ
python 92.34% <ø> (ø)
rust 85.94% <74.03%> (-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.

@hugrbot
Copy link
Collaborator

hugrbot commented Jan 15, 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_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.38.0/src/lints/enum_variant_added.ron

Failed in:
variant Term:Float in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/mod.rs:724
variant Term:FloatType in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-model/src/v0/mod.rs:730

@zrho zrho marked this pull request as ready for review January 16, 2025 14:49
@zrho zrho requested a review from a team as a code owner January 16, 2025 14:49
@zrho zrho requested a review from ss2165 January 16, 2025 14:49
@zrho zrho force-pushed the zrho/model-compact-arrays branch from 7b7bc0d to b588731 Compare January 16, 2025 15:59
Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

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

🚀

(@ arithmetic.float.types.float64)]])]
(ext))))))

(define-func example.f64
(define-func example.f64-json
Copy link
Member

Choose a reason for hiding this comment

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

is this still using json?

@@ -27,12 +27,13 @@ declarative = ["hugr-core/declarative"]
model_unstable = ["hugr-core/model_unstable", "hugr-model"]
llvm = ["hugr-llvm/llvm14-0"]
llvm-test = ["hugr-llvm/llvm14-0", "hugr-llvm/test-utils"]
default = ["model_unstable"]
Copy link
Member

Choose a reason for hiding this comment

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

😓

Copy link
Collaborator

Choose a reason for hiding this comment

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

Uhm. I think we should do unstable XOR default

self.print_text(format!("{:?}", value.into_inner()));
Ok(())
}
Term::FloatType => {
Copy link
Member

Choose a reason for hiding this comment

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

looks like float type isn't being covered, pls add to test

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.

4 participants