Skip to content

Commit

Permalink
Merge pull request #726 from qiboteam/fix_targets
Browse files Browse the repository at this point in the history
Restoring execution without specifying `targets` in runcard
  • Loading branch information
andrea-pasquale authored Feb 23, 2024
2 parents 9c7a34c + e1c993b commit 804691a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 66 deletions.
8 changes: 7 additions & 1 deletion src/qibocal/auto/runcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ class Runcard:
actions: list[Action]
"""List of action to be executed."""
targets: Optional[Targets] = None
"""Qubits to be calibrated."""
"""Qubits to be calibrated.
If `None` the protocols will be executed on all qubits
available in the platform."""
backend: str = "qibolab"
"""Qibo backend."""
platform: str = os.environ.get("QIBO_PLATFORM", "dummy")
"""Qibolab platform."""
max_iterations: int = MAX_ITERATIONS
"""Maximum number of iterations."""

def __post_init__(self):
if self.targets is None and self.platform_obj is not None:
self.targets = list(self.platform_obj.qubits)

@cached_property
def backend_obj(self) -> Backend:
"""Allocate backend."""
Expand Down
3 changes: 0 additions & 3 deletions src/qibocal/cli/autocalibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def autocalibrate(runcard, folder, force, update):
# generate output folder
path = generate_output_folder(folder, force)

# allocate qubits
# qubits = create_qubits_dict(qubits=runcard.qubits, platform=platform)

# generate meta
meta = generate_meta(backend, platform, path)
# dump platform
Expand Down
11 changes: 0 additions & 11 deletions src/qibocal/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pathlib import Path

from qibocal.config import log, raise_error
from qibocal.utils import allocate_qubits_pairs, allocate_single_qubits

RUNCARD = "runcard.yml"
UPDATED_PLATFORM = "new_platform"
Expand All @@ -22,16 +21,6 @@ def dump_report(meta, path):
(path / META).write_text(json.dumps(meta, indent=4))


def create_qubits_dict(qubits, platform):
if platform is not None:
if qubits is not None:
if any(isinstance(i, list) for i in qubits):
return allocate_qubits_pairs(platform, qubits)
return allocate_single_qubits(platform, qubits)
return allocate_single_qubits(platform, list(platform.qubits))
return qubits


def generate_meta(backend, platform, path):
"""Methods that takes care of:
- dumping original platform
Expand Down
28 changes: 0 additions & 28 deletions src/qibocal/utils.py

This file was deleted.

20 changes: 0 additions & 20 deletions tests/test_cli_utils.py

This file was deleted.

7 changes: 4 additions & 3 deletions tests/test_task_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
QUBITS = list(PLATFORM.qubits)
DUMMY_CARD = {
"backend": "numpy",
"qubits": QUBITS,
"targets": QUBITS,
"actions": [
{
"id": "standard rb",
Expand Down Expand Up @@ -49,7 +49,7 @@ def modify_card(card, targets=None, update=None):

@pytest.mark.parametrize("platform", [None, PLATFORM])
@pytest.mark.parametrize("local_targets", [None, [0, 1]])
def test_qubits_argument(platform, local_targets, tmp_path):
def test_targets_argument(platform, local_targets, tmp_path):
"""Test possible qubits combinations between global and local."""
runcard = Runcard.load(modify_card(DUMMY_CARD, targets=local_targets))
print(runcard)
Expand All @@ -66,10 +66,11 @@ def test_qubits_argument(platform, local_targets, tmp_path):
assert completed.task.targets == local_targets
else:
assert completed.task.targets == list(QUBITS)
assert runcard.targets == list(QUBITS)


UPDATE_CARD = {
"qubits": QUBITS,
"targets": QUBITS,
"actions": [
{
"id": "resonator frequency",
Expand Down

0 comments on commit 804691a

Please sign in to comment.