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

Migrate from deprecated json schema methods #1098

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions pytket/tests/architecture_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# limitations under the License.

import json
from jsonschema import RefResolver, Draft7Validator # type: ignore
from referencing import Registry
from referencing.jsonschema import DRAFT7
from jsonschema import Draft7Validator # type: ignore
from pathlib import Path
from pytket.circuit import Node
from pytket.architecture import Architecture, SquareGrid, FullyConnected, RingArch
Expand All @@ -27,15 +29,14 @@
with open(schema_dir / "fullyconnected_v1.json", "r") as f:
fc_schema = json.load(f)

schema_store = {
circ_schema["$id"]: circ_schema,
arch_schema["$id"]: arch_schema,
fc_schema["$id"]: fc_schema,
}
arch_validator_resolver = RefResolver.from_schema(arch_schema, store=schema_store)
arch_validator = Draft7Validator(arch_schema, resolver=arch_validator_resolver)
fc_validator_resolver = RefResolver.from_schema(fc_schema, store=schema_store)
fc_validator = Draft7Validator(fc_schema, resolver=fc_validator_resolver)
schema_store = [
(circ_schema["$id"], DRAFT7.create_resource(circ_schema)),
(arch_schema["$id"], DRAFT7.create_resource(arch_schema)),
(fc_schema["$id"], DRAFT7.create_resource(fc_schema)),
]
registry: Registry = Registry().with_resources(schema_store)
arch_validator = Draft7Validator(arch_schema, registry=registry)
fc_validator = Draft7Validator(fc_schema, registry=registry)


def check_arch_serialisation(arch: Architecture) -> None:
Expand Down
27 changes: 13 additions & 14 deletions pytket/tests/passes_serialisation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

import json
import pytest
from jsonschema import RefResolver, Draft7Validator, ValidationError # type: ignore
from referencing import Registry
from referencing.jsonschema import DRAFT7
from jsonschema import Draft7Validator, ValidationError # type: ignore
from pathlib import Path
from typing import Any, Dict, List

Expand Down Expand Up @@ -408,19 +410,16 @@ def nonparam_predicate_dict(name: str) -> Dict[str, Any]:
with open(schema_dir / "predicate_v1.json", "r") as f:
pred_schema = json.load(f)

schema_store = {
pass_schema["$id"]: pass_schema,
circ_schema["$id"]: circ_schema,
arch_schema["$id"]: arch_schema,
plact_schema["$id"]: plact_schema,
pred_schema["$id"]: pred_schema,
}
pass_validator_resolver = RefResolver.from_schema(pass_schema, store=schema_store)
pass_validator = Draft7Validator(pass_schema, resolver=pass_validator_resolver)
predicate_validator_resolver = RefResolver.from_schema(pred_schema, store=schema_store)
predicate_validator = Draft7Validator(
pred_schema, resolver=predicate_validator_resolver
)
schema_store = [
(pass_schema["$id"], DRAFT7.create_resource(pass_schema)),
(circ_schema["$id"], DRAFT7.create_resource(circ_schema)),
(arch_schema["$id"], DRAFT7.create_resource(arch_schema)),
(plact_schema["$id"], DRAFT7.create_resource(plact_schema)),
(pred_schema["$id"], DRAFT7.create_resource(pred_schema)),
]
registry: Registry = Registry().with_resources(schema_store)
pass_validator = Draft7Validator(pass_schema, registry=registry)
predicate_validator = Draft7Validator(pred_schema, registry=registry)


def check_pass_serialisation(
Expand Down
2 changes: 1 addition & 1 deletion schemas/compiler_pass_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"description": "Minimal number of CX gates in each phase in \"ComposePhasePolyBoxes\"."
},
"routing_config": {
"$ref": "#definitions/routing_config"
"$ref": "#/definitions/routing_config"
},
"fidelities": {
"type": "object",
Expand Down
Loading