Skip to content

Commit

Permalink
Merge pull request #993 from qiboteam/qq_run
Browse files Browse the repository at this point in the history
Replace qq auto with qq run
  • Loading branch information
Edoardo-Pedicillo authored Nov 4, 2024
2 parents 39e5d3c + 1e6d06c commit 2cb2090
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ targets: [0]

```
### How to run protocols
To run the protocols specified in the ```runcard```, Qibocal uses the `qq auto` command
To run the protocols specified in the ```runcard```, Qibocal uses the `qq run` command
```sh
qq auto <runcard> -o <output_folder>
qq run <runcard> -o <output_folder>
```
if ```<output_folder>``` is specified, the results will be saved in it, otherwise ```qq``` will automatically create a default folder containing the current date and the username.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting-started/example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Run the routine

.. code-block::
qq auto example.yml -o resonator_spectroscopy_routine
qq run example.yml -o resonator_spectroscopy_routine
6 changes: 3 additions & 3 deletions doc/source/getting-started/interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ regarding the protocols executed.
qq report <output_folder>
``qq auto``
``qq run``
^^^^^^^^^^^

The previous commands are put together using ``qq auto`` which will perform data acquisition, post-processing and report generation.
The previous commands are put together using ``qq run`` which will perform data acquisition, post-processing and report generation.
When executing multiple protocols they are executed following the actions specified in the runcard.

.. code-block::
qq auto <path_to_runcard> -o <output_folder>
qq run <path_to_runcard> -o <output_folder>
``qq update``
^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion doc/source/protocols/dispersive_shift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ It follows an example of the experiment parameters.
freq_width: 1000000
After running `qq auto`, the experiment is executed and the result will looks like
After running `qq run`, the experiment is executed and the result will looks like
the following picture.

.. image:: dispersive_shift.png
Expand Down
2 changes: 1 addition & 1 deletion doc/source/protocols/rabi/rabi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ It follows an example of the experiment parameters.
To run properly this experiment it is important to set the
`relaxation_time` higher than the qubit `T1`.

After running `qq auto`, the experiment is executed and the result will looks like
After running `qq run`, the experiment is executed and the result will looks like
the following picture.

.. image:: rabi_amplitude.png
Expand Down
53 changes: 49 additions & 4 deletions src/qibocal/cli/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from ..auto.runcard import Runcard
from .acquisition import acquire as acquisition
from .autocalibration import autocalibrate
from .compare import compare_reports
from .fit import fit as fitting
from .report import report as reporting
from .run import protocols_execution
from .update import update as updating
from .upload import upload_report

Expand Down Expand Up @@ -58,8 +58,8 @@ def command():
default=None,
help="Name of the Qibo backend.,",
)
def auto(runcard, folder, force, update, platform, backend):
"""Autocalibration.
def run(runcard, folder, force, update, platform, backend):
"""Execute the qubit calibration.
Arguments:
Expand All @@ -72,7 +72,7 @@ def auto(runcard, folder, force, update, platform, backend):
if backend is not None:
runcard.backend = backend

autocalibrate(runcard, folder, force, update)
protocols_execution(runcard, folder, force, update)


@command.command(context_settings=CONTEXT_SETTINGS)
Expand Down Expand Up @@ -236,3 +236,48 @@ def upload(path, tag, author):
)
def compare(report_1_path, report_2_path, folder, force):
compare_reports(folder, report_1_path, report_2_path, force)


@command.command(context_settings=CONTEXT_SETTINGS, deprecated=True)
@click.argument(
"runcard", metavar="RUNCARD", type=click.Path(exists=True, path_type=pathlib.Path)
)
@click.option(
"folder",
"-o",
type=click.Path(path_type=pathlib.Path),
help="Output folder. If not provided a standard name will generated.",
)
@click.option(
"force",
"-f",
is_flag=True,
help="Use --force option to overwrite the output folder.",
)
@click.option(
"--update/--no-update",
default=True,
help="Use --no-update option to avoid updating iteratively the platform."
"With this option the new runcard will not be produced.",
)
@click.option(
"--platform",
default=None,
help="Name of the Qibolab platform.",
)
@click.option(
"--backend",
default=None,
help="Name of the Qibo backend.,",
)
def auto(runcard, folder, force, update, platform, backend):
"""Execute the qubit calibration.
Arguments:
- RUNCARD: runcard with declarative inputs.
"""
click.echo(
"Warning: This command is deprecated and may be removed in a future version. Please use 'qq run' instead. ",
err=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .report import report


def autocalibrate(runcard: Runcard, folder: Path, force, update):
def protocols_execution(runcard: Runcard, folder: Path, force, update):
"""Autocalibration.
Arguments:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_qq_update(update, tmp_path, monkeypatch):
runner = CliRunner()
runner.invoke(
command,
["auto", str(DUMMY_ACTION), "-o", str(output_folder), "-f", update],
["run", str(DUMMY_ACTION), "-o", str(output_folder), "-f", update],
catch_exceptions=False,
)

Expand Down Expand Up @@ -85,8 +85,8 @@ def test_compare_report_dates(tmp_path):
compare_dir = tmp_path / "compare_dir"

runner = CliRunner()
runner.invoke(command, ["auto", str(DUMMY_COMPARE), "-o", str(report_dir_1), "-f"])
runner.invoke(command, ["auto", str(DUMMY_COMPARE), "-o", str(report_dir_2), "-f"])
runner.invoke(command, ["run", str(DUMMY_COMPARE), "-o", str(report_dir_1), "-f"])
runner.invoke(command, ["run", str(DUMMY_COMPARE), "-o", str(report_dir_2), "-f"])

runner.invoke(
command,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
ACTION = Action(**action)


# TODO: this is essentially a proto `qq auto` invocation, it should be simplified as
# TODO: this is essentially a proto `qq run` invocation, it should be simplified as
# much as possible in the library, and made available in conftest
@pytest.fixture
def fake_output(tmp_path: Path) -> tuple[Output, Path]:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ def locate_tomography_file(runcard):

@pytest.mark.parametrize("update", ["--update", "--no-update"])
@pytest.mark.parametrize("runcard", generate_runcard_single_protocol(), ids=idfn)
def test_auto_command(runcard, update, tmp_path):
def test_run_command(runcard, update, tmp_path):
"""Test auto command pipeline."""
runcard = runcard[0]

locate_tomography_file(runcard)

(tmp_path / SINGLE_ACTION_RUNCARD).write_text(yaml.safe_dump(runcard))
outpath = tmp_path / "auto_test"
outpath = tmp_path / "run_test"
runner = CliRunner()
runner.invoke(
command,
[
"auto",
"run",
str(tmp_path / SINGLE_ACTION_RUNCARD),
"-o",
str(outpath),
Expand Down

0 comments on commit 2cb2090

Please sign in to comment.