Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Using the experiment queue

We recommend using the queue for long-running experiments that require no interaction.

The queue works like a compute cluster: you submit an experiment protocol, the chamber runs it when ready, and it uploads the data to a server for you to download.

You will need API credentials to use the experiment queue. To get your credentials, please use the sign-up form.

Basic workflow

The API is very similar to that of the interactive experiments. You can find a complete example below.

1

Log in to the Remote Lab

First, log in to the Remote Lab (see also Quickstart)

from causalchamber import lab

rlab = lab.login(credentials_file = 'path/to/file')

If you stored your credentials in the environment variables CAUSALCHAMBER_USER and CAUSALCHAMBER_PASSWORD

from causalchamber import lab

rlab = lab.login()
2

Create a new experiment protocol

Then, start a new protocol by specifying which chamber (chamber_id) and hardware configuration (config) you want it to run on

experiment = rlab.new_experiment(chamber_id, config)

You can find your available Chambers (and their IDs) in the dashboard printed by the call to rlab.login(...) in step 1, or by calling rlab.dashboard().

3

Add instructions

Add instructions to the experiment protocol to manipulate the Chamber hardware and collect data from its sensors. There are three instruction types:

experiment.set(target, value)

This sets the variable target to the given value, returning when the hardware has made the change. The above call returns None.

Target variables can be physical quantities, such as a polarizer's position, or parameters that control a sensor behavior. See the Chambers documentation for a description of each Chamber and its variables.

experiment.measure(n, delay)

The Chamber takes n successive measurements of all variables, including images if it produces them. Setting delay (in milliseconds) adds an additional delay before each measurement, allowing you to change the measurement frequency.

experiment.wait(milliseconds)

The chamber acts as a precise clock and waits the given milliseconds before executing the next instruction.

This is useful, for example, if you want to wait for the system to reach equilibrium before measuring after a SET instruction.

You can check which instructions are already in the protocol by calling experiment.instructions. Calling experiment.clear() will remove all instructions.

You can also generate instructions directly from a pandas dataframe (see below).

4

Submit your experiment

Once you are ready, submit the experiment to the Chamber's queue with

experiment.submit(tag='optional-tag')

This will return a experiment_id that uniquely identifies your experiment in the system.

To help you keep track of your experiments, you can also add an optional tag parameter with a string of your choice (alphanumeric characters and +-_:).

How much will an experiment cost?

The cost of an experiment is determined by its total runtime (see How credits work). Before submitting, you can check how many credits an experiment will cost by calling

experiment.cost()

This returns the maximum amount of credits that will be deducted from your wallet. If the experiment runs faster, we will refund the difference. If you cancel an experiment before it's finished, you will be refunded the credits for the remaining runtime.

Monitoring your experiments

You can check on all your current and past experiments with

rlab.get_experiments()

This returns a list of your experiments and displays an overview:

You can also query the details (incl. status) for an individual experiment with

Checking your position in the queue

You can monitor the running and queued experiments for a given Chamber by calling

This displays the Chamber's queue, as well as its available hardware configurations and their documentation.

Cancelling an experiment

You can cancel a queued or running experiment by calling

For running experiments, the experiment will temporarily transition to status stopping while the chamber finishes executing the current instruction. This may take a moment if that happens to be a long measure or wait instruction.

If you cancel an experiment before it's finished, you will be refunded the credits for the remaining runtime. Canceling an experiment while it's still queued triggers a full refund.

Downloading the data

Once an experiment is finished (status=done), you can download the data by calling

where root specifies the directory where you want to store the data. Then, load the data into the desired format

A complete example

Let's submit an experiment to visualize the effect of Malus' law of polarization in the Light Tunnel Mk2. You can learn more about this effect in Appendix IV.2.1 of the original paper.

For our experiment, we will keep the light source fixed at a constant brightness and take measurements for random polarizer positions.

You can monitor the experiment with rlab.get_experiments() or rlab.dashboard()and load the measurements into a pandas dataframe once it's done.

Now we can plot the light intensity after both polarizers vs. their relative angle (see ir_3, pol_1, pol_2 in the configuration docs). For comparison, we show the prediction from Malus' law in red.

Generating instructions from a pandas dataframe

To make things easier when creating experiments, you can also generate instructions from a pandas dataframe by calling experiment.from_df(...) . For example, the above experiment can be rewritten as

You can use the help function to find more details about how the function works, e.g., to customize the number of measurements per row, by calling

Last updated