From c8caec37e62ab50966911e29be160b09ad9e84fa Mon Sep 17 00:00:00 2001 From: CamDavidsonPilon Date: Fri, 29 Nov 2024 11:30:31 -0500 Subject: [PATCH] od blank shouldn't dodge: --- CHANGELOG.md | 9 +++-- pioreactor/actions/od_blank.py | 61 ++++++++++++++++-------------- pioreactor/background_jobs/base.py | 22 +++++------ 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa9b4dcf..de19df1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,14 @@ ### Upcoming #### Highlights - - new export dataset API. The datasets on the Export page are now provided via YAML files on the leader's disk. This makes it easy to add new datasets to that UI to be exported. These YAML files can be added to `~/.pioreactor/exportable_datasets`. - - new Export Data page in the UI. Preview datasets before you export them, and new partition options for the exported csvs. - - Plugins can now add datasets to the Export Data page. The plugin's datasets are automatically added to the Export Data page when installed. + - New export datasets improvements! + - new export dataset API. The datasets on the Export Data UI page are now provided via YAML files on the leader's disk. This makes it easy to add new datasets to that UI to be exported. These YAML files can be added to `~/.pioreactor/exportable_datasets`. + - new Export Data page in the UI. Preview datasets before you export them, and new partition options for the exported CSVs. + - Plugins can now add datasets to the Export Data page. The plugin's datasets are automatically added to the Export Data page when installed. + - Stirring can now pause itself during an OD reading. This is accomplished by "dodging OD readings". You can activate this feature by setting the `enable_dodging_od` to `True` in config.ini, under `[stirring.config]`. The replaces an older, less reliable plugin that was on our forums. Users have wanted this feature to have a very fast RPM between OD measurements (to get more aeration), and avoid noisy OD measurements. #### Enhancements + - improvements to Dodging background job code, including the ability to initialize the class based on dodging or not. - better error handling for failed OD blanks. - better button state management in the UI. - you can add addresses to the (new) `[cluster.addresses]` section to specify IPs for pioreactors. Example: diff --git a/pioreactor/actions/od_blank.py b/pioreactor/actions/od_blank.py index c86d3a70..b2bd7079 100644 --- a/pioreactor/actions/od_blank.py +++ b/pioreactor/actions/od_blank.py @@ -17,6 +17,7 @@ from pioreactor import types as pt from pioreactor import whoami from pioreactor.config import config +from pioreactor.config import temporary_config_change from pioreactor.logging import create_logger from pioreactor.pubsub import prune_retained_messages from pioreactor.utils import is_pio_job_running @@ -53,10 +54,11 @@ def od_statistics( from pioreactor.background_jobs.stirring import start_stirring logger.info("Starting stirring.") - st = start_stirring( - unit=unit, - experiment=experiment, - ) + with temporary_config_change(config, "stirring.config", "enable_dodging_od", "False"): + st = start_stirring( + unit=unit, + experiment=experiment, + ) st.block_until_rpm_is_close_to_target(timeout=40) # wait for stirring to be reasonable. else: st = nullcontext() # type: ignore @@ -160,32 +162,33 @@ def od_blank( with managed_lifecycle(unit, experiment, action_name): try: - with start_od_reading( - od_angle_channel1, - od_angle_channel2, - unit=unit, - interval=1.5, - experiment=testing_experiment, # use testing experiment to not pollute the database (and they would show up in the UI) - fake_data=whoami.is_testing_env(), - ) as od_stream, start_stirring( - unit=unit, - experiment=testing_experiment, - ) as st: - # warm up OD reader - for count, _ in enumerate(od_stream, start=0): - if count == 5: - break - - st.block_until_rpm_is_close_to_target(timeout=30) - - means, _ = od_statistics( - od_stream, - action_name, + with temporary_config_change(config, "stirring.config", "enable_dodging_od", "False"): + with start_od_reading( + od_angle_channel1, + od_angle_channel2, unit=unit, - experiment=experiment, - n_samples=n_samples, - logger=logger, - ) + interval=1.5, + experiment=testing_experiment, # use testing experiment to not pollute the database (and they would show up in the UI) + fake_data=whoami.is_testing_env(), + ) as od_stream, start_stirring( + unit=unit, + experiment=testing_experiment, + ) as st: + # warm up OD reader + for count, _ in enumerate(od_stream, start=0): + if count == 5: + break + + st.block_until_rpm_is_close_to_target(timeout=30) + + means, _ = od_statistics( + od_stream, + action_name, + unit=unit, + experiment=experiment, + n_samples=n_samples, + logger=logger, + ) except Exception as e: logger.debug(e, exc_info=True) logger.error(e) diff --git a/pioreactor/background_jobs/base.py b/pioreactor/background_jobs/base.py index af23d3b2..39ed5eac 100644 --- a/pioreactor/background_jobs/base.py +++ b/pioreactor/background_jobs/base.py @@ -1038,7 +1038,7 @@ def __init__(self, *args, source="app", **kwargs) -> None: def __post__init__(self): super().__post__init__() self.set_enable_dodging_od( - config.getboolean(f"{self.job_name}.config", "enable_dodging_od", fallback="True") + config.getboolean(f"{self.job_name}.config", "enable_dodging_od", fallback="False") ) self.start_passive_listeners() @@ -1066,17 +1066,15 @@ def set_currently_dodging_od(self, value: bool): def set_enable_dodging_od(self, value: bool): self.enable_dodging_od = value - if self.is_od_job_running() and self.enable_dodging_od: - self.logger.info("Will attempt to dodge OD readings.") - self.set_currently_dodging_od(True) - elif self.is_od_job_running() and not self.enable_dodging_od: - self.logger.info("Running continuously through OD readings.") - self.set_currently_dodging_od(False) - elif not self.is_od_job_running() and not self.enable_dodging_od: - self.logger.info("Running continuously through OD readings.") - self.set_currently_dodging_od(False) - elif not self.is_od_job_running() and self.enable_dodging_od: - self.logger.info("Will attempt to dodge later OD readings.") + if self.enable_dodging_od: + if self.is_od_job_running(): + self.logger.debug("Will attempt to dodge OD readings.") + self.set_currently_dodging_od(True) + else: + self.logger.debug("Will attempt to dodge later OD readings.") + self.set_currently_dodging_od(False) + else: + self.logger.debug("Running continuously through OD readings.") self.set_currently_dodging_od(False) def is_od_job_running(self) -> bool: