From 237930f118ef76166ac1a11564b915ed604763c4 Mon Sep 17 00:00:00 2001 From: Mythir Date: Tue, 15 Apr 2025 15:21:38 +0200 Subject: [PATCH] Reorganise for expanded topology --- schemas/get_dynamic/reply_success.schema.json | 2 +- schemas/get_static/reply_success.schema.json | 38 ++++++++++--------- .../models/get_static_reply_success.py | 14 +++++-- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/schemas/get_dynamic/reply_success.schema.json b/schemas/get_dynamic/reply_success.schema.json index 05a3bba..0afff95 100644 --- a/schemas/get_dynamic/reply_success.schema.json +++ b/schemas/get_dynamic/reply_success.schema.json @@ -30,4 +30,4 @@ ], "title": "Get hardware data reply", "type": "object" -} +} \ No newline at end of file diff --git a/schemas/get_static/reply_success.schema.json b/schemas/get_static/reply_success.schema.json index ff138c9..fcf4143 100644 --- a/schemas/get_static/reply_success.schema.json +++ b/schemas/get_static/reply_success.schema.json @@ -80,22 +80,8 @@ "type": "integer" }, "topology": { - "description": "List of the edges between the various qubits", - "items": { - "maxItems": 2, - "minItems": 2, - "prefixItems": [ - { - "type": "integer" - }, - { - "type": "integer" - } - ], - "type": "array" - }, - "title": "Topology", - "type": "array" + "$ref": "#/$defs/Topology", + "description": "List of the edges between the various qubits" }, "name": { "description": "Name of the system.", @@ -141,6 +127,24 @@ ], "title": "QuantumHardwareStaticData", "type": "object" + }, + "Topology": { + "description": "A class representing the topology of a quantum chip.\n\nIt is a list of tuples, where each tuple represents a unidirectional connection between two qubits. The first\nelement of the tuple is the source qubit, and the second element is the target qubit.", + "items": { + "maxItems": 2, + "minItems": 2, + "prefixItems": [ + { + "type": "integer" + }, + { + "type": "integer" + } + ], + "type": "array" + }, + "title": "Topology", + "type": "array" } }, "description": "The reply containing system information for 2300.", @@ -167,4 +171,4 @@ ], "title": "Get hardware data reply", "type": "object" -} +} \ No newline at end of file diff --git a/tests/control-software-validator/models/get_static_reply_success.py b/tests/control-software-validator/models/get_static_reply_success.py index bb16fa8..ab692b6 100644 --- a/tests/control-software-validator/models/get_static_reply_success.py +++ b/tests/control-software-validator/models/get_static_reply_success.py @@ -30,6 +30,14 @@ class TopologyItem(RootModel[List]): root: List = Field(..., max_length=2, min_length=2) +class Topology(RootModel[List[TopologyItem]]): + root: List[TopologyItem] = Field( + ..., + description='A class representing the topology of a quantum chip.\n\nIt is a list of tuples, where each tuple represents a unidirectional connection between two qubits. The first\nelement of the tuple is the source qubit, and the second element is the target qubit.', + title='Topology', + ) + + class CompilerConfig(BaseModel): decomposition: Optional[List[CompilerPass]] = Field([], title='Decomposition') mapping: Optional[List[CompilerPass]] = Field([], title='Mapping') @@ -39,10 +47,8 @@ class CompilerConfig(BaseModel): class QuantumHardwareStaticData(BaseModel): nqubits: int = Field(..., description='The number of qubits.', title='Nqubits') - topology: List[TopologyItem] = Field( - ..., - description='List of the edges between the various qubits', - title='Topology', + topology: Topology = Field( + ..., description='List of the edges between the various qubits' ) name: str = Field(..., description='Name of the system.', title='Name') pgs: List[str] = Field(