Frontend-agnostic core¶
Notebook integration for the Qibocal executor.
Executor is a drop-in replacement of qibocal.Executor,
composed of three roles:
a
Runner, deciding where and how the steps run (Localby default, orRemote);Middleware, wrapping every step;Frontendobjects, displaying every output.
from qibocal_widgets import Executor
from qibocal_widgets.marimo import Marimo
executor = Executor.create(platform="mock", path="var/report", frontends=[Marimo()])
Frontends live in their own modules:
qibocal_widgets.marimo(requires themarimoextra)qibocal_widgets.jupyter(requires thejupyterextra)
Executions are recorded in a Session folder, appended for as long as
the executor lives. Without an explicit path, Executor.create and
Executor.open use a fresh folder of the session’s reports folder
(reports_dir()).
The calibration state of the platform can be explored and updated by path,
programmatically or with an interactive explorer (PlatformState,
executor.platform_state).
This module also exposes the frontend-agnostic building blocks, useful to write further runners, middleware, and frontends.
- class qibocal_widgets.Completed(task=None, path=None, _data=None, _results=None, data_time=0, results_time=0, bound=None, reports=None, protocol_id=None, error=None, success=True, _targets=None, notes=<factory>, views=<factory>, updates=None)¶
Bases:
CompletedExecution carrying views for notebook frontends.
Views are keyed by the display protocol they implement. Without a view for a protocol, the execution falls back to its plain representation, so views for several frontends can coexist on the same object.
- Parameters:
task (Task | None)
path (Path | None)
_data (Data | None)
_results (Results | None)
data_time (float)
results_time (float)
bound (BoundProtocol | None)
reports (Any)
protocol_id (str | None)
error (Exception | None)
success (bool)
_targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None)
notes (list[Note])
updates (Updates | None)
- updates: Updates | None = None¶
Its platform update, and the targets applied, if produced by an executor of this package (shared by its copies).
- update(targets=None)¶
Apply the platform update of the execution, after validating its fit.
To all targets, or to some (e.g.
completed.update([0, 2])); those already applied are skipped. The same as its Update buttons.- Returns:
The targets the update was applied to now.
- Raises:
ValueError – if there is no update to apply, or the execution was not produced by an executor of this package.
- Parameters:
targets (Any)
- Return type:
- class qibocal_widgets.Entry(id, parent, at, kind, changes, task=None, targets=None, source=None, paths=None)¶
Bases:
objectA change of the platform state.
- Parameters:
- class qibocal_widgets.Estimate(seconds, at, kind='execution')¶
Bases:
objectAn estimate of the acquisition duration, logged by qibolab or its driver.
- class qibocal_widgets.Executor(platform, *, runner=None, middleware=(), frontends=(), session=None, restore_platform=True, confirm=False, reuse=False, **kwargs)¶
Bases:
ExecutorQibocal executor composed of a runner, middleware, and frontends.
All the constructors of
qibocal.Executor(create,open, and the default one) are available, and accept the same additional keyword arguments.createandopenalso default the output path to a fresh folder of the session’s reports folder, if any (seereports_dir()).An executor with an output path records every execution in its
Sessionfolder, appending for as long as the instance lives, until a new session is started (new_session()). A new executor can continue an existing folder (attach()).- Parameters:
platform – as in
qibocal.Executor.runner (Runner | None) – where and how the steps run. Defaults to
Local.middleware (Iterable[Middleware]) – wrapping every step, the first being the outermost.
frontends (Iterable[Frontend]) – displaying every output.
session (Session | None) – the session recording the executions. Defaults to a new session in
path, if given, and to none otherwise.restore_platform (bool) – when given an existing session (see
Session.attach()), continue from the latest platform state recorded in its folder.**kwargs (Any) – forwarded to
qibocal.Executor.
- Raises:
TypeError – for objects given in the wrong role.
- confirm¶
Whether submitted executions wait for confirmation, by default.
- reuse¶
Whether submitted executions reuse identical ones, by default.
- history¶
compared, and restored (see
PlatformHistory).- Type:
The platform states of the session, as diffs
- classmethod create(path=None, targets=None, platform=None, **kwargs)¶
Create an executor writing its output to
path.- Parameters:
path (PathLike | None) – the output folder. If omitted, a fresh subfolder of the session’s reports folder (
QIBOCAMP_REPORTS_DIR) is used.targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None) – as in
qibocal.Executor.create().platform (Any) – as in
qibocal.Executor.create().**kwargs (Any) – as in the constructor.
- Raises:
TypeError – without
path, when no reports folder is set.- Return type:
- classmethod open(path=None, targets=None, force=False, platform=None, update=None, **kwargs)¶
Enter the execution context, as
qibocal.Executor.open().The output
pathdefaults as increate().- Parameters:
path (PathLike | None)
targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None)
force (bool)
platform (Any)
update (bool | None)
kwargs (Any)
- Return type:
- classmethod attach(path, targets=None, platform=None, *, restore_platform=True, **kwargs)¶
Create an executor appending to an existing session folder.
- Parameters:
path (PathLike) – the session folder.
targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None) – as in
create().platform (Any) – as in
create(). Defaults to the platform recorded in the session metadata.restore_platform (bool) – apply the latest platform state recorded in the folder, continuing the calibration where the session left it.
**kwargs (Any) – as in the constructor.
- Raises:
FileNotFoundError – if the folder holds no session.
- Return type:
- new_session(path=None)¶
Record the following executions in a new session folder.
- property platform_state: PlatformState¶
The calibration state of the platform, to explore and update by path.
It is the state the steps run on, as known by the runner: the local platform, or the state kept by a remote runner (asked to the remote machine, if not known yet). Updates are applied through the runner, and recorded in the session, as protocol updates are.
- note(content, completed=None, *, author=None)¶
Add a note to the session, or to one of its executions.
See
Session.note().- Raises:
ValueError – if the executor has no session.
- Parameters:
- submit(bound, skip_fit=False, *, reuse=None, confirm=None, **kwargs)¶
Execute a protocol in the background, as
executor(bound).Returns immediately, leaving the notebook free while the execution runs: get its result with
pending.result(),await pending, or peek at it withpending(). In Marimo notebooks, the pending execution is reactive state: cells referencing it run again when it completes.With a remote runner, acquisitions are independent jobs, queued together; with the local runner, they wait for each other, sharing the instruments. The execution manages the platform connection itself: no
with executor:is needed.Executions are recorded, fitted, reported, and update the platform in the order they start (submission, or confirmation), whatever the order their acquisitions complete in. An acquisition uses the platform state at the time it starts: acquisitions submitted together do not see each other’s updates.
- Parameters:
bound (BoundProtocol) – the protocol to execute.
skip_fit (bool) – as in
executor(bound).reuse (bool | None) – return an identical execution instead of acquiring again, if any: one still running, or one recorded in the session (loaded from disk; only for protocols registered in
qibocal.protocols, which Qibocal can load back). Executions are identical with the same protocol, parameters, overrides, and targets, whatever the platform state: updates of other executions do not cause acquiring again. Useful where cells may run again unintentionally, as in reactive notebooks; submit without it to acquire again. Defaults to the executor’s.confirm (bool | None) – wait for confirmation before starting: the execution is
ready, displayed as a Run button, until clicked, orpending.start(). Only where a frontend can show it (e.g. in notebooks); elsewhere, it starts at once. Reused executions need no confirmation. Defaults to the executor’s.**kwargs (Any) – execution overrides, as in
executor(bound).
- Return type:
- close()¶
Close execution.
- acquire(bound, **kwargs)¶
Execute only the acquisition phase.
- fit(completed, *, targets=None)¶
Execute the fit phase on existing data.
This can be used to re-fit data that was previously acquired, or to apply a different fitting strategy.
- Parameters:
completed (Completed) – An acquired execution, optionally loaded from disk.
targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None) – Optional override of the targets recorded at acquisition.
- Returns:
A new Completed instance with fitting results attached.
- Raises:
ValueError – If the protocol does not have a fit function.
- Return type:
- report(completed, *, targets=None)¶
Execute the report phase.
- Parameters:
completed (Completed) – An acquired or fitted execution.
targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None) – Optional override of the targets recorded at acquisition.
- Returns:
A new Completed instance with report output attached.
- Raises:
ValueError – If the protocol does not have a report function.
- Return type:
- update(completed, *, targets=None)¶
Execute the update phase to apply results to platform.
- Parameters:
completed (Completed) – A fitted execution.
targets (list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[Annotated[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None) – Optional override of the targets recorded at acquisition.
- Returns:
A new Completed instance after applying the platform update.
- Raises:
ValueError – If the protocol has no update function or no platform is configured.
- Return type:
- class qibocal_widgets.Frontend¶
Bases:
objectBase frontend.
Subclasses set
protocoland implementrender().- render(completed)¶
Displayable object for an execution.
- Parameters:
completed (Completed)
- Return type:
- attach(completed, executor=None)¶
A copy of the execution, displayed by this frontend.
- background()¶
The pending type and thread type of background executions.
For frontends needing them integrated with their runtime (e.g. Marimo’s reactive state and threads);
Nonekeeps the defaults. The first frontend providing them is used.- Return type:
tuple[type[Pending], type[threading.Thread]] | None
- confirmable()¶
Whether executions can be confirmed here, e.g. with a button.
Executions submitted with
confirmonly wait for confirmation if a frontend can show it; elsewhere (e.g. in scripts) they start at once.- Return type:
- submitted(pending)¶
Called with every execution returned by
Executor.submit.In the context of the call, e.g. the notebook cell: the execution may be new, or reused, possibly already completed. Frontends following the executions where they are displayed override it.
- Parameters:
pending (Pending)
- Return type:
None
- class qibocal_widgets.Local¶
Bases:
qibocal_widgets.runner.RunnerRun every step in the current process (the default runner).
- class qibocal_widgets.Middleware¶
Bases:
objectBase middleware: every hook passes through unchanged.
Subclasses override only the hooks they need.
- open(executor, call_next, *args, **kwargs)¶
Around the initialization of the execution context.
- Parameters:
executor (Executor)
call_next (Next)
args (Any)
kwargs (Any)
- close(executor, call_next, *args, **kwargs)¶
Around the finalization of the execution context.
- Parameters:
executor (Executor)
call_next (Next)
args (Any)
kwargs (Any)
- acquire(executor, call_next, *args, **kwargs)¶
Around the acquisition.
- fit(executor, call_next, *args, **kwargs)¶
Around the fit.
- report(executor, call_next, *args, **kwargs)¶
Around the report.
- update(executor, call_next, *args, **kwargs)¶
Around the update.
- exception qibocal_widgets.NotStartedError¶
Bases:
RuntimeErrorAn execution waiting for confirmation was waited for.
- class qibocal_widgets.Pending(bound)¶
Bases:
objectAn execution running in the background, returned by
Executor.submit.Get its result synchronously, blocking until it is available:
completed = pending.result()
asynchronously, where top-level
awaitis available:completed = await pending
or peek at it, without blocking:
pending()is the result, orNonewhile running (and raises if the execution failed).Submitted with
confirm, it isreadyand waits for confirmation before starting: its Run button, orstart(). Once completed, it can run again, with its Run again button, orrerun().Displayed, it shows its state; frontends may update the display when the execution completes. Frontends may also provide a subclass (see
Frontend.background), e.g. reactive in Marimo.- Parameters:
bound (BoundProtocol)
- bound¶
The protocol being executed.
- submitted_at¶
When the execution was submitted (UTC).
- views: dict[str, Callable[[Completed], Any]]¶
Views registered by frontends, keyed by display protocol.
- estimates: list[Estimate]¶
each one refines the previous ones, and restarts the progress bar.
- Type:
Duration estimates received while acquiring, in order
- start()¶
Start an execution waiting for confirmation (
ready).As its Run button does; nothing happens if already started.
- Return type:
None
- update(targets=None)¶
Apply the platform update of the completed execution, as
Completed.update.- Raises:
ValueError – if not completed successfully.
- Parameters:
targets (Any)
- Return type:
- rerun()¶
Run a completed execution again, as its Run again button does.
The same handle follows the new execution:
pending()isNoneagain until it completes,result()waits for it. It ignores reuse: the protocol is acquired again, and recorded anew in the session. Nothing happens while running, or waiting for confirmation.- Return type:
None
- on_change(callback)¶
Call
callback(pending)on every change of state, from any thread.Changes of state include new estimates. Returns a function removing the callback.
- result(timeout=None)¶
The completed execution, waiting for it if needed.
- Raises:
NotStartedError – if waiting for confirmation (waiting for it would block the confirmation itself).
TimeoutError – if not completed within
timeoutseconds.Exception – the error of the execution, if it failed.
- Parameters:
timeout (float | None)
- Return type:
- exception(timeout=None)¶
The error of the execution, if it failed.
- Parameters:
timeout (float | None)
- Return type:
BaseException | None
- property batches: int¶
Batches started in the current execution on the platform, as estimated by the driver: all but the last are done.
- progress()¶
A progress bar, as HTML, while acquiring with an estimate.
It fills in the latest estimated duration, from when the estimate was received, with a CSS animation: no further update is needed. The first estimate is shown for comparison, and the batches done, once the driver estimates them (their total is not known in advance).
- Return type:
str | None
- class qibocal_widgets.PlatformHistory(executor, records=None)¶
Bases:
objectThe platform states of a session, as
Executor.history.Entries are addressed by their
id, by negative index (-1is the latest), or by the folder name of the execution updating the platform (history["rabi-0"]). Restoring a state continues from it: the following entries fork from there.- classmethod load(executor)¶
The history recorded in the executor’s session folder, if any.
- Parameters:
executor (Executor)
- Return type:
- lineage(ref=-1)¶
The entries leading to one, from the start.
- state(ref=-1)¶
The platform state after an entry, as a read-only snapshot.
- Parameters:
- Return type:
- diff(a, b=None)¶
Leaves differing between two entries, as
(a, b)values.bdefaults to the current state, so thatdiff(a)is what changed sincea.
- applied(task)¶
Targets updated by an execution, from its folder name.
- explore(a=None, b=None)¶
An explorer comparing two entries, and restoring them.
Requires
anywidget(in thejupyterandmarimoextras).
- on_change(callback)¶
Call
callback(history)whenever an entry is recorded.- Parameters:
callback (Callable[[PlatformHistory], None])
- Return type:
None
- restore(ref, paths=None)¶
Restore the state after an entry, entirely or for some paths.
Restored entirely, the following entries continue from it, forking the history. Restoring some paths (leaves, or branches such as a whole qubit, in any form accepted by
PlatformState) sets their values as they were, on top of the current state.
- class qibocal_widgets.PlatformState(source, sink=None, *, name='state', saver=None)¶
Bases:
objectThe calibration state of a platform, addressed by path.
A state is either bound to a platform (reading its current state, and writing updates back), or a read-only snapshot. Use the constructors:
of()(a platform object),load()(a folder),snapshot(), orExecutor.platform_state.- Parameters:
source (Callable[[], platforms.State | None]) – returns the current state.
sink (Callable[[platforms.State], None] | None) – applies an updated state;
Nonefor read-only states.name (str) – how the state is referred to in code, in the snippets shown by the explorer.
saver (Callable[[platforms.State, bool], str] | None) – writes a state in the platform folder, given
overwrite, returning where (seesave());Noneif not known.
- classmethod of(platform, *, name='state')¶
The state of a platform object, bound to it.
- Parameters:
- Return type:
- classmethod load(path, *, name='state')¶
A snapshot of a state dumped in a folder.
- Parameters:
- Raises:
FileNotFoundError – if no state is found.
- Return type:
- save(path=None, *, overwrite=False)¶
Write the state as a platform folder:
parameters.jsonandcalibration.json, formatted as qibolab dumps them.- Parameters:
path (str | Path | None) – the folder; by default, the folder of the platform, e.g. in
QIBOLAB_PLATFORMS, on the remote machine for remote runners without a local platform.overwrite (bool) – replace existing files outside of a git working tree. In a git working tree, they are always replaced: git keeps the previous version, and the changes are reviewed and committed there (e.g. with Qibocamp).
- Returns:
The folder written, on the machine where it is.
- Raises:
ValueError – without a path, when the platform folder is not known.
FileExistsError – replacing files outside of a git working tree, without
overwrite.
- Return type:
- classmethod frozen(state, *, name='state')¶
A read-only snapshot of a state.
- Parameters:
- Return type:
- snapshot()¶
A read-only copy of the current state, e.g. to compare later.
- Return type:
- state()¶
The current state, as JSON strings.
- Raises:
LookupError – if the state is not known (e.g. no platform).
- Return type:
- get(path, default=None)¶
The value at a path, or a default.
- resolve(text)¶
The canonical path designated by some text, if any.
Accepted forms, so that paths can be pasted from anywhere:
a full path:
parameters.configs.0/drive.frequency;a path within a document, as copied from the Qibocamp dashboard (which shows one file at a time) or written for qibolab’s
Platform.update:configs.0/drive.frequency;any text quoting a path, as an API call or its output:
state["parameters.configs.0/drive.frequency"].
All methods taking a path accept the same forms.
- leaves(path='')¶
All the leaves under a path, by full path.
- find(query)¶
Leaves whose path contains some text (case insensitive).
- diff(other)¶
Leaves differing from another state, as
(other, self)values.Leaves missing on one side are reported as
Noneon that side.
- update(changes)¶
Set values by path, validating the whole state.
All changes are applied at once: if any of them is invalid, none is.
- Raises:
ReadOnlyState – for snapshots.
KeyError – for paths which do not exist (no new entries are created, so that typos are not silently accepted).
ValueError – if the updated state is not valid.
- Parameters:
- Return type:
None
- explore(path='', *, editable=False, compare=None)¶
An interactive explorer, for Jupyter and Marimo.
- Parameters:
path (str) – where to start; any text accepted by
resolve().compare (PlatformState | None) – highlight differences with another state (e.g. a snapshot taken earlier, or the start of a session).
Requires
anywidget(in thejupyterandmarimoextras).
- exception qibocal_widgets.ReadOnlyState¶
Bases:
RuntimeErrorThe state is a snapshot, not bound to any platform.
- class qibocal_widgets.Report(figures=<factory>, table='', extra=<factory>)¶
Bases:
objectNormalized report content for a single target.
- class qibocal_widgets.Runner¶
Bases:
objectBase runner: every step runs locally, as in
qibocal.Executor.- property concurrent: bool¶
Whether acquisitions may run at the same time (see
Executor.submit).Local acquisitions share the instruments, so they run one at a time.
- open(executor)¶
Enter the execution context: connect the platform.
The output folder is managed by the executor’s session, not by the runner.
- Parameters:
executor (Executor)
- Return type:
None
- close(executor)¶
Exit the execution context: disconnect the platform.
- Parameters:
executor (Executor)
- Return type:
None
- platform_name(executor)¶
Name of the platform the steps run on, if known.
- platform_state(executor)¶
Current calibration state of the platform the steps run on, if known.
- Parameters:
executor (Executor)
- Return type:
platforms.State | None
- set_platform_state(executor, state)¶
Apply a calibration state (e.g. attaching a session, or edited).
- Parameters:
executor (Executor)
state (platforms.State)
- Return type:
None
- save_platform(executor, state, overwrite=False)¶
Write a calibration state in the folder of the platform.
- Returns:
The folder written, on the machine of the platform.
- Raises:
ValueError – without a platform.
FileExistsError – see
platforms.export().
- Parameters:
- Return type:
- acquire(executor, bound, **kwargs)¶
Acquire data, as
qibocal.Executor.acquire().
- fit(executor, completed, **kwargs)¶
Fit data, as
qibocal.Executor.fit().
- report(executor, completed, **kwargs)¶
Report results, as
qibocal.Executor.report().
- class qibocal_widgets.Session(path, meta=None)¶
Bases:
objectThe folder recording the executions of an executor.
The folder is created when the session starts, i.e. at the first context entry or recorded execution, whichever comes first.
- Parameters:
path (str | Path) – the session folder.
meta (Metadata | None) – the session metadata. If omitted, it is generated from the executor when the session starts.
- path¶
The session folder.
- meta¶
Session metadata, written to
meta.json.
- started¶
Whether the folder exists and holds the session.
- classmethod attach(path)¶
Continue an existing session folder.
- Raises:
FileNotFoundError – if the folder holds no session (no
meta.json).- Parameters:
- Return type:
- start(executor, force=False)¶
Create the folder, unless already started.
- Parameters:
- Raises:
SessionExists – if the folder already exists and is not empty, and
forceis not set.- Return type:
None
- flush()¶
Register the latest activity, and write the metadata.
- Return type:
None
- platform_state()¶
The latest platform state recorded in the folder, if any.
- restore(executor)¶
Continue from the latest platform state recorded in the folder.
The state is handed to the executor’s runner: applied to the local platform, or kept by remote runners for their next jobs.
- Parameters:
executor (Executor)
- Return type:
None
- note(content, completed=None, *, author=None)¶
Add a note to the session, or to one of its executions.
Notes are appended to the
notes.jsonof the session folder, or of the execution folder, safely with respect to the report server, which may add notes concurrently.- Parameters:
- Raises:
ValueError – if the session has not started, or the execution is not recorded in it.
- Return type:
Note
- notes(completed=None)¶
Notes of the session, or of one of its executions.
- Parameters:
completed (Completed | None)
- Return type:
list[Note]
- contains(completed)¶
Whether an execution is already recorded in this session.
- Parameters:
completed (Completed)
- Return type:
- ensure(executor, completed)¶
Record an execution as a new task, unless already recorded.
- add(executor, completed)¶
Record an execution as a new task.
- tag(completed, key)¶
Record the reuse key of an execution (see
Executor.submit).- Parameters:
completed (Completed)
key (str)
- Return type:
None
- find(key)¶
The folder of the latest execution recorded with a reuse key, if any.
The latest is the last iteration of the task (
<id>-<n>), e.g. after running it again.
- results(completed)¶
Write the fit results of a recorded execution.
- Parameters:
completed (Completed)
- Return type:
None
- exception qibocal_widgets.SessionExists¶
Bases:
FileExistsErrorA new session would overwrite an existing folder.
- qibocal_widgets.convert(completed, completed_type=<class 'qibocal_widgets._core.completed.Completed'>)¶
Re-wrap an execution into another
qibocal.auto.task.Completedsubclass.The operation is idempotent: instances already of the requested type are returned unchanged. Lazily loaded attributes (data and results stored on disk) are copied as they are, without triggering any loading.
- Parameters:
completed (Completed)
completed_type (type[_CompletedT])
- Return type:
_CompletedT
- qibocal_widgets.data_frames(data)¶
Tabulate acquired data, one table per target.
- qibocal_widgets.reports(completed)¶
Normalized reports of an execution (empty if the report phase did not run).
- qibocal_widgets.reports_dir()¶
The session’s reports folder, if any.
Read from the
QIBOCAMP_REPORTS_DIRenvironment variable, set by Qibocamp for sessions with a reports folder (or by hand). Relative values are taken relative to the current working directory.- Returns:
The absolute folder, or
Nonewhen the variable is unset or empty.- Return type:
Path | None
- qibocal_widgets.reports_of(reports)¶
Normalize protocol reports into per-target
Reportobjects.Qibocal report callbacks accepting a
targetargument produce a mapping from target to(figures, table); callbacks without it produce a single object. Both shapes are accepted: the latter is stored under theNonekey.