From 9ce6e49d1d0c8c200b9b78ebe35a0a3257009ca1 Mon Sep 17 00:00:00 2001 From: doug-q <141026920+doug-q@users.noreply.github.com> Date: Tue, 7 May 2024 12:10:15 +0100 Subject: [PATCH] fix!: serialisation fixes (#997) These are the serialisation fixes from the `proptest` branch. There we have tested all of the schema roundtrips, with the exception of: * OpDef * CustomConst BREAKING CHANGE: serialisation format --- hugr-py/src/hugr/serialization/tys.py | 31 +++-- hugr/src/hugr/serialize/test.rs | 5 +- hugr/src/hugr/validate/test.rs | 1 - hugr/src/ops/constant.rs | 2 +- hugr/src/types/serialize.rs | 6 +- hugr/src/types/type_param.rs | 2 + poetry.lock | 106 +++++++++--------- specification/schema/.gitattributes | 1 + .../schema/hugr_schema_strict_v1.json | 102 +++++++++++------ specification/schema/hugr_schema_v1.json | 102 +++++++++++------ .../schema/testing_hugr_schema_strict_v1.json | 102 +++++++++++------ .../schema/testing_hugr_schema_v1.json | 102 +++++++++++------ 12 files changed, 342 insertions(+), 220 deletions(-) create mode 100644 specification/schema/.gitattributes diff --git a/hugr-py/src/hugr/serialization/tys.py b/hugr-py/src/hugr/serialization/tys.py index d181b7e45..c9f116af5 100644 --- a/hugr-py/src/hugr/serialization/tys.py +++ b/hugr-py/src/hugr/serialization/tys.py @@ -105,11 +105,6 @@ class TypeParam(RootModel): # ------------------------------------------ -class CustomTypeArg(ConfiguredBaseModel): - typ: None # TODO - value: str - - class TypeTypeArg(ConfiguredBaseModel): tya: Literal["Type"] = "Type" ty: "Type" @@ -122,12 +117,13 @@ class BoundedNatArg(ConfiguredBaseModel): class OpaqueArg(ConfiguredBaseModel): tya: Literal["Opaque"] = "Opaque" - arg: CustomTypeArg + typ: "Opaque" + value: Any class SequenceArg(ConfiguredBaseModel): tya: Literal["Sequence"] = "Sequence" - args: list["TypeArg"] + elems: list["TypeArg"] class ExtensionsArg(ConfiguredBaseModel): @@ -135,11 +131,22 @@ class ExtensionsArg(ConfiguredBaseModel): es: ExtensionSet +class VariableArg(BaseModel): + tya: Literal["Variable"] = "Variable" + idx: int + cached_decl: TypeParam + + class TypeArg(RootModel): """A type argument.""" root: Annotated[ - TypeTypeArg | BoundedNatArg | OpaqueArg | SequenceArg | ExtensionsArg, + TypeTypeArg + | BoundedNatArg + | OpaqueArg + | SequenceArg + | ExtensionsArg + | VariableArg, WrapValidator(_json_custom_error_validator), ] = Field(discriminator="tya") @@ -273,13 +280,17 @@ def join(*bs: "TypeBound") -> "TypeBound": class Opaque(ConfiguredBaseModel): """An opaque Type that can be downcasted by the extensions that define it.""" - t: Literal["Opaque"] = "Opaque" extension: ExtensionId id: str # Unique identifier of the opaque type. args: list[TypeArg] bound: TypeBound +class TaggedOpaque(ConfiguredBaseModel): + t: Literal["Opaque"] = "Opaque" + o: Opaque + + class Alias(ConfiguredBaseModel): """An Alias Type""" @@ -309,7 +320,7 @@ class Type(RootModel): | FunctionType | Array | TaggedSumType - | Opaque + | TaggedOpaque | Alias, WrapValidator(_json_custom_error_validator), ] = Field(discriminator="t") diff --git a/hugr/src/hugr/serialize/test.rs b/hugr/src/hugr/serialize/test.rs index 2c63e33d7..57ae945ed 100644 --- a/hugr/src/hugr/serialize/test.rs +++ b/hugr/src/hugr/serialize/test.rs @@ -7,7 +7,6 @@ use crate::extension::prelude::{BOOL_T, PRELUDE_ID, QB_T, USIZE_T}; use crate::extension::simple_op::MakeRegisteredOp; use crate::extension::{EMPTY_REG, PRELUDE_REGISTRY}; use crate::hugr::hugrmut::sealed::HugrMutInternals; -use crate::hugr::NodeType; use crate::ops::custom::{ExtensionOp, OpaqueOp}; use crate::ops::{self, Value}; use crate::ops::{dataflow::IOTrait, Input, Module, Noop, Output, DFG}; @@ -22,9 +21,7 @@ use itertools::Itertools; use jsonschema::{Draft, JSONSchema}; use lazy_static::lazy_static; use portgraph::LinkView; -use portgraph::{ - multiportgraph::MultiPortGraph, Hierarchy, LinkMut, PortMut, PortView, UnmanagedDenseMap, -}; +use portgraph::{multiportgraph::MultiPortGraph, Hierarchy, LinkMut, PortMut, UnmanagedDenseMap}; use rstest::rstest; const NAT: Type = crate::extension::prelude::USIZE_T; diff --git a/hugr/src/hugr/validate/test.rs b/hugr/src/hugr/validate/test.rs index 98fe890ed..8c1387dc0 100644 --- a/hugr/src/hugr/validate/test.rs +++ b/hugr/src/hugr/validate/test.rs @@ -583,7 +583,6 @@ fn test_polymorphic_load() -> Result<(), Box> { #[cfg(feature = "extension_inference")] mod extension_tests { use super::*; - use crate::builder::ModuleBuilder; use crate::extension::ExtensionSet; use crate::macros::const_extension_ids; diff --git a/hugr/src/ops/constant.rs b/hugr/src/ops/constant.rs index 256846a92..bb13a7317 100644 --- a/hugr/src/ops/constant.rs +++ b/hugr/src/ops/constant.rs @@ -345,7 +345,7 @@ pub type ValueNameRef = str; #[cfg(test)] mod test { - use super::{Value, ValueName}; + use super::Value; use crate::builder::test::simple_dfg_hugr; use crate::{ builder::{BuildError, DFGBuilder, Dataflow, DataflowHugr}, diff --git a/hugr/src/types/serialize.rs b/hugr/src/types/serialize.rs index 493f6cca0..83718a5c5 100644 --- a/hugr/src/types/serialize.rs +++ b/hugr/src/types/serialize.rs @@ -13,7 +13,7 @@ pub(super) enum SerSimpleType { G(Box), Sum { st: SumType }, Array { inner: Box, len: u64 }, - Opaque(CustomType), + Opaque { o: CustomType }, Alias(AliasDecl), V { i: usize, b: TypeBound }, } @@ -29,7 +29,7 @@ impl From for SerSimpleType { // TODO short circuiting for array. let Type(value, _) = value; match value { - TypeEnum::Extension(c) => SerSimpleType::Opaque(c), + TypeEnum::Extension(o) => SerSimpleType::Opaque { o }, TypeEnum::Alias(a) => SerSimpleType::Alias(a), TypeEnum::Function(sig) => SerSimpleType::G(sig), TypeEnum::Variable(i, b) => SerSimpleType::V { i, b }, @@ -48,7 +48,7 @@ impl From for Type { SerSimpleType::Array { inner, len } => { array_type(TypeArg::BoundedNat { n: len }, (*inner).into()) } - SerSimpleType::Opaque(custom) => Type::new_extension(custom), + SerSimpleType::Opaque { o } => Type::new_extension(o), SerSimpleType::Alias(a) => Type::new_alias(a), SerSimpleType::V { i, b } => Type::new_var_use(i, b), } diff --git a/hugr/src/types/type_param.rs b/hugr/src/types/type_param.rs index ffe0f6166..66053a7dc 100644 --- a/hugr/src/types/type_param.rs +++ b/hugr/src/types/type_param.rs @@ -154,6 +154,7 @@ pub enum TypeArg { ///Instance of [TypeParam::Opaque] An opaque value, stored as serialized blob. Opaque { #[allow(missing_docs)] + #[serde(flatten)] arg: CustomTypeArg, }, /// Instance of [TypeParam::List] or [TypeParam::Tuple], defined by a @@ -171,6 +172,7 @@ pub enum TypeArg { /// or [TypeArg::Extensions] - see [TypeArg::new_var_use] Variable { #[allow(missing_docs)] + #[serde(flatten)] v: TypeArgVariable, }, } diff --git a/poetry.lock b/poetry.lock index c8b22fe46..77c94471d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -35,63 +35,63 @@ files = [ [[package]] name = "coverage" -version = "7.5.0" +version = "7.5.1" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ - {file = "coverage-7.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:432949a32c3e3f820af808db1833d6d1631664d53dd3ce487aa25d574e18ad1c"}, - {file = "coverage-7.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2bd7065249703cbeb6d4ce679c734bef0ee69baa7bff9724361ada04a15b7e3b"}, - {file = "coverage-7.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bbfe6389c5522b99768a93d89aca52ef92310a96b99782973b9d11e80511f932"}, - {file = "coverage-7.5.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:39793731182c4be939b4be0cdecde074b833f6171313cf53481f869937129ed3"}, - {file = "coverage-7.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85a5dbe1ba1bf38d6c63b6d2c42132d45cbee6d9f0c51b52c59aa4afba057517"}, - {file = "coverage-7.5.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:357754dcdfd811462a725e7501a9b4556388e8ecf66e79df6f4b988fa3d0b39a"}, - {file = "coverage-7.5.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:a81eb64feded34f40c8986869a2f764f0fe2db58c0530d3a4afbcde50f314880"}, - {file = "coverage-7.5.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:51431d0abbed3a868e967f8257c5faf283d41ec882f58413cf295a389bb22e58"}, - {file = "coverage-7.5.0-cp310-cp310-win32.whl", hash = "sha256:f609ebcb0242d84b7adeee2b06c11a2ddaec5464d21888b2c8255f5fd6a98ae4"}, - {file = "coverage-7.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:6782cd6216fab5a83216cc39f13ebe30adfac2fa72688c5a4d8d180cd52e8f6a"}, - {file = "coverage-7.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:e768d870801f68c74c2b669fc909839660180c366501d4cc4b87efd6b0eee375"}, - {file = "coverage-7.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:84921b10aeb2dd453247fd10de22907984eaf80901b578a5cf0bb1e279a587cb"}, - {file = "coverage-7.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:710c62b6e35a9a766b99b15cdc56d5aeda0914edae8bb467e9c355f75d14ee95"}, - {file = "coverage-7.5.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c379cdd3efc0658e652a14112d51a7668f6bfca7445c5a10dee7eabecabba19d"}, - {file = "coverage-7.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fea9d3ca80bcf17edb2c08a4704259dadac196fe5e9274067e7a20511fad1743"}, - {file = "coverage-7.5.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:41327143c5b1d715f5f98a397608f90ab9ebba606ae4e6f3389c2145410c52b1"}, - {file = "coverage-7.5.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:565b2e82d0968c977e0b0f7cbf25fd06d78d4856289abc79694c8edcce6eb2de"}, - {file = "coverage-7.5.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cf3539007202ebfe03923128fedfdd245db5860a36810136ad95a564a2fdffff"}, - {file = "coverage-7.5.0-cp311-cp311-win32.whl", hash = "sha256:bf0b4b8d9caa8d64df838e0f8dcf68fb570c5733b726d1494b87f3da85db3a2d"}, - {file = "coverage-7.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:9c6384cc90e37cfb60435bbbe0488444e54b98700f727f16f64d8bfda0b84656"}, - {file = "coverage-7.5.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:fed7a72d54bd52f4aeb6c6e951f363903bd7d70bc1cad64dd1f087980d309ab9"}, - {file = "coverage-7.5.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cbe6581fcff7c8e262eb574244f81f5faaea539e712a058e6707a9d272fe5b64"}, - {file = "coverage-7.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ad97ec0da94b378e593ef532b980c15e377df9b9608c7c6da3506953182398af"}, - {file = "coverage-7.5.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bd4bacd62aa2f1a1627352fe68885d6ee694bdaebb16038b6e680f2924a9b2cc"}, - {file = "coverage-7.5.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:adf032b6c105881f9d77fa17d9eebe0ad1f9bfb2ad25777811f97c5362aa07f2"}, - {file = "coverage-7.5.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:4ba01d9ba112b55bfa4b24808ec431197bb34f09f66f7cb4fd0258ff9d3711b1"}, - {file = "coverage-7.5.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:f0bfe42523893c188e9616d853c47685e1c575fe25f737adf473d0405dcfa7eb"}, - {file = "coverage-7.5.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a9a7ef30a1b02547c1b23fa9a5564f03c9982fc71eb2ecb7f98c96d7a0db5cf2"}, - {file = "coverage-7.5.0-cp312-cp312-win32.whl", hash = "sha256:3c2b77f295edb9fcdb6a250f83e6481c679335ca7e6e4a955e4290350f2d22a4"}, - {file = "coverage-7.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:427e1e627b0963ac02d7c8730ca6d935df10280d230508c0ba059505e9233475"}, - {file = "coverage-7.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9dd88fce54abbdbf4c42fb1fea0e498973d07816f24c0e27a1ecaf91883ce69e"}, - {file = "coverage-7.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a898c11dca8f8c97b467138004a30133974aacd572818c383596f8d5b2eb04a9"}, - {file = "coverage-7.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:07dfdd492d645eea1bd70fb1d6febdcf47db178b0d99161d8e4eed18e7f62fe7"}, - {file = "coverage-7.5.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d3d117890b6eee85887b1eed41eefe2e598ad6e40523d9f94c4c4b213258e4a4"}, - {file = "coverage-7.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6afd2e84e7da40fe23ca588379f815fb6dbbb1b757c883935ed11647205111cb"}, - {file = "coverage-7.5.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a9960dd1891b2ddf13a7fe45339cd59ecee3abb6b8326d8b932d0c5da208104f"}, - {file = "coverage-7.5.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ced268e82af993d7801a9db2dbc1d2322e786c5dc76295d8e89473d46c6b84d4"}, - {file = "coverage-7.5.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e7c211f25777746d468d76f11719e64acb40eed410d81c26cefac641975beb88"}, - {file = "coverage-7.5.0-cp38-cp38-win32.whl", hash = "sha256:262fffc1f6c1a26125d5d573e1ec379285a3723363f3bd9c83923c9593a2ac25"}, - {file = "coverage-7.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:eed462b4541c540d63ab57b3fc69e7d8c84d5957668854ee4e408b50e92ce26a"}, - {file = "coverage-7.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d0194d654e360b3e6cc9b774e83235bae6b9b2cac3be09040880bb0e8a88f4a1"}, - {file = "coverage-7.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:33c020d3322662e74bc507fb11488773a96894aa82a622c35a5a28673c0c26f5"}, - {file = "coverage-7.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0cbdf2cae14a06827bec50bd58e49249452d211d9caddd8bd80e35b53cb04631"}, - {file = "coverage-7.5.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3235d7c781232e525b0761730e052388a01548bd7f67d0067a253887c6e8df46"}, - {file = "coverage-7.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2de4e546f0ec4b2787d625e0b16b78e99c3e21bc1722b4977c0dddf11ca84e"}, - {file = "coverage-7.5.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4d0e206259b73af35c4ec1319fd04003776e11e859936658cb6ceffdeba0f5be"}, - {file = "coverage-7.5.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:2055c4fb9a6ff624253d432aa471a37202cd8f458c033d6d989be4499aed037b"}, - {file = "coverage-7.5.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:075299460948cd12722a970c7eae43d25d37989da682997687b34ae6b87c0ef0"}, - {file = "coverage-7.5.0-cp39-cp39-win32.whl", hash = "sha256:280132aada3bc2f0fac939a5771db4fbb84f245cb35b94fae4994d4c1f80dae7"}, - {file = "coverage-7.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:c58536f6892559e030e6924896a44098bc1290663ea12532c78cef71d0df8493"}, - {file = "coverage-7.5.0-pp38.pp39.pp310-none-any.whl", hash = "sha256:2b57780b51084d5223eee7b59f0d4911c31c16ee5aa12737c7a02455829ff067"}, - {file = "coverage-7.5.0.tar.gz", hash = "sha256:cf62d17310f34084c59c01e027259076479128d11e4661bb6c9acb38c5e19bb8"}, + {file = "coverage-7.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c0884920835a033b78d1c73b6d3bbcda8161a900f38a488829a83982925f6c2e"}, + {file = "coverage-7.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:39afcd3d4339329c5f58de48a52f6e4e50f6578dd6099961cf22228feb25f38f"}, + {file = "coverage-7.5.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4a7b0ceee8147444347da6a66be737c9d78f3353b0681715b668b72e79203e4a"}, + {file = "coverage-7.5.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a9ca3f2fae0088c3c71d743d85404cec8df9be818a005ea065495bedc33da35"}, + {file = "coverage-7.5.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fd215c0c7d7aab005221608a3c2b46f58c0285a819565887ee0b718c052aa4e"}, + {file = "coverage-7.5.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4bf0655ab60d754491004a5efd7f9cccefcc1081a74c9ef2da4735d6ee4a6223"}, + {file = "coverage-7.5.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:61c4bf1ba021817de12b813338c9be9f0ad5b1e781b9b340a6d29fc13e7c1b5e"}, + {file = "coverage-7.5.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:db66fc317a046556a96b453a58eced5024af4582a8dbdc0c23ca4dbc0d5b3146"}, + {file = "coverage-7.5.1-cp310-cp310-win32.whl", hash = "sha256:b016ea6b959d3b9556cb401c55a37547135a587db0115635a443b2ce8f1c7228"}, + {file = "coverage-7.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:df4e745a81c110e7446b1cc8131bf986157770fa405fe90e15e850aaf7619bc8"}, + {file = "coverage-7.5.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:796a79f63eca8814ca3317a1ea443645c9ff0d18b188de470ed7ccd45ae79428"}, + {file = "coverage-7.5.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4fc84a37bfd98db31beae3c2748811a3fa72bf2007ff7902f68746d9757f3746"}, + {file = "coverage-7.5.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6175d1a0559986c6ee3f7fccfc4a90ecd12ba0a383dcc2da30c2b9918d67d8a3"}, + {file = "coverage-7.5.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fc81d5878cd6274ce971e0a3a18a8803c3fe25457165314271cf78e3aae3aa2"}, + {file = "coverage-7.5.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:556cf1a7cbc8028cb60e1ff0be806be2eded2daf8129b8811c63e2b9a6c43bca"}, + {file = "coverage-7.5.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9981706d300c18d8b220995ad22627647be11a4276721c10911e0e9fa44c83e8"}, + {file = "coverage-7.5.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:d7fed867ee50edf1a0b4a11e8e5d0895150e572af1cd6d315d557758bfa9c057"}, + {file = "coverage-7.5.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ef48e2707fb320c8f139424a596f5b69955a85b178f15af261bab871873bb987"}, + {file = "coverage-7.5.1-cp311-cp311-win32.whl", hash = "sha256:9314d5678dcc665330df5b69c1e726a0e49b27df0461c08ca12674bcc19ef136"}, + {file = "coverage-7.5.1-cp311-cp311-win_amd64.whl", hash = "sha256:5fa567e99765fe98f4e7d7394ce623e794d7cabb170f2ca2ac5a4174437e90dd"}, + {file = "coverage-7.5.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b6cf3764c030e5338e7f61f95bd21147963cf6aa16e09d2f74f1fa52013c1206"}, + {file = "coverage-7.5.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2ec92012fefebee89a6b9c79bc39051a6cb3891d562b9270ab10ecfdadbc0c34"}, + {file = "coverage-7.5.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:16db7f26000a07efcf6aea00316f6ac57e7d9a96501e990a36f40c965ec7a95d"}, + {file = "coverage-7.5.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:beccf7b8a10b09c4ae543582c1319c6df47d78fd732f854ac68d518ee1fb97fa"}, + {file = "coverage-7.5.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8748731ad392d736cc9ccac03c9845b13bb07d020a33423fa5b3a36521ac6e4e"}, + {file = "coverage-7.5.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7352b9161b33fd0b643ccd1f21f3a3908daaddf414f1c6cb9d3a2fd618bf2572"}, + {file = "coverage-7.5.1-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:7a588d39e0925f6a2bff87154752481273cdb1736270642aeb3635cb9b4cad07"}, + {file = "coverage-7.5.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:68f962d9b72ce69ea8621f57551b2fa9c70509af757ee3b8105d4f51b92b41a7"}, + {file = "coverage-7.5.1-cp312-cp312-win32.whl", hash = "sha256:f152cbf5b88aaeb836127d920dd0f5e7edff5a66f10c079157306c4343d86c19"}, + {file = "coverage-7.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:5a5740d1fb60ddf268a3811bcd353de34eb56dc24e8f52a7f05ee513b2d4f596"}, + {file = "coverage-7.5.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e2213def81a50519d7cc56ed643c9e93e0247f5bbe0d1247d15fa520814a7cd7"}, + {file = "coverage-7.5.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5037f8fcc2a95b1f0e80585bd9d1ec31068a9bcb157d9750a172836e98bc7a90"}, + {file = "coverage-7.5.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c3721c2c9e4c4953a41a26c14f4cef64330392a6d2d675c8b1db3b645e31f0e"}, + {file = "coverage-7.5.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca498687ca46a62ae590253fba634a1fe9836bc56f626852fb2720f334c9e4e5"}, + {file = "coverage-7.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0cdcbc320b14c3e5877ee79e649677cb7d89ef588852e9583e6b24c2e5072661"}, + {file = "coverage-7.5.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:57e0204b5b745594e5bc14b9b50006da722827f0b8c776949f1135677e88d0b8"}, + {file = "coverage-7.5.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8fe7502616b67b234482c3ce276ff26f39ffe88adca2acf0261df4b8454668b4"}, + {file = "coverage-7.5.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:9e78295f4144f9dacfed4f92935fbe1780021247c2fabf73a819b17f0ccfff8d"}, + {file = "coverage-7.5.1-cp38-cp38-win32.whl", hash = "sha256:1434e088b41594baa71188a17533083eabf5609e8e72f16ce8c186001e6b8c41"}, + {file = "coverage-7.5.1-cp38-cp38-win_amd64.whl", hash = "sha256:0646599e9b139988b63704d704af8e8df7fa4cbc4a1f33df69d97f36cb0a38de"}, + {file = "coverage-7.5.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4cc37def103a2725bc672f84bd939a6fe4522310503207aae4d56351644682f1"}, + {file = "coverage-7.5.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:fc0b4d8bfeabd25ea75e94632f5b6e047eef8adaed0c2161ada1e922e7f7cece"}, + {file = "coverage-7.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d0a0f5e06881ecedfe6f3dd2f56dcb057b6dbeb3327fd32d4b12854df36bf26"}, + {file = "coverage-7.5.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9735317685ba6ec7e3754798c8871c2f49aa5e687cc794a0b1d284b2389d1bd5"}, + {file = "coverage-7.5.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d21918e9ef11edf36764b93101e2ae8cc82aa5efdc7c5a4e9c6c35a48496d601"}, + {file = "coverage-7.5.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:c3e757949f268364b96ca894b4c342b41dc6f8f8b66c37878aacef5930db61be"}, + {file = "coverage-7.5.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:79afb6197e2f7f60c4824dd4b2d4c2ec5801ceb6ba9ce5d2c3080e5660d51a4f"}, + {file = "coverage-7.5.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d1d0d98d95dd18fe29dc66808e1accf59f037d5716f86a501fc0256455219668"}, + {file = "coverage-7.5.1-cp39-cp39-win32.whl", hash = "sha256:1cc0fe9b0b3a8364093c53b0b4c0c2dd4bb23acbec4c9240b5f284095ccf7981"}, + {file = "coverage-7.5.1-cp39-cp39-win_amd64.whl", hash = "sha256:dde0070c40ea8bb3641e811c1cfbf18e265d024deff6de52c5950677a8fb1e0f"}, + {file = "coverage-7.5.1-pp38.pp39.pp310-none-any.whl", hash = "sha256:6537e7c10cc47c595828b8a8be04c72144725c383c4702703ff4e42e44577312"}, + {file = "coverage-7.5.1.tar.gz", hash = "sha256:54de9ef3a9da981f7af93eafde4ede199e0846cd819eb27c88e2b712aae9708c"}, ] [package.dependencies] diff --git a/specification/schema/.gitattributes b/specification/schema/.gitattributes new file mode 100644 index 000000000..94ff3e30f --- /dev/null +++ b/specification/schema/.gitattributes @@ -0,0 +1 @@ +*schema_v*.json -diff diff --git a/specification/schema/hugr_schema_strict_v1.json b/specification/schema/hugr_schema_strict_v1.json index 18b8ad32c..2ed6d0919 100644 --- a/specification/schema/hugr_schema_strict_v1.json +++ b/specification/schema/hugr_schema_strict_v1.json @@ -562,25 +562,6 @@ "title": "CustomOp", "type": "object" }, - "CustomTypeArg": { - "additionalProperties": false, - "properties": { - "typ": { - "title": "Typ", - "type": "null" - }, - "value": { - "title": "Value", - "type": "string" - } - }, - "required": [ - "typ", - "value" - ], - "title": "CustomTypeArg", - "type": "object" - }, "DFG": { "additionalProperties": false, "description": "A simply nested dataflow graph.", @@ -1457,15 +1438,6 @@ "additionalProperties": false, "description": "An opaque Type that can be downcasted by the extensions that define it.", "properties": { - "t": { - "const": "Opaque", - "default": "Opaque", - "enum": [ - "Opaque" - ], - "title": "T", - "type": "string" - }, "extension": { "title": "Extension", "type": "string" @@ -1506,12 +1478,16 @@ "title": "Tya", "type": "string" }, - "arg": { - "$ref": "#/$defs/CustomTypeArg" + "typ": { + "$ref": "#/$defs/Opaque" + }, + "value": { + "title": "Value" } }, "required": [ - "arg" + "typ", + "value" ], "title": "OpaqueArg", "type": "object" @@ -1635,16 +1611,16 @@ "title": "Tya", "type": "string" }, - "args": { + "elems": { "items": { "$ref": "#/$defs/TypeArg" }, - "title": "Args", + "title": "Elems", "type": "array" } }, "required": [ - "args" + "elems" ], "title": "SequenceArg", "type": "object" @@ -1758,6 +1734,28 @@ "title": "Tag", "type": "object" }, + "TaggedOpaque": { + "additionalProperties": false, + "properties": { + "t": { + "const": "Opaque", + "default": "Opaque", + "enum": [ + "Opaque" + ], + "title": "T", + "type": "string" + }, + "o": { + "$ref": "#/$defs/Opaque" + } + }, + "required": [ + "o" + ], + "title": "TaggedOpaque", + "type": "object" + }, "TaggedSumType": { "additionalProperties": false, "properties": { @@ -1901,7 +1899,7 @@ "Array": "#/$defs/Array", "G": "#/$defs/FunctionType", "I": "#/$defs/USize", - "Opaque": "#/$defs/Opaque", + "Opaque": "#/$defs/TaggedOpaque", "Q": "#/$defs/Qubit", "Sum": "#/$defs/TaggedSumType", "V": "#/$defs/Variable" @@ -1928,7 +1926,7 @@ "$ref": "#/$defs/TaggedSumType" }, { - "$ref": "#/$defs/Opaque" + "$ref": "#/$defs/TaggedOpaque" }, { "$ref": "#/$defs/Alias" @@ -1944,7 +1942,8 @@ "Extensions": "#/$defs/ExtensionsArg", "Opaque": "#/$defs/OpaqueArg", "Sequence": "#/$defs/SequenceArg", - "Type": "#/$defs/TypeTypeArg" + "Type": "#/$defs/TypeTypeArg", + "Variable": "#/$defs/VariableArg" }, "propertyName": "tya" }, @@ -1963,6 +1962,9 @@ }, { "$ref": "#/$defs/ExtensionsArg" + }, + { + "$ref": "#/$defs/VariableArg" } ], "title": "TypeArg" @@ -2196,6 +2198,32 @@ ], "title": "Variable", "type": "object" + }, + "VariableArg": { + "properties": { + "tya": { + "const": "Variable", + "default": "Variable", + "enum": [ + "Variable" + ], + "title": "Tya", + "type": "string" + }, + "idx": { + "title": "Idx", + "type": "integer" + }, + "cached_decl": { + "$ref": "#/$defs/TypeParam" + } + }, + "required": [ + "idx", + "cached_decl" + ], + "title": "VariableArg", + "type": "object" } }, "description": "A serializable representation of a Hugr.", diff --git a/specification/schema/hugr_schema_v1.json b/specification/schema/hugr_schema_v1.json index 75e5823b2..9f6979cf4 100644 --- a/specification/schema/hugr_schema_v1.json +++ b/specification/schema/hugr_schema_v1.json @@ -562,25 +562,6 @@ "title": "CustomOp", "type": "object" }, - "CustomTypeArg": { - "additionalProperties": true, - "properties": { - "typ": { - "title": "Typ", - "type": "null" - }, - "value": { - "title": "Value", - "type": "string" - } - }, - "required": [ - "typ", - "value" - ], - "title": "CustomTypeArg", - "type": "object" - }, "DFG": { "additionalProperties": true, "description": "A simply nested dataflow graph.", @@ -1457,15 +1438,6 @@ "additionalProperties": true, "description": "An opaque Type that can be downcasted by the extensions that define it.", "properties": { - "t": { - "const": "Opaque", - "default": "Opaque", - "enum": [ - "Opaque" - ], - "title": "T", - "type": "string" - }, "extension": { "title": "Extension", "type": "string" @@ -1506,12 +1478,16 @@ "title": "Tya", "type": "string" }, - "arg": { - "$ref": "#/$defs/CustomTypeArg" + "typ": { + "$ref": "#/$defs/Opaque" + }, + "value": { + "title": "Value" } }, "required": [ - "arg" + "typ", + "value" ], "title": "OpaqueArg", "type": "object" @@ -1635,16 +1611,16 @@ "title": "Tya", "type": "string" }, - "args": { + "elems": { "items": { "$ref": "#/$defs/TypeArg" }, - "title": "Args", + "title": "Elems", "type": "array" } }, "required": [ - "args" + "elems" ], "title": "SequenceArg", "type": "object" @@ -1758,6 +1734,28 @@ "title": "Tag", "type": "object" }, + "TaggedOpaque": { + "additionalProperties": true, + "properties": { + "t": { + "const": "Opaque", + "default": "Opaque", + "enum": [ + "Opaque" + ], + "title": "T", + "type": "string" + }, + "o": { + "$ref": "#/$defs/Opaque" + } + }, + "required": [ + "o" + ], + "title": "TaggedOpaque", + "type": "object" + }, "TaggedSumType": { "additionalProperties": true, "properties": { @@ -1901,7 +1899,7 @@ "Array": "#/$defs/Array", "G": "#/$defs/FunctionType", "I": "#/$defs/USize", - "Opaque": "#/$defs/Opaque", + "Opaque": "#/$defs/TaggedOpaque", "Q": "#/$defs/Qubit", "Sum": "#/$defs/TaggedSumType", "V": "#/$defs/Variable" @@ -1928,7 +1926,7 @@ "$ref": "#/$defs/TaggedSumType" }, { - "$ref": "#/$defs/Opaque" + "$ref": "#/$defs/TaggedOpaque" }, { "$ref": "#/$defs/Alias" @@ -1944,7 +1942,8 @@ "Extensions": "#/$defs/ExtensionsArg", "Opaque": "#/$defs/OpaqueArg", "Sequence": "#/$defs/SequenceArg", - "Type": "#/$defs/TypeTypeArg" + "Type": "#/$defs/TypeTypeArg", + "Variable": "#/$defs/VariableArg" }, "propertyName": "tya" }, @@ -1963,6 +1962,9 @@ }, { "$ref": "#/$defs/ExtensionsArg" + }, + { + "$ref": "#/$defs/VariableArg" } ], "title": "TypeArg" @@ -2196,6 +2198,32 @@ ], "title": "Variable", "type": "object" + }, + "VariableArg": { + "properties": { + "tya": { + "const": "Variable", + "default": "Variable", + "enum": [ + "Variable" + ], + "title": "Tya", + "type": "string" + }, + "idx": { + "title": "Idx", + "type": "integer" + }, + "cached_decl": { + "$ref": "#/$defs/TypeParam" + } + }, + "required": [ + "idx", + "cached_decl" + ], + "title": "VariableArg", + "type": "object" } }, "description": "A serializable representation of a Hugr.", diff --git a/specification/schema/testing_hugr_schema_strict_v1.json b/specification/schema/testing_hugr_schema_strict_v1.json index 4949faabd..2747617b1 100644 --- a/specification/schema/testing_hugr_schema_strict_v1.json +++ b/specification/schema/testing_hugr_schema_strict_v1.json @@ -562,25 +562,6 @@ "title": "CustomOp", "type": "object" }, - "CustomTypeArg": { - "additionalProperties": false, - "properties": { - "typ": { - "title": "Typ", - "type": "null" - }, - "value": { - "title": "Value", - "type": "string" - } - }, - "required": [ - "typ", - "value" - ], - "title": "CustomTypeArg", - "type": "object" - }, "DFG": { "additionalProperties": false, "description": "A simply nested dataflow graph.", @@ -1457,15 +1438,6 @@ "additionalProperties": false, "description": "An opaque Type that can be downcasted by the extensions that define it.", "properties": { - "t": { - "const": "Opaque", - "default": "Opaque", - "enum": [ - "Opaque" - ], - "title": "T", - "type": "string" - }, "extension": { "title": "Extension", "type": "string" @@ -1506,12 +1478,16 @@ "title": "Tya", "type": "string" }, - "arg": { - "$ref": "#/$defs/CustomTypeArg" + "typ": { + "$ref": "#/$defs/Opaque" + }, + "value": { + "title": "Value" } }, "required": [ - "arg" + "typ", + "value" ], "title": "OpaqueArg", "type": "object" @@ -1635,16 +1611,16 @@ "title": "Tya", "type": "string" }, - "args": { + "elems": { "items": { "$ref": "#/$defs/TypeArg" }, - "title": "Args", + "title": "Elems", "type": "array" } }, "required": [ - "args" + "elems" ], "title": "SequenceArg", "type": "object" @@ -1758,6 +1734,28 @@ "title": "Tag", "type": "object" }, + "TaggedOpaque": { + "additionalProperties": false, + "properties": { + "t": { + "const": "Opaque", + "default": "Opaque", + "enum": [ + "Opaque" + ], + "title": "T", + "type": "string" + }, + "o": { + "$ref": "#/$defs/Opaque" + } + }, + "required": [ + "o" + ], + "title": "TaggedOpaque", + "type": "object" + }, "TaggedSumType": { "additionalProperties": false, "properties": { @@ -1901,7 +1899,7 @@ "Array": "#/$defs/Array", "G": "#/$defs/FunctionType", "I": "#/$defs/USize", - "Opaque": "#/$defs/Opaque", + "Opaque": "#/$defs/TaggedOpaque", "Q": "#/$defs/Qubit", "Sum": "#/$defs/TaggedSumType", "V": "#/$defs/Variable" @@ -1928,7 +1926,7 @@ "$ref": "#/$defs/TaggedSumType" }, { - "$ref": "#/$defs/Opaque" + "$ref": "#/$defs/TaggedOpaque" }, { "$ref": "#/$defs/Alias" @@ -1944,7 +1942,8 @@ "Extensions": "#/$defs/ExtensionsArg", "Opaque": "#/$defs/OpaqueArg", "Sequence": "#/$defs/SequenceArg", - "Type": "#/$defs/TypeTypeArg" + "Type": "#/$defs/TypeTypeArg", + "Variable": "#/$defs/VariableArg" }, "propertyName": "tya" }, @@ -1963,6 +1962,9 @@ }, { "$ref": "#/$defs/ExtensionsArg" + }, + { + "$ref": "#/$defs/VariableArg" } ], "title": "TypeArg" @@ -2196,6 +2198,32 @@ ], "title": "Variable", "type": "object" + }, + "VariableArg": { + "properties": { + "tya": { + "const": "Variable", + "default": "Variable", + "enum": [ + "Variable" + ], + "title": "Tya", + "type": "string" + }, + "idx": { + "title": "Idx", + "type": "integer" + }, + "cached_decl": { + "$ref": "#/$defs/TypeParam" + } + }, + "required": [ + "idx", + "cached_decl" + ], + "title": "VariableArg", + "type": "object" } }, "additionalProperties": false, diff --git a/specification/schema/testing_hugr_schema_v1.json b/specification/schema/testing_hugr_schema_v1.json index 72f8d4804..62c062626 100644 --- a/specification/schema/testing_hugr_schema_v1.json +++ b/specification/schema/testing_hugr_schema_v1.json @@ -562,25 +562,6 @@ "title": "CustomOp", "type": "object" }, - "CustomTypeArg": { - "additionalProperties": true, - "properties": { - "typ": { - "title": "Typ", - "type": "null" - }, - "value": { - "title": "Value", - "type": "string" - } - }, - "required": [ - "typ", - "value" - ], - "title": "CustomTypeArg", - "type": "object" - }, "DFG": { "additionalProperties": true, "description": "A simply nested dataflow graph.", @@ -1457,15 +1438,6 @@ "additionalProperties": true, "description": "An opaque Type that can be downcasted by the extensions that define it.", "properties": { - "t": { - "const": "Opaque", - "default": "Opaque", - "enum": [ - "Opaque" - ], - "title": "T", - "type": "string" - }, "extension": { "title": "Extension", "type": "string" @@ -1506,12 +1478,16 @@ "title": "Tya", "type": "string" }, - "arg": { - "$ref": "#/$defs/CustomTypeArg" + "typ": { + "$ref": "#/$defs/Opaque" + }, + "value": { + "title": "Value" } }, "required": [ - "arg" + "typ", + "value" ], "title": "OpaqueArg", "type": "object" @@ -1635,16 +1611,16 @@ "title": "Tya", "type": "string" }, - "args": { + "elems": { "items": { "$ref": "#/$defs/TypeArg" }, - "title": "Args", + "title": "Elems", "type": "array" } }, "required": [ - "args" + "elems" ], "title": "SequenceArg", "type": "object" @@ -1758,6 +1734,28 @@ "title": "Tag", "type": "object" }, + "TaggedOpaque": { + "additionalProperties": true, + "properties": { + "t": { + "const": "Opaque", + "default": "Opaque", + "enum": [ + "Opaque" + ], + "title": "T", + "type": "string" + }, + "o": { + "$ref": "#/$defs/Opaque" + } + }, + "required": [ + "o" + ], + "title": "TaggedOpaque", + "type": "object" + }, "TaggedSumType": { "additionalProperties": true, "properties": { @@ -1901,7 +1899,7 @@ "Array": "#/$defs/Array", "G": "#/$defs/FunctionType", "I": "#/$defs/USize", - "Opaque": "#/$defs/Opaque", + "Opaque": "#/$defs/TaggedOpaque", "Q": "#/$defs/Qubit", "Sum": "#/$defs/TaggedSumType", "V": "#/$defs/Variable" @@ -1928,7 +1926,7 @@ "$ref": "#/$defs/TaggedSumType" }, { - "$ref": "#/$defs/Opaque" + "$ref": "#/$defs/TaggedOpaque" }, { "$ref": "#/$defs/Alias" @@ -1944,7 +1942,8 @@ "Extensions": "#/$defs/ExtensionsArg", "Opaque": "#/$defs/OpaqueArg", "Sequence": "#/$defs/SequenceArg", - "Type": "#/$defs/TypeTypeArg" + "Type": "#/$defs/TypeTypeArg", + "Variable": "#/$defs/VariableArg" }, "propertyName": "tya" }, @@ -1963,6 +1962,9 @@ }, { "$ref": "#/$defs/ExtensionsArg" + }, + { + "$ref": "#/$defs/VariableArg" } ], "title": "TypeArg" @@ -2196,6 +2198,32 @@ ], "title": "Variable", "type": "object" + }, + "VariableArg": { + "properties": { + "tya": { + "const": "Variable", + "default": "Variable", + "enum": [ + "Variable" + ], + "title": "Tya", + "type": "string" + }, + "idx": { + "title": "Idx", + "type": "integer" + }, + "cached_decl": { + "$ref": "#/$defs/TypeParam" + } + }, + "required": [ + "idx", + "cached_decl" + ], + "title": "VariableArg", + "type": "object" } }, "additionalProperties": true,