Skip to content

Commit

Permalink
Merge pull request #1002 from qiboteam/params_yaml
Browse files Browse the repository at this point in the history
Circuit serialization as parameters of the tomography
  • Loading branch information
Edoardo-Pedicillo authored Oct 14, 2024
2 parents 6789ac8 + 14acf17 commit 22f62d5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/qibocal/auto/task.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -21,6 +23,7 @@
"""Elements to be calibrated by a single protocol."""

SINGLE_ACTION = "action.yml"
CIRCUIT = "circuit.json"


@dataclass
Expand All @@ -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_path = path / CIRCUIT
circuit_path.write_text(json.dumps(value.raw))
self.parameters[param] = str(circuit_path)
(path / SINGLE_ACTION).write_text(yaml.safe_dump(asdict(self)))

@classmethod
Expand Down

0 comments on commit 22f62d5

Please sign in to comment.