Skip to content

Commit

Permalink
od blank shouldn't dodge:
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Nov 29, 2024
1 parent 04aec3c commit c8caec3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
61 changes: 32 additions & 29 deletions pioreactor/actions/od_blank.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 10 additions & 12 deletions pioreactor/background_jobs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c8caec3

Please sign in to comment.