Remote¶
Remote execution.
The Remote runner dispatches the acquisition to the machine with
access to the instruments, according to a Connection:
from qibocal_widgets import Executor
from qibocal_widgets.marimo import Marimo
from qibocal_widgets.remote import Remote
remote = Remote("lab") # named connection, from the configuration file
remote.install() # once, or whenever the requirements change
executor = Executor(None, targets=[0, 1], runner=remote, frontends=[Marimo()])
executor(bound) # acquired remotely, fitted and reported locally
Connections are stored in remotes.json, in the configuration directory
shared with Qibocamp, and managed with save_connection(),
remove_connection(), and connections().
- class qibocal_widgets.remote.Connection(*, ssh=None, queue=None, slurm=None, workdir=None, venv='qibocal', python=None, requirements=None, rebuild_on_compute=False, platform=None, platforms_dir=None, timeout=None)¶
Bases:
BaseModelHow to reach the machine with access to the instruments.
The tier is determined by the options, not detected:
neither
sshnorqueue/slurm: the current process already runs where the instruments are, and nothing is dispatched;queueorslurm: every remote step is a blockingsrunjob, submitted from the current machine (the access node);ssh: the same, through SSH (from a laptop to the access node). Withoutqueue/slurm, steps run directly on the SSH destination.
- Parameters:
- model_config = {'extra': 'forbid', 'strict': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ssh: str | None¶
SSH arguments, ending with the destination (e.g.
"-J bastion me@login").Host aliases and jump hosts from
~/.ssh/configare honored.
- requirements: str | None¶
Environment requirements, in
requirements.txtformat.Qibocal is included by default, unless already named (e.g. to pin a branch). Further entries make external protocols available.
- exception qibocal_widgets.remote.IncompatibleConfig¶
Bases:
RuntimeErrorThe configuration file has an unsupported version.
- class qibocal_widgets.remote.Remote(connection=None, **options)¶
Bases:
qibocal_widgets.runner.RunnerExecute the steps needing the instruments on another machine.
Only the acquisition needs the instruments: it is dispatched according to the connection (see
Connection), while fit and report always run locally. The update runs locally when the executor has a platform, whose state is then sent along with every acquisition; otherwise it runs remotely, on the access node, and the runner keeps the resulting state.When the connection dispatches nothing (the process already runs where the instruments are), every step passes through unchanged, so the same notebook works on every tier.
- Parameters:
connection (str | Connection | None) – a named connection from the configuration file, or a
Connection. If omitted, the connection named by theQIBOCAL_WIDGETS_CONNECTIONenvironment variable is used, or none.**options (Any) –
Connectionfields, overriding the connection’s.
- connection¶
The effective connection.
- install(*, rebuild=False)¶
Prepare the remote environment, installing the requirements.
Separate from execution: steps never install anything, and fail if the environment is missing. Installation runs on the access node, unless
rebuild_on_computeis set.
- platform_name(executor)¶
Name of the platform the steps run on, if known.
- queue(*, partition=None, user=None, states=None, timeout=30.0)¶
The SLURM queue of the connection, asked once.
By default, the whole partition the acquisitions are submitted to, so that the jobs ahead are visible; the jobs of the remote user are flagged as
mine, those of this runner asours. The query and its fields are the ones of Qibocamp.
- monitor(*, interval=30.0, mine=False, **options)¶
A refreshable view of the queue, for Jupyter and Marimo.
- Parameters:
Requires
anywidget(in thejupyterandmarimoextras).
- describe(executor)¶
The calibration state of the remote platform, as found remotely.
Runs on the access node, outside of the queue: the platform is created, but not connected.
- platform_state(executor)¶
Current calibration state of the platform the steps run on, if known.
- set_platform_state(executor, state)¶
Apply a calibration state (e.g. attaching a session, or edited).
- save_platform(executor, state, overwrite=False)¶
Write a state in the platform folder: on the remote machine, without a local platform (in
platforms_dir, if configured), outside of the queue.
- 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
- acquire(executor, bound, **kwargs)¶
Acquire data, as
qibocal.Executor.acquire().
- exception qibocal_widgets.remote.RemoteError(message, details='')¶
Bases:
RuntimeErrorA remote step failed.
- TAIL = 20¶
Lines of details included in the message.
- details¶
Remote traceback, or standard error, when available.
- qibocal_widgets.remote.connections()¶
All the named connections in the configuration file.
- Return type:
- qibocal_widgets.remote.environment_name(name)¶
The environment a named connection uses, unless it names one.
Its name made safe for a folder, under
_remote/: distinct connections, and notebook sessions of the same name, do not share one unless it is named on purpose. The same rule as Qibocamp’s desktop application.
- qibocal_widgets.remote.load_connection(name)¶
A named connection from the configuration file.
- qibocal_widgets.remote.remove_connection(name)¶
Remove a named connection from the configuration file.
- Parameters:
name (str)
- Return type:
None
- qibocal_widgets.remote.save_connection(name, connection)¶
Add or replace a named connection in the configuration file.
- Parameters:
name (str)
connection (Connection)
- Return type:
None