diff --git a/src/qibolab/_core/platform/load.py b/src/qibolab/_core/platform/load.py index a79e7adf9..034d8763e 100644 --- a/src/qibolab/_core/platform/load.py +++ b/src/qibolab/_core/platform/load.py @@ -62,7 +62,7 @@ def locate_platform(name: str, paths: Optional[list[Path]] = None) -> Path: return _search(name, paths) -def create_platform(name: str, params: Optional[dict] = None) -> Platform: +def create_platform(name: str, parameters: Optional[Parameters] = None) -> Platform: """A platform for executing quantum algorithms. It consists of a quantum processor QPU and a set of controlling instruments. @@ -83,10 +83,10 @@ def create_platform(name: str, params: Optional[dict] = None) -> Platform: if isinstance(hardware, Platform): return hardware - if params is None: + if parameters is None: return Platform.load(path, **hardware) - return Platform(**hardware, parameters=Parameters(**params)) + return Platform(**hardware, parameters=parameters) def available_platforms() -> list[str]: diff --git a/src/qibolab/_core/platform/platform.py b/src/qibolab/_core/platform/platform.py index 4ef4d292a..e5f61bc25 100644 --- a/src/qibolab/_core/platform/platform.py +++ b/src/qibolab/_core/platform/platform.py @@ -16,6 +16,7 @@ InstrumentMap, NativeGates, Parameters, + ParametersBuilder, QubitMap, Settings, Update, @@ -310,13 +311,13 @@ def load( if couplers is None: couplers = {} - return cls( - name=name, - parameters=Parameters.model_validate_json((path / PARAMETERS).read_text()), - instruments=instruments, - qubits=qubits, - couplers=couplers, - ) + hardware = {"instruments": instruments, "qubits": qubits, "couplers": couplers} + try: + parameters = Parameters.model_validate_json((path / PARAMETERS).read_text()) + except FileNotFoundError: + parameters = ParametersBuilder(hardware=hardware).build() + + return cls(name=name, parameters=parameters, **hardware) def dump(self, path: Path): """Dump platform."""