From 34a23b63b3b2cf6c38e612632155f48d8b92481c Mon Sep 17 00:00:00 2001 From: Edoardo-Pedicillo Date: Tue, 8 Oct 2024 12:10:07 +0400 Subject: [PATCH 1/3] fix: circuit serialization as parameters of the tomography --- src/qibocal/auto/task.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qibocal/auto/task.py b/src/qibocal/auto/task.py index 33a038680..aaf5b43c2 100644 --- a/src/qibocal/auto/task.py +++ b/src/qibocal/auto/task.py @@ -1,11 +1,13 @@ """Action execution tracker.""" import copy +import json from dataclasses import asdict, dataclass from pathlib import Path from typing import Any, NewType, Optional, Union import yaml +from qibo import Circuit from qibolab.platform import Platform from qibolab.qubits import QubitId, QubitPairId @@ -21,6 +23,7 @@ """Elements to be calibrated by a single protocol.""" SINGLE_ACTION = "action.yml" +CIRCUIT = "circuit.json" @dataclass @@ -40,6 +43,12 @@ class Action: def dump(self, path: Path): """Dump single action to yaml.""" + if self.parameters is not None: + for param, value in self.parameters.items(): + if type(value) is Circuit: + circuit_file = open(CIRCUIT, "w") + json.dump(value.raw, circuit_file) + self.parameters[param] = str(CIRCUIT) (path / SINGLE_ACTION).write_text(yaml.safe_dump(asdict(self))) @classmethod From b2e54f5ce48e0be0bc7bc5ada8aa49f975091607 Mon Sep 17 00:00:00 2001 From: Edoardo-Pedicillo Date: Tue, 8 Oct 2024 13:23:44 +0400 Subject: [PATCH 2/3] fix: change file circuit path --- src/qibocal/auto/task.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qibocal/auto/task.py b/src/qibocal/auto/task.py index aaf5b43c2..d00c0e7ae 100644 --- a/src/qibocal/auto/task.py +++ b/src/qibocal/auto/task.py @@ -46,9 +46,10 @@ def dump(self, path: Path): if self.parameters is not None: for param, value in self.parameters.items(): if type(value) is Circuit: - circuit_file = open(CIRCUIT, "w") + circuit_path = path / CIRCUIT + circuit_file = open(circuit_path, "w") json.dump(value.raw, circuit_file) - self.parameters[param] = str(CIRCUIT) + self.parameters[param] = str(circuit_path) (path / SINGLE_ACTION).write_text(yaml.safe_dump(asdict(self))) @classmethod From 14acf17ecd8a8b9c386886c5830d6eb1243b654e Mon Sep 17 00:00:00 2001 From: Edoardo-Pedicillo Date: Wed, 9 Oct 2024 12:38:24 +0400 Subject: [PATCH 3/3] fix: close descriptor --- src/qibocal/auto/task.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qibocal/auto/task.py b/src/qibocal/auto/task.py index d00c0e7ae..c8a07d9fc 100644 --- a/src/qibocal/auto/task.py +++ b/src/qibocal/auto/task.py @@ -47,8 +47,7 @@ def dump(self, path: Path): for param, value in self.parameters.items(): if type(value) is Circuit: circuit_path = path / CIRCUIT - circuit_file = open(circuit_path, "w") - json.dump(value.raw, circuit_file) + circuit_path.write_text(json.dumps(value.raw)) self.parameters[param] = str(circuit_path) (path / SINGLE_ACTION).write_text(yaml.safe_dump(asdict(self)))