Pump not running in custom dosing automation

Hi, I’m currently looking into custom dosing automations and profiles. I made a fed-batch dosing automation which tries to keep a constant growth rate. This dosing automation is then used in an experiment profile, where the automation is activated once the growth rate is dropping below its setpoint (i.e. the substrate in the starting medium is consumed).

When testing this workflow, I came along some hurdles, specifically when the experiment profile starts the dosing automation:

  1. The dosing automation is able to start after I rebooted the pioreactor, or when the previous run was ended correctly (i.e. no error/warning). Otherwise, I get a warning “dosing_automation is already running (job_id=9). Skipping.” Is there a way for the profile to initialize such that the dosing automation is always able to start and never give this warning?
  2. After the dosing automation ran for some period of time, I get the errors “unable to open and create temporary_cache database at /run/pioreactor/cache/local_intermittent_pioreactor_metadata.sqlite” & “unable to open database file”. Is there a way to solve this?

Here’s the code of my dosing automation plugin:

from pioreactor.automations.dosing.base import DosingAutomationJobContrib

class MusetFedbatch(DosingAutomationJobContrib):
automation_name = "muset_fedbatch"
    published_settings = {
        "dosing_volume": {"datatype": "float", "settable": True, "unit": "mL"},
        "target_mu": {"datatype": "float", "settable": True, "unit": "1/h"}
    }

    def __init__(self, dosing_volume, target_mu, **kwargs):
        super().__init__(**kwargs)
        self.logger.warning(
            "When using the fed-batch automation, no liquid is removed. Carefully monitor the level of liquid to avoid overflow!"
        )
        self.dosing_volume = float(dosing_volume)
        self.target_mu = float(target_mu)

    def execute(self):
        if self.latest_growth_rate < self.target_mu:
            vol = self.add_media_to_bioreactor(
                ml=self.dosing_volume,
                source_of_event=f"{self.job_name}:{self.automation_name}",
                unit=self.unit,
                experiment=self.experiment,
            )
            if vol != self.dosing_volume:
                self.logger.warning("Under-dosed!")

Here’s the experiment profile I made:

experiment_profile_name: Start fedbatch after batch

metadata:
  author: Stijn 
  description: Custom fed-batch operation for all assigned pioreactors. Fed-batch operation starts after the initial glucose is consumed (decreasing growth rate), maintaining constant stirring and temperature, with a specified growth rate of 0.1 h⁻¹ (0.01 mL every 0.1 minutes).

common:
  jobs:
    stirring:
      actions:
        - type: start
          t: 0.0
          options:
            target_rpm: 500.0
    temperature_automation:
      actions:
        - type: start
          t: 0.0
          options:
            automation_name: thermostat
            target_temperature: 30.0
    od_reading:
      actions:
        - type: start
          t: 0.0
    growth_rate_calculating:
      actions:
        - type: start
          t: 0.0

    dosing_automation:
      actions:
        - type: when
          t: 0.1 # start after 1h, for safety reasons
          wait_until: ${{::growth_rate_calculating:growth_rate.growth_rate > 0.1}}
          actions:
            - type: start
              t: 0.0
              options:
                automation_name: muset_fedbatch
                target_mu: 0.1 # 1/h
                dosing_volume: 0.01 # mL
                duration: 0.1 # min, time between checks

I think this was caused by a bug in the recent “Assign Pioreactors” page. For now, stop all jobs before unassigning from an experiment (this will be automatic again in >= 26.3.3)

  1. After the dosing automation ran for some period of time, I get the errors “unable to open and create temporary_cache database at /run/pioreactor/cache/local_intermittent_pioreactor_metadata.sqlite” & “unable to open database file”. Is there a way to solve this?

I’m try to repro this now. Unfortunately I can’t give much suggestions yet. Do you see it on all units? After how long approximately?

actually I could repro this. Investigating now

This change should be enough

    def execute(self):
        if self.latest_growth_rate < self.target_mu:
            vol = self.add_media_to_bioreactor(
                ml=self.dosing_volume,
                source_of_event=f"{self.job_name}:{self.automation_name}",
                unit=self.unit,
                experiment=self.experiment,
-            )
+               mqtt_client=self.pub_client,
+               logger=self.logger,
+            )

Thanks! Updating to 26.3.3 solved the problem.