Management system¶
The management system described below is optional: experiments can be run one by one using artiq_run
, and the controllers can run stand-alone (without a controller manager). For their very first steps with ARTIQ or in simple or particular cases, users do not need to deploy the management system.
Components¶
Master¶
The master is responsible for managing the parameter and device databases, the experiment repository, scheduling and running experiments, archiving results, and distributing real-time results.
The master is a headless component, and one or several clients (command-line or GUI) use the network to interact with it.
Controller manager¶
Controller managers are responsible for running and stopping controllers on a machine. There is one controller manager per network node that runs controllers.
A controller manager connects to the master and uses the device database to determine what controllers need to be run. Changes in the device database are tracked by the manager and controllers are started and stopped accordingly.
Controller managers use the local network address of the connection to the master to filter the device database and run only those controllers that are allocated to the current node. Hostname resolution is supported.
Warning
With some network setups, the current machine’s hostname without the domain name resolves to a localhost address (127.0.0.1 or even 127.0.1.1). If you wish to use controllers across a network, make sure that the hostname you provide resolves to an IP address visible on the network (e.g. try providing the full hostname including the domain name).
Command-line client¶
The command-line client connects to the master and permits modification and monitoring of the databases, monitoring the experiment schedule and log, and submitting experiments.
Dashboard¶
The dashboard connects to the master and is the main way of interacting with it. The main features of the dashboard are scheduling of experiments, setting of their arguments, examining the schedule, displaying real-time results, and debugging TTL and DDS channels in real time.
Experiment scheduling¶
Basics¶
To use hardware resources more efficiently, potentially compute-intensive pre-computation and analysis phases of other experiments is executed in parallel with the body of the current experiment that accesses the hardware.
Experiments are divided into three phases that are programmed by the user:
- The preparation stage, that pre-fetches and pre-computes any data that necessary to run the experiment. Users may implement this stage by overloading the
prepare
method. It is not permitted to access hardware in this stage, as doing so may conflict with other experiments using the same devices. - The running stage, that corresponds to the body of the experiment, and typically accesses hardware. Users must implement this stage and overload the
run
method. - The analysis stage, where raw results collected in the running stage are post-processed and may lead to updates of the parameter database. This stage may be implemented by overloading the
analyze
method.
Note
Only the run
method implementation is mandatory; if the experiment does not fit into the pipelined scheduling model, it can leave one or both of the other methods empty (which is the default).
The three phases of several experiments are then executed in a pipelined manner by the scheduler in the ARTIQ master: experiment A executes its preparation stage, then experiment A executes its running stage while experiment B executes its preparation stage, and so on.
Priorities and timed runs¶
When determining what experiment to begin executing next (i.e. entering the preparation stage), the scheduling looks at the following factors, by decreasing order of precedence:
- Experiments may be scheduled with a due date. If there is one and it is not reached yet, the experiment is not eligible for preparation.
- The integer priority value specified by the user.
- The due date itself. The earlier the due date, the earlier the experiment is scheduled.
- The run identifier (RID), an integer that is incremented at each experiment submission. This ensures that, all other things being equal, experiments are scheduled in the same order as they are submitted.
Pauses¶
In the run stage, an experiment may yield to the scheduler by calling the pause()
method of the scheduler.
If there are other experiments with higher priority (e.g. a high-priority timed experiment has reached its due date), they are preemptively executed, and then pause()
returns.
Otherwise, pause()
returns immediately.
To check whether pause()
would in fact not return immediately, use artiq.master.scheduler.Scheduler.check_pause()
.
The experiment must place the hardware in a safe state and disconnect from the core device (typically, by using self.core.comm.close()
) before calling pause
.
Accessing the pause
and check_pause
methods is done through a virtual device called scheduler
that is accessible to all experiments. The scheduler virtual device is requested like regular devices using get_device
or attr_device
.
check_pause
can be called (via RPC) from a kernel, but pause
must not.
Multiple pipelines¶
Multiple pipelines can operate in parallel inside the same master. It is the responsibility of the user to ensure that experiments scheduled in one pipeline will never conflict with those of another pipeline over resources (e.g. same devices).
Pipelines are identified by their name, and are automatically created (when an experiment is scheduled with a pipeline name that does not exist) and destroyed (when it runs empty).
Git integration¶
The master may use a Git repository for the storage of experiment source code. Using Git has many advantages. For example, each result file (HDF5) contains the commit ID corresponding to the exact source code that produced it, which helps reproducibility.
Even though the master also supports non-bare repositories, it is recommended to use a bare repository so that it can easily support push transactions from clients. Create it with e.g.:
$ mkdir experiments
$ cd experiments
$ git init --bare
You want Git to notify the master every time the repository is pushed to (updated), so that it is rescanned for experiments and e.g. the GUI controls and the experiment list are updated.
Create a file named post-receive
in the hooks
folder (this folder has been created by the git
command), containing the following:
#!/bin/sh
artiq_client scan-repository
Then set the execution permission on it:
$ chmod 755 hooks/post-receive
You may now run the master with the Git support enabled:
$ artiq_master -g -r /path_to/experiments
Push commits containing experiments to the bare repository using e.g. Git over SSH, and the new experiments should automatically appear in the dashboard.
Note
If you plan to run the ARTIQ system entirely on a single machine, you may also consider using a non-bare repository and the post-commit
hook to trigger repository scans every time you commit changes (locally). The ARTIQ master never uses the repository’s working directory, but only what is committed. More precisely, when scanning the repository, it fetches the last (atomically) completed commit at that time of repository scan and checks it out in a temporary folder. This commit ID is used by default when subsequently submitting experiments. There is one temporary folder by commit ID currently referenced in the system, so concurrently running experiments from different repository revisions is fully supported by the master.
The dashboard always runs experiments from the repository. The command-line client, by default, runs experiment from the raw filesystem (which is useful for iterating rapidly without creating many disorganized commits). If you want to use the repository instead, simply pass the -R
option.
Scheduler API reference¶
The scheduler is exposed to the experiments via a virtual device called scheduler
. It can be requested like any regular device, and then the methods below can be called on the returned object.
The scheduler virtual device also contains the attributes rid
, pipeline_name
, priority
and expid
that contain the corresponding information about the current run.
-
class
artiq.master.scheduler.
Scheduler
(ridc, worker_handlers, experiment_db)[source]¶ -
check_pause
(rid)[source]¶ Returns
True
if there is a condition that could makepause
not return immediately (termination requested or higher priority run).The typical purpose of this function is to check from a kernel whether returning control to the host and pausing would have an effect, in order to avoid the cost of switching kernels in the common case where
pause
does nothing.This function does not have side effects, and does not have to be followed by a call to
pause
.
-
Client control broadcasts (CCBs)¶
Client control broadcasts are requests made by experiments for clients to perform some action. Experiments do so by requesting the ccb
virtual device and calling its issue
method. The first argument of the issue method is the name of the broadcast, and any further positional and keyword arguments are passed to the broadcast.
CCBs are used by experiments to configure applets in the dashboard, for example for plotting purposes.
-
artiq.dashboard.applets_ccb.
AppletsCCBDock
¶ alias of
<Mock id='139630089918224'>
Front-end tool reference¶
ARTIQ master
usage: artiq_master [-h] [--bind BIND] [--no-localhost-bind]
[--port-notify PORT_NOTIFY] [--port-control PORT_CONTROL]
[--port-logging PORT_LOGGING]
[--port-broadcast PORT_BROADCAST] [--device-db DEVICE_DB]
[--dataset-db DATASET_DB] [-g] [-r REPOSITORY] [-v] [-q]
[--log-file LOG_FILE]
[--log-backup-count LOG_BACKUP_COUNT]
- Options:
--bind=[] additional hostname or IP address to bind to; use ‘*’ to bind to all interfaces (default: %(default)s) --no-localhost-bind=False do not implicitly also bind to localhost addresses --port-notify=3250 TCP port to listen on for notifications connections (default: 3250) --port-control=3251 TCP port to listen on for control connections (default: 3251) --port-logging=1066 TCP port to listen on for remote logging connections (default: 1066) --port-broadcast=1067 TCP port to listen on for broadcasts connections (default: 1067) --device-db=device_db.py device database file (default: ‘%(default)s’) --dataset-db=dataset_db.pyon dataset file (default: ‘%(default)s’) -g=False, --git=False use the Git repository backend -r=repository, --repository=repository path to the repository (default: ‘%(default)s’) -v=0, --verbose=0 increase logging level of the master process -q=0, --quiet=0 decrease logging level of the master process --log-file= store logs in rotated files; set the base filename --log-backup-count=0 number of old log files to keep, or 0 to keep all log files. ‘.<yyyy>-<mm>-<dd>’ is added to the base filename (default: %(default)d)
ARTIQ controller manager
usage: artiq_ctlmgr [-h] [-v] [-q] [-s SERVER] [--port-notify PORT_NOTIFY]
[--port-logging PORT_LOGGING]
[--retry-master RETRY_MASTER] [--bind BIND]
[--no-localhost-bind] [--port-control PORT_CONTROL]
- Options:
-v=0, --verbose=0 increase logging level of the manager process -q=0, --quiet=0 decrease logging level of the manager process -s=::1, --server=::1 hostname or IP of the master to connect to --port-notify=3250 TCP port to connect to for notifications --port-logging=1066 TCP port to connect to for logging --retry-master=5.0 retry timer for reconnecting to master --bind=[] additional hostname or IP address to bind to; use ‘*’ to bind to all interfaces (default: %(default)s) --no-localhost-bind=False do not implicitly also bind to localhost addresses --port-control=3249 TCP port to listen on for control connections (default: 3249)
ARTIQ CLI client
usage: artiq_client [-h] [-s SERVER] [--port PORT]
{submit,delete,set-dataset,del-dataset,show,scan-devices,scan-repository,ls}
...
- Options:
-s=::1, --server=::1 hostname or IP of the master to connect to --port TCP port to use to connect to the master - Sub-commands:
- submit
submit an experiment
usage: artiq_client submit [-h] [-p PIPELINE] [-P PRIORITY] [-t TIMED] [-f] [-R] [-r REVISION] [-c CLASS_NAME] [-v] [-q] FILE [ARGUMENTS [ARGUMENTS ...]]
- Positional arguments:
file file containing the experiment to run arguments run arguments - Options:
-p=main, --pipeline=main pipeline to run the experiment in (default: %(default)s) -P=0, --priority=0 priority (higher value means sooner scheduling, default: %(default)s) -t, --timed set a due date for the experiment -f=False, --flush=False flush the pipeline before preparing the experiment -R=False, --repository=False use the experiment repository -r, --revision use a specific repository revision (defaults to head, ignored without -R) -c, --class-name name of the class to run -v=0, --verbose=0 increase logging level of the experiment -q=0, --quiet=0 decrease logging level of the experiment
- delete
delete an experiment from the schedule
usage: artiq_client delete [-h] [-g] RID
- Positional arguments:
rid run identifier (RID) - Options:
-g=False request graceful termination
- set-dataset
add or modify a dataset
usage: artiq_client set-dataset [-h] [-p] [-n] NAME VALUE
- Positional arguments:
name name of the dataset value value in PYON format - Options:
-p=False, --persist=False make the dataset persistent -n=False, --no-persist=False make the dataset non-persistent
- del-dataset
delete a dataset
usage: artiq_client del-dataset [-h] name
- Positional arguments:
name name of the dataset
- show
show schedule, log, devices or datasets
usage: artiq_client show [-h] WHAT
- Positional arguments:
what select object to show: schedule/log/devices/datasets
- scan-devices
trigger a device database (re)scan
usage: artiq_client scan-devices [-h]
- scan-repository
trigger a repository (re)scan
usage: artiq_client scan-repository [-h] [--async] [REVISION]
- Positional arguments:
revision use a specific repository revision (defaults to head) - Options:
--async=False trigger scan and return immediately
- ls
list a directory on the master
usage: artiq_client ls [-h] [directory]
- Positional arguments:
directory Undocumented
ARTIQ Dashboard
usage: artiq_dashboard [-h] [-s SERVER] [--port-notify PORT_NOTIFY]
[--port-control PORT_CONTROL]
[--port-broadcast PORT_BROADCAST] [--db-file DB_FILE]
[-v] [-q]
- Options:
-s=::1, --server=::1 hostname or IP of the master to connect to --port-notify=3250 TCP port to connect to for notifications --port-control=3251 TCP port to connect to for control --port-broadcast=1067 TCP port to connect to for broadcasts --db-file=/var/lib/buildbot/.config/artiq/3/artiq_dashboard.pyon database file for local GUI settings (default: %(default)s) -v=0, --verbose=0 increase logging level -q=0, --quiet=0 decrease logging level
ARTIQ session manager. Automatically runs the master, dashboard and local controller manager on the current machine.
usage: artiq_session [-h] [-m M] [-d D] [-c C]
- Options:
-m=[] add argument to the master command line -d=[] add argument to the dashboard command line -c=[] add argument to the controller manager command line