diff --git a/src/qibolab/instruments/bluefors.py b/src/qibolab/instruments/bluefors.py index b38442ca4..b92ddc6fd 100644 --- a/src/qibolab/instruments/bluefors.py +++ b/src/qibolab/instruments/bluefors.py @@ -1,6 +1,7 @@ import socket import yaml +from pydantic import Field from qibo.config import log from qibolab.instruments.abstract import Instrument @@ -19,17 +20,13 @@ class TemperatureController(Instrument): print(temperature_value) """ - def __init__(self, name: str, address: str, port: int = 8888): - """Creation of the controller object. - - Args: - name (str): name of the instrument. - address (str): IP address of the board sending cryo temperature data. - port (int): port of the board sending cryo temperature data. - """ - super().__init__(name, address) - self.port = port - self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + address: str + """IP address of the board sending cryo temperature data.""" + port: int = 8888 + """Port of the board sending cryo temperature data.""" + client_socket: socket.socket = Field( + default_factory=lambda: socket.socket(socket.AF_INET, socket.SOCK_STREAM) + ) def connect(self): """Connect to the socket.""" diff --git a/src/qibolab/instruments/erasynth.py b/src/qibolab/instruments/erasynth.py index 9f4b13652..7bf88dc9f 100644 --- a/src/qibolab/instruments/erasynth.py +++ b/src/qibolab/instruments/erasynth.py @@ -4,7 +4,7 @@ from qcodes_contrib_drivers.drivers.ERAInstruments import ERASynthPlusPlus from qibo.config import log -from qibolab.instruments.oscillator import LocalOscillator +from qibolab.instruments.oscillator import LocalOscillator, LocalOscillatorSettings RECONNECTION_ATTEMPTS = 10 """Number of times to attempt sending requests to the web server in case of @@ -128,7 +128,11 @@ class ERA(LocalOscillator): """ def __init__(self, name, address, ethernet=True, ref_osc_source=None): - super().__init__(name, address, ref_osc_source) + super().__init__( + name=name, + address=address, + settings=LocalOscillatorSettings(ref_osc_source=ref_osc_source), + ) self.ethernet = ethernet def create(self): diff --git a/src/qibolab/instruments/icarusqfpga.py b/src/qibolab/instruments/icarusqfpga.py index 4a6b7c35e..f4258df42 100644 --- a/src/qibolab/instruments/icarusqfpga.py +++ b/src/qibolab/instruments/icarusqfpga.py @@ -12,9 +12,10 @@ AveragingMode, ExecutionParameters, ) +from qibolab.identifier import QubitId from qibolab.instruments.abstract import Controller from qibolab.pulses import Pulse -from qibolab.qubits import Qubit, QubitId +from qibolab.qubits import Qubit from qibolab.result import average, average_iq, collect from qibolab.sequence import PulseSequence from qibolab.sweeper import Parameter, Sweeper, SweeperType @@ -41,7 +42,7 @@ def __init__( delay_samples_offset_dac: int = 0, delay_samples_offset_adc: int = 0, ): - super().__init__(name, address) + super().__init__(name=name, address=address, bounds="icarusq/bounds") self.channel_delay_offset_dac = delay_samples_offset_dac self.channel_delay_offset_adc = delay_samples_offset_adc diff --git a/src/qibolab/instruments/qblox/module.py b/src/qibolab/instruments/qblox/module.py index 61203bc67..240894d91 100644 --- a/src/qibolab/instruments/qblox/module.py +++ b/src/qibolab/instruments/qblox/module.py @@ -14,7 +14,7 @@ class ClusterModule(Instrument): """ def __init__(self, name: str, address: str): - super().__init__(name, address) + super().__init__(name=name, address=address) DEFAULT_SEQUENCERS_VALUES = { "cont_mode_en_awg_path0": False, "cont_mode_en_awg_path1": False, diff --git a/src/qibolab/instruments/qm/controller.py b/src/qibolab/instruments/qm/controller.py index fda8cccd2..d1e3815ad 100644 --- a/src/qibolab/instruments/qm/controller.py +++ b/src/qibolab/instruments/qm/controller.py @@ -2,10 +2,11 @@ import tempfile import warnings from collections import defaultdict -from dataclasses import asdict, dataclass, field +from dataclasses import asdict, dataclass from pathlib import Path from typing import Optional +from pydantic import Field from qm import QuantumMachinesManager, SimulationConfig, generate_qua_script from qm.octave import QmOctaveConfig from qm.simulate.credentials import create_credentials @@ -112,7 +113,6 @@ def fetch_results(result, acquisitions): } -@dataclass class QmController(Controller): """:class:`qibolab.instruments.abstract.Controller` object for controlling a Quantum Machines cluster. @@ -138,7 +138,7 @@ class QmController(Controller): """Dictionary containing the :class:`qibolab.instruments.qm.controller.Octave` instruments being used.""" - channels: dict[str, QmChannel] + channels: dict[ChannelId, QmChannel] bounds: str = "qm/bounds" """Maximum bounds used for batching in sequence unrolling.""" @@ -165,7 +165,7 @@ class QmController(Controller): is_connected: bool = False """Boolean that shows whether we are connected to the QM manager.""" - config: QmConfig = field(default_factory=QmConfig) + config: QmConfig = Field(default_factory=QmConfig) """Configuration dictionary required for pulse execution on the OPXs.""" simulation_duration: Optional[int] = None @@ -184,12 +184,9 @@ class QmController(Controller): Default is ``False``. """ - def __post_init__(self): - super().__init__(self.name, self.address) + def model_post_init(self, __context): # convert ``channels`` from list to dict - self.channels = { - str(channel.logical_channel.name): channel for channel in self.channels - } + self.channels = {channel.logical_channel: channel for channel in self.channels} if self.simulation_duration is not None: # convert simulation duration from ns to clock cycles diff --git a/src/qibolab/instruments/rfsoc/driver.py b/src/qibolab/instruments/rfsoc/driver.py index 307b31c43..f40d99bae 100644 --- a/src/qibolab/instruments/rfsoc/driver.py +++ b/src/qibolab/instruments/rfsoc/driver.py @@ -50,7 +50,7 @@ def __init__(self, name: str, address: str, port: int, sampling_rate: float = 1. address (str): IP and port of the server (ex. 192.168.0.10) port (int): Port of the server (ex.6000) """ - super().__init__(name, address=address) + super().__init__(name=name, address=address) self.host = address self.port = port self.cfg = rfsoc.Config() diff --git a/src/qibolab/instruments/zhinst/executor.py b/src/qibolab/instruments/zhinst/executor.py index c6e000b3d..d72b9c2ec 100644 --- a/src/qibolab/instruments/zhinst/executor.py +++ b/src/qibolab/instruments/zhinst/executor.py @@ -56,7 +56,7 @@ def __init__( time_of_flight=0.0, smearing=0.0, ): - super().__init__(name, None) + super().__init__(name=name, address=None) self.signal_map = {} "Signals to lines mapping"