Skip to content

Commit

Permalink
Comments and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Oct 30, 2023
1 parent 85ec235 commit 9554f05
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
18 changes: 8 additions & 10 deletions src/qibocal/cli/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ def auto(runcard, folder, force, update, platform, backend):
- RUNCARD: runcard with declarative inputs.
"""
card = yaml.safe_load(runcard.read_text(encoding="utf-8"))
action_runcard = Runcard.load(card)
plat = platform if platform is not None else action_runcard.platform
back = backend if backend is not None else action_runcard.backend
autocalibrate(action_runcard, folder, force, update, plat, back)
runcard = Runcard.load(yaml.safe_load(runcard.read_text(encoding="utf-8")))
plat = platform if platform is not None else runcard.platform
back = backend if backend is not None else runcard.backend
autocalibrate(runcard, folder, force, update, plat, back)


@command.command(context_settings=CONTEXT_SETTINGS)
Expand Down Expand Up @@ -101,11 +100,10 @@ def acquire(runcard, folder, force, platform, backend):
- RUNCARD: runcard with declarative inputs.
"""
card = yaml.safe_load(runcard.read_text(encoding="utf-8"))
action_runcard = Runcard.load(card)
plat = platform if platform is not None else action_runcard.platform
back = backend if backend is not None else action_runcard.backend
acquisition(action_runcard, folder, force, plat, back)
runcard = Runcard.load(yaml.safe_load(runcard.read_text(encoding="utf-8")))
plat = platform if platform is not None else runcard.platform
back = backend if backend is not None else runcard.backend
acquisition(runcard, folder, force, plat, back)


@command.command(context_settings=CONTEXT_SETTINGS)
Expand Down
4 changes: 2 additions & 2 deletions src/qibocal/cli/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def acquire(runcard, folder, force, platform_name, backend_name):
- RUNCARD: runcard with declarative inputs.
"""

# generate output folder
path = generate_output_folder(folder, force)

# FIXME: it should be a function
# allocate qubits, runcard and executor
# set backend, platform and qubits
GlobalBackend.set_backend(backend=backend_name, platform=platform_name)
backend = GlobalBackend()
platform = backend.platform
Expand Down
18 changes: 12 additions & 6 deletions src/qibocal/cli/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,33 @@ def fit(path, update):
- FOLDER: input folder.
"""
# load path, meta, runcard and executor
meta = yaml.safe_load((path / META).read_text())
# load meta
meta = json.loads((path / META).read_text())
# load runcard
runcard = Runcard.load(yaml.safe_load((path / RUNCARD).read_text()))

# set backend, platform and qubits
GlobalBackend.set_backend(backend=meta["backend"], platform=meta["platform"])
backend = GlobalBackend()
platform = backend.platform
qubits = create_qubits_dict(qubits=runcard.qubits, platform=platform)

# load executor
executor = Executor.load(
runcard, path, update=update, platform=platform, qubits=qubits
)

# perform post-processing
list(executor.run(mode=ExecutionMode.fit))

# update time in meta
meta = add_timings_to_meta(meta, executor.history)
e = datetime.datetime.now(datetime.timezone.utc)
meta["end-time"] = e.strftime("%H:%M:%S")

# dump updated runcard
if platform is not None and update:
dump_runcard(platform, path / UPDATED_PLATFORM)

# update time in meta.yml
meta = add_timings_to_meta(meta, executor.history)
e = datetime.datetime.now(datetime.timezone.utc)
meta["end-time"] = e.strftime("%H:%M:%S")
# dump json
(path / META).write_text(json.dumps(meta, indent=4))
9 changes: 7 additions & 2 deletions src/qibocal/cli/report.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import tempfile
from functools import cached_property
from pathlib import Path
Expand Down Expand Up @@ -27,13 +28,17 @@ def report(path):
- FOLDER: input folder.
"""
# load path, meta and runcard
meta = yaml.safe_load((path / META).read_text())
# load meta
meta = json.loads((path / META).read_text())
# load runcard
runcard = Runcard.load(yaml.safe_load((path / RUNCARD).read_text()))

# set backend, platform and qubits
GlobalBackend.set_backend(backend=meta["backend"], platform=meta["platform"])
backend = GlobalBackend()
platform = backend.platform
qubits = create_qubits_dict(qubits=runcard.qubits, platform=platform)

# load executor
executor = Executor.load(runcard, path, qubits=qubits)

Expand Down

0 comments on commit 9554f05

Please sign in to comment.