Skip to content

Commit

Permalink
changes for 25.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Feb 12, 2025
1 parent cf3e35d commit 4022e52
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
6 changes: 3 additions & 3 deletions developer-guide/07-Plugins/03-plugin-as-python-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ setup(
#### 1. Your plugins Python files

This Python file contains the core code for your plugin. If your plugin is implementing a background job, then there should be a
function decorated with `@click.command` at the bottom of the file. See example [here](https://github.com/CamDavidsonPilon/pioreactor-relay-plugin/blob/e25b46997d6e6b3b1b2e2bf1141299ddba4eaa49/pioreactor_relay_plugin/relay.py#L79-L93). For discovery reasons, this function's name **should start with `click_`**.
function decorated with `@run.command` at the bottom of the file. See example [here](https://github.com/CamDavidsonPilon/pioreactor-relay-plugin/blob/e25b46997d6e6b3b1b2e2bf1141299ddba4eaa49/pioreactor_relay_plugin/relay.py#L79-L93).

#### 2. A Python `__init__.py` file

Expand All @@ -140,10 +140,10 @@ function decorated with `@click.command` at the bottom of the file. See example
Example for the relay plugin:

```python
from pioreactor_relay_plugin.relay import click_relay
from pioreactor_relay_plugin.relay import start_relay
```

where `click_relay` is the function decorated with `@click.command`.
where `start_relay` is the function decorated with `@run.command`.


#### 3. Optional: A configuration file, named `additional_config.ini`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The Pioreactor software will automatically backup the SQLite database via a sche

## Local key-value datastore

SQLite3 is also used by the library *diskcache*. This is essentially a fast key-value store on the Raspberry Pi. For Pioreactor, we use it to store "machine-specific" data, like calibration curves, locks on GPIOs, state of LEDs, jobs running, etc. Instead of one large file containing all these keys, we have split them into multiple locations based on category and level of persistence. The persistent databases are stored in `/home/pioreactor/.pioreactor/storage` and the temporary databases are in `/tmp`. You can access them from Python using `pioreactor.utils.local_persistant_storage` and `pioreactor.utils.local_intermittent_storage`, respectively.
SQLite3 is also used by the library *diskcache*. This is essentially a fast key-value store on the Raspberry Pi. For Pioreactor, we use it to store "machine-specific" data, like calibration curves, locks on GPIOs, state of LEDs, jobs running, etc. Instead of one large file containing all these keys, we have split them into multiple locations based on category and level of persistence. The persistent databases are stored in `/home/pioreactor/.pioreactor/storage` and the temporary databases are in `/tmp`. You can access them from Python using `pioreactor.utils.local_persistent_storage` and `pioreactor.utils.local_intermittent_storage`, respectively.

:::info
What are temporary and persistent? Something like GPIO locks or LED state are physically reset between cycles of the Raspberry Pi. So when the Pi power-cycles, the state is wiped, and by have the database in `/tmp`, the databases are wiped as well.
Expand Down
4 changes: 1 addition & 3 deletions developer-guide/20-User interface/01-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Both workers and leaders have this backend. However, workers only use expose the

The frontend is a React app, built with Material UI. The source code is at [pioreactorui_frontend](https://github.com/Pioreactor/pioreactorui_frontend). A lot of the "data" for the frontend comes from YAML files on the RPi's filesystem. For example, all the charts, activities, and automations are defined in their own YAML file in a `contrib` folder on the filesystem. This way, it's easy to add new data to the frontend without having to write new JS.

A lot of the live data


### DNS name resolution to `pioreactor.local`

Expand All @@ -41,7 +39,7 @@ To update on the UI on Pioreactor leader, use `pio update ui`. This also restart
To restart:

```
sudo systemctl restart lighttp && sudo systemctl restart huey
sudo systemctl restart lighttpd && sudo systemctl restart huey
```

### Logs
Expand Down
21 changes: 13 additions & 8 deletions developer-guide/25-Calibrations/01-Calibrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,20 @@ class PHCalibration(CalibrationBase, kw_only=True, tag="ph"):

# not required, but helpful
def voltage_to_ph(self, voltage: float) -> float:
return self.predict(voltage)
return self.y_to_x(voltage)

def ph_to_voltage(self, ph: float) -> float:
return self.ipredict(ph)
return self.x_to_y(ph)
```

The `predict` and `ipredict` functions are used to convert between the two variables. The `i` in `ipredict` stands for "inverse".



## Creating a new protocol for an existing device
## (Optional) Creating a new protocol for an existing device

If you want to add a custom script to create a calibration on the Pioreactor, you can do that by creating a new protocol.


Define a `CalibrationProtocol` subclass that will hold metadata for your protocol. It should have a `run` method that returns a calibration (a subclass of `CalibrationBase` - see above).

Expand All @@ -70,6 +73,7 @@ from pioreactor.utils.timing import current_utc_datetime
class BufferBasedPHProtocol(CalibrationProtocol):
target_device = "ph"
protocol_name = "buffer_based"
description = "Calibrate the pH sensor using buffer solutions"

def run(self, target_device: str) -> PHCalibration:
return run_ph_calibration()
Expand All @@ -94,7 +98,7 @@ def run_ph_calibration() -> PHCalibration:
```


### Adding it to the plugins folder
## Adding it to the plugins folder

You can add your code to the `~/.pioreactor/plugins` folder on the Pioreactor, it will auto-magically populate the CLI
and UI. To complete our pH example, add the following to a new Python file in the `~/.pioreactor/plugins` folder:
Expand All @@ -111,14 +115,15 @@ class PHCalibration(CalibrationBase, kw_only=True, tag="ph"):
y: str = "Voltage"

def voltage_to_ph(self, voltage: float) -> float:
return self.predict(voltage)
return self.y_to_x(voltage)

def ph_to_voltage(self, ph: float) -> float:
return self.ipredict(ph)
return self.x_to_y(ph)

class BufferBasedPHProtocol(CalibrationProtocol):
target_device = "ph"
protocol_name = "buffer_based"
description = "Calibrate the pH sensor using buffer solutions"

def run(self, target_device: str) -> PHCalibration:
return run_ph_calibration()
Expand All @@ -145,10 +150,10 @@ def run_ph_calibration() -> PHCalibration:

And run it with:
```
pio calibrations run --device ph --protocol-name buffer_based
pio calibrations run --device ph
```

### Tips
## Tips

- use the Python library `click` to create an interactive CLI for your calibration protocol.
- the pair `(device, calibration_name)` must be unique. The final directory structure looks like `~/.pioreactor/storage/calibrations/<device>/<calibration_name>.yaml`
Expand Down
2 changes: 1 addition & 1 deletion user-guide/01-getting-started/02-software-set-up.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ We recommend running a [self-test](/user-guide/running-self-test) on all Pioreac
#### My leader Pioreactor never flashes the blue LED
- First, confirm that when you press the HAT button, the blue LED does not show up. If it does, you're good to go.
- It's likely that the installation failed (due to a settings issue), or there is a problem with the SD card. Double check the settings that you used and try reinstalling the image.
- Are you using a microSD card with a size *larger* than 32GB? You may need to reformat it to FAT32. To do this, in the Raspberry Pi Imager, first select "Erase: format card as FAT32" under "Choose OS". Then proceed with writing the image.
- Are you using a microSD card with a size *larger* than 32GB or with exFAT format? You may need to reformat it to FAT32. To do this, in the Raspberry Pi Imager, first select "Erase: format card as FAT32" under "Choose OS". Then proceed with writing the image.


#### My Pioreactor keeps flashing the blue LED
Expand Down
15 changes: 8 additions & 7 deletions user-guide/03-Extending your Pioreactor/05-calibrate-od600.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ import * as colors from '@site/src/components/constants';

## Calibrating your OD600 readings

Depending on the purposes of your research, you may want to calibrate your Pioreactor against known samples and OD600 values. We've given you the option to do this through the command line, similar to how pump calibrations currently work. _Calibrations using the UI are coming soon!_
Depending on the purposes of your research, you may want to calibrate your Pioreactor against known samples and OD600 values. We've given you the option to do this through the command line, similar to how pump and stirring calibrations currently work.

OD600 calibrations are straightforward, and only require one vial, your sample of interest, and an accurate way to measure liquids. We recommend a micropipette of volume range 100 to 1000 uL.
There are two protocols to create an OD calibration.

The first requires only require one vial, your sample of interest, and an accurate way to measure liquids (we recommend a micropipette of volume range 100 to 1000 uL). The protocol works by reading a dilution series. You will start with 10mL of your sample of interest cultivated in your media, at the highest density you expect to observe. During the calibration, you will specify and add an amount of your media to dilute your sample. To avoid overflowing, the program will prompt you to reduce the volume in your vial to 10mL at set intervals. Depending on your number of measurements, you may be prompted to reduce your vial volume to 10 mL. _OPTIONAL_: At this point, you may take the OD600 reading of your vial on a different instrument and input this OD600 value for the current measurement.



The second requires multiple vials that will work as standards. This option is quicker for calibrating multiple Pioreactors, too.

The calibration works by reading a dilution series. You will start with 10mL of your sample of interest cultivated in your media, at the highest density you expect to observe. During the calibration, you will specify and add an amount of your media to dilute your sample. To avoid overflowing, the program will prompt you to reduce the volume in your vial to 10mL at set intervals.

Calibrations should be specific to your experiment setup. Any changes to your media, culture, or optical setup (i.e. changing IR intensity, replacing pieces, or changing the angle) may require a new calibration. If everything remains consistent, then we recommend running calibrations every 6 months, or whatever suits your purposes.

Expand All @@ -39,9 +44,6 @@ Following the questions, stirring and optical density reading will begin. A grap

![Graph generated as you measure.](/img/user-guide/generating_graph.png)

Depending on your number of measurements, you may be prompted to reduce your vial volume to 10 mL. _OPTIONAL_: At this point, you may take the OD600 reading of your vial on a different instrument and input this OD600 value for the current measurement.

![Input an external OD600 value.](/img/user-guide/add_new_od600.png)

Once you complete all your measurements, a calibration curve will appear over your graph. If you are satisfied with this, save your calibration.

Expand Down Expand Up @@ -74,6 +76,5 @@ pio calibrations analyze --device od --name <name of your calibration>
## Sharing calibrations

Since the calibrations are just YAML files, you can easily share existing calibrations to other Pioreactors.
```


7 changes: 2 additions & 5 deletions user-guide/99-common-questions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ The button can be [reprogrammed](/developer-guide/hat-button), too.

### How do I change the date or time on the Pioreactor?

[SSH](/user-guide/accessing-raspberry-pi) into your Pioreactor, and run:
```
sudo date --set "2023-11-02 09:46:50"
Under _Inventory_ -> _Leader_, there is a card titled _Cluster clocks_. You can change the date and time there.

```


## Optical density and LEDs
Expand Down Expand Up @@ -183,7 +180,7 @@ _Note that the official Raspberry Pi microSD card (32 GB) is now included in all

### What power supply unit (PSU) do I need?

If you look at the power rating, it should be about 5 V and at least 2.25 A, or above 12 W. We really like the [official Raspberry Pi PSUs](https://www.raspberrypi.com/products/#power-supplies-and-cables), available at most places you can purchase Raspberry Pis.
If you look at the power rating, it should be about 5 V and at least 2.25 A, or above 12 W. We really like the [official Raspberry Pi PSUs](https://www.raspberrypi.com/products/power-supply/), available at most places you can purchase Raspberry Pis, Amazon, etc.

If you need to power multiple Pioreactors, you might consider a single PSU with USB ports [detailed here](/user-guide/powering-cluster).

Expand Down

0 comments on commit 4022e52

Please sign in to comment.