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

fix!: serialisation schema #968

Merged
merged 16 commits into from
Apr 30, 2024
Merged

fix!: serialisation schema #968

merged 16 commits into from
Apr 30, 2024

Conversation

doug-q
Copy link
Collaborator

@doug-q doug-q commented Apr 24, 2024

BEGIN_COMMIT_OVERRIDE
fix: Serialisation for Type, PolyFuncType, and Value (#968)
END_COMMIT_OVERRIDE

@doug-q doug-q force-pushed the feat/sumtype-serialisation branch 3 times, most recently from 6e079a5 to e309c00 Compare April 24, 2024 12:51
Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 90.69767% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 85.87%. Comparing base (76dcc80) to head (d82db9c).

Files Patch % Lines
hugr/src/types/type_param.rs 0.00% 3 Missing ⚠️
hugr/src/hugr/serialize.rs 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #968      +/-   ##
==========================================
+ Coverage   85.77%   85.87%   +0.09%     
==========================================
  Files          79       79              
  Lines       14407    14440      +33     
  Branches    14407    14440      +33     
==========================================
+ Hits        12358    12400      +42     
+ Misses       1412     1403       -9     
  Partials      637      637              
Flag Coverage Δ
rust 85.87% <90.69%> (+0.09%) ⬆️

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.

@doug-q doug-q force-pushed the feat/sumtype-serialisation branch from e309c00 to 97ec3b8 Compare April 24, 2024 12:56
Base automatically changed from feat/bring-back-value to main April 25, 2024 08:38
@doug-q doug-q force-pushed the feat/sumtype-serialisation branch from 90a129c to 7e24fb1 Compare April 25, 2024 12:26
@doug-q doug-q requested a review from mark-koch April 25, 2024 13:21
@doug-q doug-q force-pushed the feat/sumtype-serialisation branch 2 times, most recently from 981f5d0 to 567537b Compare April 26, 2024 07:21
@doug-q doug-q requested a review from ss2165 April 29, 2024 08:50
@doug-q doug-q closed this Apr 29, 2024
@doug-q doug-q force-pushed the feat/sumtype-serialisation branch from 9d91f34 to c352abf Compare April 29, 2024 09:14
@doug-q doug-q reopened this Apr 29, 2024
@doug-q doug-q force-pushed the feat/sumtype-serialisation branch from fe4cda0 to 920269f Compare April 29, 2024 09:39
@doug-q doug-q force-pushed the feat/sumtype-serialisation branch from 920269f to b7d0186 Compare April 29, 2024 13:41
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.

Looks like this gets us to a much better place. I'm a bit wary of the combined test-only schema and pydantic model with lots of optional fields. Is this done for convenience or is there something preventing us testing the individual schema?

devenv.nix Outdated
@@ -11,6 +11,7 @@ in
pkgs.llvmPackages_16.libllvm
# cargo-llvm-cov is currently marked broken on nixpkgs unstable
pkgs-stable.cargo-llvm-cov
pkgs.ruff
Copy link
Member

Choose a reason for hiding this comment

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

isn't this part of the poetry dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, though it doesn't work well on NixOS. will revert.

@classmethod
def get_version(cls) -> str:
"""Return the version of the schema."""
return cls(typ=Type(USize())).v
Copy link
Member

Choose a reason for hiding this comment

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

should v be a class attribute? Is that something pydantic can handle?

Copy link
Member

Choose a reason for hiding this comment

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

*version

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's copy/pasted from the neighbouring serial_hugr.py, I'll have another look

import json
import sys
from pathlib import Path

from pydantic import TypeAdapter

from hugr.serialization import SerialHugr
from hugr.serialization.hugrtype import HugrType

def write_schema(out_dir: Path, name_prefix: str, schema):
Copy link
Member

Choose a reason for hiding this comment

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

schema: Type[BaseModel] ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we do this we get a mypy error on get_version. I am inclined to leave as is.

Copy link
Member

Choose a reason for hiding this comment

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

in which case you need to constrain it to a type that has that classmethod. Either by defining a common baseclass or protocol for SerialHugr, TestingHugr etc. to share or using a Type[SerialHugr] | Type[TestingHugr] annotation here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought the first was not worth it. I'll do the second though, good idea.

@@ -26,16 +26,21 @@ use super::{HugrMut, HugrView};
/// will try to deserialize them in order.
#[derive(Serialize, Deserialize)]
#[serde(tag = "version", rename_all = "lowercase")]
enum Versioned {
enum Versioned<T> {
Copy link
Member

Choose a reason for hiding this comment

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

why is this generic? it implies a new generic parameter will need to be added for each version of the payload.

Copy link
Member

Choose a reason for hiding this comment

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

From below it looks like this is generic to allow versioned payloads for different types. Maybe call the type parameter V1 for clarity.

@@ -67,6 +82,7 @@ pub fn ser_roundtrip_validate<T: Serialize + serde::de::DeserializeOwned>(
println!("Validation error: {}", error);
println!("Instance path: {}", error.instance_path);
}
dbg!(s);
Copy link
Member

Choose a reason for hiding this comment

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

remove?

Comment on lines +337 to +344
#[case(BOOL_T)]
#[case(USIZE_T)]
#[case(INT_TYPES[2].clone())]
#[case(Type::new_alias(crate::ops::AliasDecl::new("t", TypeBound::Any)))]
#[case(Type::new_var_use(2, TypeBound::Copyable))]
#[case(Type::new_tuple(type_row![BOOL_T,QB_T]))]
#[case(Type::new_sum([type_row![BOOL_T,QB_T], type_row![Type::new_unit_sum(4)]]))]
#[case(Type::new_function(FunctionType::new_endo(type_row![QB_T,BOOL_T,USIZE_T])))]
Copy link
Member

Choose a reason for hiding this comment

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

can we use hypothesis/proptest for at least some of these?

Copy link
Collaborator Author

@doug-q doug-q Apr 30, 2024

Choose a reason for hiding this comment

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

I agree that it would be better. Hugr-Valued Values would not be possible, and anything with type variables may be tricky (if it turns out they have to make sense).

I would prefer to leave this as-is for now and convert to proptest in a second pass. Do lmk if you disagree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On further investigation, it seems like it will be fine to construct and round trip types with typevars that don't make sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have agreed to try proptest, I hope you are ok merging this PR first?

@doug-q
Copy link
Collaborator Author

doug-q commented Apr 29, 2024

Looks like this gets us to a much better place. I'm a bit wary of the combined test-only schema and pydantic model with lots of optional fields. Is this done for convenience or is there something preventing us testing the individual schema?

Do you mean preventing us from using the hugr schema, or preventing us from using nicer testing schemas(i.e. one for type, one for value etc.)

We don't use the hugr schema because it doesn't allow a type (or value, etc.) at the root. We use a single testing schema for convenience.

I will backport a change I've made where I stop defining those structs locally and instead have one struct with many optional fields.

@doug-q doug-q force-pushed the feat/sumtype-serialisation branch 2 times, most recently from 8a07c3b to b8e74d5 Compare April 30, 2024 09:40
@doug-q doug-q force-pushed the feat/sumtype-serialisation branch from b8e74d5 to ee37468 Compare April 30, 2024 09:41
@doug-q doug-q requested a review from ss2165 April 30, 2024 09:43
import json
import sys
from pathlib import Path

from pydantic import TypeAdapter

from hugr.serialization import SerialHugr
from hugr.serialization.hugrtype import HugrType

def write_schema(out_dir: Path, name_prefix: str, schema):
Copy link
Member

Choose a reason for hiding this comment

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

in which case you need to constrain it to a type that has that classmethod. Either by defining a common baseclass or protocol for SerialHugr, TestingHugr etc. to share or using a Type[SerialHugr] | Type[TestingHugr] annotation here

@doug-q doug-q added this pull request to the merge queue Apr 30, 2024
Merged via the queue into main with commit d913f40 Apr 30, 2024
18 checks passed
@doug-q doug-q deleted the feat/sumtype-serialisation branch April 30, 2024 10:30
Copy link
Contributor

github-actions bot commented May 10, 2024

Hey there and thank you for opening this pull request! 👋🏼

It looks like your proposed title indicates a breaking change. If that's the case,
please make sure to include a "BREAKING CHANGE:" footer in the body of the pull request
describing the breaking change and any migration instructions.

doug-q pushed a commit that referenced this pull request May 10, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.2.0-pre](hugr-py-v0.1.0...hugr-py-v0.2.0-pre)
(2024-05-10)


### ⚠ BREAKING CHANGES

* New serialisation schema
* rename `Const::const_type` and `Value::const_type` to
`Const::get_type` and `Value::get_type`. These now match several other
`get_type` functions ([#1005](#1005))
* Many uses of `Const` now use `Value`.

### Features

* Add LoadFunction node
([#947](#947))
([81e9602](81e9602))
* Encoder metadata in serialized hugr
([#955](#955))
([0a44d48](0a44d48))
* Implement `CustomConst` serialization
([#1005](#1005))
([c45e6fc](c45e6fc))
* Revert the removal of `Value`
([#967](#967))
([0c354b6](0c354b6))
* Set default value for `Conditional.sum_rows`
([#934](#934))
([d69198e](d69198e))


### Bug Fixes

* `OpDef` serialization
([#1013](#1013))
([3d8f6f6](3d8f6f6))
* input_port_types and other helper functions on pydantic schema
([#958](#958))
([8651839](8651839))
* Remove insert_port_types for LoadFunction
([#993](#993))
([acca7bf](acca7bf))
* Serialisation for `Type`, `PolyFuncType`, and `Value`
([#968](#968))
([d913f40](d913f40))
* Serialization for `Op`s
([#997](#997))
([9ce6e49](9ce6e49))


### Code Refactoring

* rename `Const::const_type` and `Value::const_type` to
`Const::get_type` and `Value::get_type`. These now match several other
`get_type` functions ([#1005](#1005))
([c45e6fc](c45e6fc))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request May 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.2.0a1](hugr-py-v0.1.0...hugr-py-v0.2.0a1)
(2024-05-13)


### ⚠ BREAKING CHANGES

* New serialisation schema
* rename `Const::const_type` and `Value::const_type` to
`Const::get_type` and `Value::get_type`. These now match several other
`get_type` functions ([#1005](#1005))
* Many uses of `Const` now use `Value`.

### Features

* Add LoadFunction node
([#947](#947))
([81e9602](81e9602))
* Encoder metadata in serialized hugr
([#955](#955))
([0a44d48](0a44d48))
* Implement `CustomConst` serialization
([#1005](#1005))
([c45e6fc](c45e6fc))
* Revert the removal of `Value`
([#967](#967))
([0c354b6](0c354b6))
* Set default value for `Conditional.sum_rows`
([#934](#934))
([d69198e](d69198e))


### Bug Fixes

* `OpDef` serialization
([#1013](#1013))
([3d8f6f6](3d8f6f6))
* input_port_types and other helper functions on pydantic schema
([#958](#958))
([8651839](8651839))
* Remove insert_port_types for LoadFunction
([#993](#993))
([acca7bf](acca7bf))
* Serialisation for `Type`, `PolyFuncType`, and `Value`
([#968](#968))
([d913f40](d913f40))
* Serialization for `Op`s
([#997](#997))
([9ce6e49](9ce6e49))
* set `[build-system]` in `hugr-py/pyproject.toml`
([#1022](#1022))
([b9c3ee4](b9c3ee4))


### Code Refactoring

* rename `Const::const_type` and `Value::const_type` to
`Const::get_type` and `Value::get_type`. These now match several other
`get_type` functions ([#1005](#1005))
([c45e6fc](c45e6fc))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Douglas Wilson <douglas.wilson@quantinuum.com>
github-merge-queue bot pushed a commit that referenced this pull request May 13, 2024
## 🤖 New release
* `hugr`: 0.3.1 -> 0.4.0-alpha.1 (⚠️ API breaking changes)

### ⚠️ `hugr` breaking changes

```
--- failure enum_marked_non_exhaustive: enum marked #[non_exhaustive] ---

Description:
A public enum has been marked #[non_exhaustive]. Pattern-matching on it outside of its crate must now include a wildcard pattern like `_`, or it will fail to compile.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/enum_marked_non_exhaustive.ron

Failed in:
  enum RegionBlocksError in /tmp/.tmpleGpag/hugr/hugr/src/algorithm/nest_cfgs.rs:282
  enum EdgeValidationError in /tmp/.tmpleGpag/hugr/hugr/src/ops/validate.rs:213
  enum ExtensionDeclarationError in /tmp/.tmpleGpag/hugr/hugr/src/extension/declarative.rs:179
  enum InterGraphEdgeError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/validate.rs:748
  enum ValidationError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/validate.rs:632
  enum ValidationError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/validate.rs:632
  enum HUGRSerializationError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/serialize.rs:107
  enum InlineDFGError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/inline_dfg.rs:15
  enum ExtensionError in /tmp/.tmpleGpag/hugr/hugr/src/extension/validate.rs:163
  enum IntOpDef in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/arithmetic/int_ops.rs:51
  enum ChildrenValidationError in /tmp/.tmpleGpag/hugr/hugr/src/ops/validate.rs:163
  enum SumTypeError in /tmp/.tmpleGpag/hugr/hugr/src/types/check.rs:11
  enum ReplaceError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/replace.rs:388
  enum ConvertOpDef in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/arithmetic/conversions.rs:30
  enum InvalidSubgraph in /tmp/.tmpleGpag/hugr/hugr/src/hugr/views/sibling_subgraph.rs:647
  enum TypeArgError in /tmp/.tmpleGpag/hugr/hugr/src/types/type_param.rs:376
  enum SumType in /tmp/.tmpleGpag/hugr/hugr/src/types.rs:124
  enum ListOp in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/collections.rs:209
  enum SimpleReplacementError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/simple_replace.rs:185
  enum SimpleReplacementError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/simple_replace.rs:185
  enum SimpleReplacementError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/simple_replace.rs:185
  enum CustomCheckFailure in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:227
  enum CustomCheckFailure in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:227
  enum IdentityInsertionError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/insert_identity.rs:36
  enum RemoveError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/consts.rs:18
  enum OutlineCfgError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/outline_cfg.rs:223
  enum NaryLogic in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/logic.rs:56
  enum OpLoadError in /tmp/.tmpleGpag/hugr/hugr/src/extension/simple_op.rs:24
  enum ConstTypeError in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:244
  enum ConstTypeError in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:244
  enum InvalidReplacement in /tmp/.tmpleGpag/hugr/hugr/src/hugr/views/sibling_subgraph.rs:629
  enum InvalidSubgraphBoundary in /tmp/.tmpleGpag/hugr/hugr/src/hugr/views/sibling_subgraph.rs:665
  enum InferExtensionError in /tmp/.tmpleGpag/hugr/hugr/src/extension/infer.rs:68
  enum FloatOps in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/arithmetic/float_ops.rs:25
  enum CustomOpError in /tmp/.tmpleGpag/hugr/hugr/src/ops/custom.rs:400

--- 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.31.0/src/lints/enum_missing.ron

Failed in:
  enum hugr::ops::constant::Const, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:22
  enum hugr::ops::Const, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:22

--- failure enum_struct_variant_field_added: pub enum struct variant field added ---

Description:
An enum's exhaustive struct variant has a new field, which has to be included when constructing or matching on this variant.
        ref: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/enum_struct_variant_field_added.ron

Failed in:
  field dir of variant HUGRSerializationError::MissingPortOffset in /tmp/.tmpleGpag/hugr/hugr/src/hugr/serialize.rs:120

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

Failed in:
  variant SignatureError:LoadFunctionIncorrectlyAppliesType in /tmp/.tmpleGpag/hugr/hugr/src/extension.rs:182
  variant ExtensionBuildError:ValueExists in /tmp/.tmpleGpag/hugr/hugr/src/extension.rs:405

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn 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.31.0/src/lints/inherent_method_missing.ron

Failed in:
  ConvertOpDef::with_width, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/conversions.rs:78
  IntOpDef::with_width, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_ops.rs:314
  IntOpDef::with_two_widths, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_ops.rs:323
  Const::const_type, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:124
  Const::sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:138
  Const::tuple, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:153
  Const::function, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:164
  Const::unit, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:173
  Const::unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:178
  Const::unary_unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:183
  Const::true_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:188
  Const::false_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:193
  Const::from_bool, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:199
  Const::extension, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:208
  Const::get_custom_value, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:215
  Const::const_type, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:124
  Const::sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:138
  Const::tuple, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:153
  Const::function, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:164
  Const::unit, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:173
  Const::unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:178
  Const::unary_unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:183
  Const::true_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:188
  Const::false_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:193
  Const::from_bool, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:199
  Const::extension, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:208
  Const::get_custom_value, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:215

--- 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.31.0/src/lints/struct_missing.ron

Failed in:
  struct hugr::std_extensions::arithmetic::int_types::ConstIntS, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_types.rs:83
  struct hugr::std_extensions::arithmetic::int_types::ConstIntU, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_types.rs:76
  struct hugr::ops::constant::ExtensionConst, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:64

--- failure trait_missing: pub trait removed or renamed ---

Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait 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.31.0/src/lints/trait_missing.ron

Failed in:
  trait hugr::ops::OpName, previously in file /tmp/.tmppKREXC/hugr/src/ops.rs:307

--- failure trait_removed_supertrait: supertrait removed or renamed ---

Description:
A supertrait was removed from a trait. Users of the trait can no longer assume it can also be used like its supertrait.
        ref: https://doc.rust-lang.org/reference/items/traits.html#supertraits
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/trait_removed_supertrait.ron

Failed in:
  supertrait hugr::ops::OpName of trait MakeExtensionOp in file /tmp/.tmpleGpag/hugr/hugr/src/extension/simple_op.rs:87
  supertrait hugr::ops::OpName of trait MakeOpDef in file /tmp/.tmpleGpag/hugr/hugr/src/extension/simple_op.rs:45
```

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

<blockquote>

## 0.4.0 (2024-05-13)

### Bug Fixes

- Serialization round-trips
([#948](#948))
- [**breaking**] Combine `ConstIntU` and `ConstIntS`
([#974](#974))
- Disable serialisation tests when miri is active
([#977](#977))
- [**breaking**] Serialisation schema
([#968](#968))
- Correct constant fold for `fne`.
([#995](#995))
- [**breaking**] Serialisation fixes
([#997](#997))
- [**breaking**] OpDef serialisation
([#1013](#1013))
- NaryLogicOp constant folding
([#1026](#1026))

### Features

- 'Replace' rewrite returns node map
([#929](#929))
- `new` methods for leaf ops
([#940](#940))
- Add `string` type and `print` function to `prelude`
([#942](#942))
- `CustomOp::extension` utility function
([#951](#951))
- [**breaking**] Add `non_exhaustive` to various enums
([#952](#952))
- Encoder metadata in serialized hugr
([#955](#955))
- [**breaking**] Bring back Value
([#967](#967))
- Add LoadFunction node ([#947](#947))
- Add From impls for TypeArg
([#1002](#1002))
- Constant-folding of integer and logic operations
([#1009](#1009))
- [**breaking**] Update serialisation schema, implement `CustomConst`
serialisation ([#1005](#1005))
- Merge basic blocks algorithm
([#956](#956))
- [**breaking**] Allow panic operation to have any input and output
wires ([#1024](#1024))

### Refactor

- Outline hugr::serialize::test
([#976](#976))
- [**breaking**] Replace SmolStr identifiers with wrapper types.
([#959](#959))
- Separate extension validation from the rest
([#1011](#1011))
- Remove "trait TypeParametrised"
([#1019](#1019))

### Testing

- Add a test of instantiating an extension set
([#939](#939))
- Ignore serialisation tests when using miri
([#975](#975))
- [**breaking**] Test roundtrip serialisation against strict + lax
schema ([#982](#982))
- Fix some bad assert_matches
([#1006](#1006))
- Expand test of instantiating extension sets
([#1003](#1003))
- Fix unconnected ports in extension test
([#1010](#1010))
</blockquote>


</p></details>

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

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Douglas Wilson <douglas.wilson@quantinuum.com>
This was referenced May 15, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 20, 2024
## 🤖 New release
* `hugr`: 0.3.1 -> 0.4.0 (⚠️ API breaking changes)

### ⚠️ `hugr` breaking changes

```
--- failure inherent_method_const_removed: pub method is no longer const ---

Description:
A publicly-visible method or associated fn is no longer `const` and can no longer be used in a `const` context.
        ref: https://doc.rust-lang.org/reference/const_eval.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/inherent_method_const_removed.ron

Failed in:
  ConstF64::new in /tmp/.tmpwo5blB/hugr/hugr/src/std_extensions/arithmetic/float_types.rs:43

--- 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.31.0/src/lints/struct_missing.ron

Failed in:
  struct hugr::ops::constant::ExtensionValue, previously in file /tmp/.tmpq1W6bC/hugr/src/ops/constant.rs:184
```

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

<blockquote>

## 0.4.0 (2024-05-20)

### Bug Fixes

- Disallow non-finite values for `ConstF64`
([#1075](#1075))
- Serialization round-trips
([#948](#948))
- [**breaking**] Combine `ConstIntU` and `ConstIntS`
([#974](#974))
- Disable serialisation tests when miri is active
([#977](#977))
- [**breaking**] Serialisation schema
([#968](#968))
- Correct constant fold for `fne`.
([#995](#995))
- [**breaking**] Serialisation fixes
([#997](#997))
- [**breaking**] OpDef serialisation
([#1013](#1013))
- NaryLogicOp constant folding
([#1026](#1026))

### Features

- Add verification to constant folding
([#1030](#1030))
- Add `Const::get_custom_value`
([#1037](#1037))
- Add serialization schema for metadata
([#1038](#1038))
- 'Replace' rewrite returns node map
([#929](#929))
- `new` methods for leaf ops
([#940](#940))
- Add `string` type and `print` function to `prelude`
([#942](#942))
- `CustomOp::extension` utility function
([#951](#951))
- [**breaking**] Add `non_exhaustive` to various enums
([#952](#952))
- Encoder metadata in serialized hugr
([#955](#955))
- [**breaking**] Bring back Value
([#967](#967))
- Add LoadFunction node ([#947](#947))
- Add From impls for TypeArg
([#1002](#1002))
- Constant-folding of integer and logic operations
([#1009](#1009))
- [**breaking**] Update serialisation schema, implement `CustomConst`
serialisation ([#1005](#1005))
- Merge basic blocks algorithm
([#956](#956))
- [**breaking**] Allow panic operation to have any input and output
wires ([#1024](#1024))

### Refactor

- [**breaking**] Rename `crate::ops::constant::ExtensionValue` =>
`OpaqueValue` ([#1036](#1036))
- Outline hugr::serialize::test
([#976](#976))
- [**breaking**] Replace SmolStr identifiers with wrapper types.
([#959](#959))
- Separate extension validation from the rest
([#1011](#1011))
- Remove "trait TypeParametrised"
([#1019](#1019))

### Testing

- Reorg OutlineCfg/nest_cfgs tests so hugr doesn't depend on algorithm
([#1007](#1007))
- Ignore tests which depend on typetag when cfg(miri)
([#1051](#1051))
- Really ignore tests which depend on typetag when cfg(miri)
([#1058](#1058))
- Proptests for round trip serialisation of `Type`s and `Op`s.
([#981](#981))
- Add a test of instantiating an extension set
([#939](#939))
- Ignore serialisation tests when using miri
([#975](#975))
- [**breaking**] Test roundtrip serialisation against strict + lax
schema ([#982](#982))
- Fix some bad assert_matches
([#1006](#1006))
- Expand test of instantiating extension sets
([#1003](#1003))
- Fix unconnected ports in extension test
([#1010](#1010))

</blockquote>


</p></details>

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

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Douglas Wilson <douglas.wilson@quantinuum.com>
github-merge-queue bot pushed a commit that referenced this pull request May 20, 2024
🤖 I have created a release *beep* *boop*
---

##
[0.2.1](hugr-py-v0.2.0...hugr-py-v0.2.1)
(2024-05-20)

### ⚠ BREAKING CHANGES

* New serialisation schema
* rename `Const::const_type` and `Value::const_type` to
`Const::get_type` and `Value::get_type`. These now match several other
`get_type` functions ([#1005](#1005))
* Many uses of `Const` now use `Value`.

### Features

* Add serialization schema for metadata
([#1038](#1038))
([19bac62](19bac62))
* Add LoadFunction node
([#947](#947))
([81e9602](81e9602))
* Encoder metadata in serialized hugr
([#955](#955))
([0a44d48](0a44d48))
* Implement `CustomConst` serialization
([#1005](#1005))
([c45e6fc](c45e6fc))
* Revert the removal of `Value`
([#967](#967))
([0c354b6](0c354b6))
* Set default value for `Conditional.sum_rows`
([#934](#934))
([d69198e](d69198e))


### Bug Fixes

* `OpDef` serialization
([#1013](#1013))
([3d8f6f6](3d8f6f6))
* input_port_types and other helper functions on pydantic schema
([#958](#958))
([8651839](8651839))
* Remove insert_port_types for LoadFunction
([#993](#993))
([acca7bf](acca7bf))
* Serialisation for `Type`, `PolyFuncType`, and `Value`
([#968](#968))
([d913f40](d913f40))
* Serialization for `Op`s
([#997](#997))
([9ce6e49](9ce6e49))
* set `[build-system]` in `hugr-py/pyproject.toml`
([#1022](#1022))
([b9c3ee4](b9c3ee4))


### Code Refactoring

* rename `Const::const_type` and `Value::const_type` to
`Const::get_type` and `Value::get_type`. These now match several other
`get_type` functions ([#1005](#1005))
([c45e6fc](c45e6fc))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com>
Co-authored-by: doug-q <141026920+doug-q@users.noreply.github.com>
Co-authored-by: Douglas Wilson <douglas.wilson@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.

2 participants