The service.chibio-relay
is the service layer for interacting with a Chi.Bio system through an API exposed by its HTTP server.
Note that this currently only works with a fork of the Chi.Bio software. This fork can be found at https://github.com/jace-ys/ChiBio/tree/develop.
python 3.9
poetry 1.0
This service should run on the same host as the Chi.Bio server, as it requires access to the local file system.
-
Install dependencies:
poetry install
-
Start auxiliary containers:
make dependencies
-
Export the following environment variables to the current shell:
export REDIS_CACHE_URL=<the URL for connecting to the db.redis service> export REDIS_PUBSUB_URL=<the URL for connecting to the pubsub.redis service> export MANAGER_CHIBIO_SERVER_URL=<base URL for the Chi.Bio server> export MANAGER_DEVICE_NAME=<a unique name for the current device> export FORWARDER_DATA_DIR=<the relative path to the Chi.Bio server's data directory> export FORWARDER_DATA_GATEWAY_URL=<the base URL for the service.data-gateway>
Other environment variables that can be configured can be found in
src/config/config.py
. -
Run the server:
make
Upon receiving a protocol trigger, the service.chibio-relay
forwards the parameters in the protocol's spec
via a POST request to the /sysData
endpoint. This configures the settings for an experiment for the specified device position on the Chi.Bio (M0
-M8
). The updated parameters should be visible in the Chi.Bio UI and terminal.
The service.chibio-relay
also creates an experiment to be executed via the /Experiment/{device}
endpoint - you should see an experiment ID in the top left corner of the Chi.Bio UI. A user is still required to start and stop the experiment manually via the UI as this ensures that the Chi.Bio doesn't start running until a user is present to supervise it, which otherwise might pose some safety risks.
Additionally, the service.chibio-relay
uses this experiment ID to keep track of the corresponding CSV data file generated by the Chi.Bio server. It watches for this file, periodically parses it, and forwards any new data to the service.data-gateway
. This allows for real-time streaming of experimental data while an experiment is running on the Chi.Bio.
The ChiBio/v1alpha1
API currently only supports one protocol named Bioreactor
. The spec
for this protocol is detailed below:
devicePosition (string)
: device position from M0 to M8deviceName (string)
: name of device (eg. Hydrogen, Lithium)od (float)
: target value to use for OD regulationvolume (float)
: volume in mlthermostat (float)
: target value for thermostatfp1Excite (string)
: value for the FP 1 Excite settingfp1Gain (string)
: value for the FP 1 Gain setting
Not all these parameters are required. Set the ones you need as how you would typically use the Chi.Bio UI.
Examples of protocol triggers for the service.chibio-relay
can be found under protocols/examples/chibio-relay
.
The service.chibio-relay
forwards data produced by the Chi.Bio to the service.data-gateway
in the following format:
{
"timeElapsed": "time elapsed",
"error": "error",
"odMeasured": "OD measured",
"odSetpoint": "OD setpoint",
...
}
The full list of exported data parameters is reflected in src/forwarder/payload.py
.
To add new parameters to the Bioreactor
protocol spec, you will need to modify the code in src/system/manager.py
. You should also have a look at the source code for the ChiBio server to see how the sysData
object can be configured.