Skip to content

Commit

Permalink
some more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Sep 6, 2023
1 parent 2f679d8 commit cbe868b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 39 deletions.
15 changes: 14 additions & 1 deletion pioreactor/automations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

from typing import Optional

from pioreactor.automations import events
from pioreactor.background_jobs.subjobs import BackgroundSubJob


DISALLOWED_AUTOMATION_NAMES = {
"config",
}
Expand All @@ -11,7 +15,7 @@
class BaseAutomationJob(BackgroundSubJob):
automation_name = "base_automation_job"

def __init__(self, unit: str, experiment: str):
def __init__(self, unit: str, experiment: str) -> None:
super(BaseAutomationJob, self).__init__(unit, experiment)

if self.automation_name in DISALLOWED_AUTOMATION_NAMES:
Expand All @@ -24,3 +28,12 @@ def __init__(self, unit: str, experiment: str):
"settable": False,
},
)

def on_init_to_ready(self) -> None:
self.start_passive_listeners()

def execute(self) -> Optional[events.AutomationEvent]:
"""
Overwrite in subclass
"""
raise NotImplementedError("Overwrite in base class")
15 changes: 0 additions & 15 deletions pioreactor/automations/dosing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,8 @@ def __init__(
self._init_volume_throughput()
self._init_vial_volume(float(initial_vial_volume))

self.add_to_published_settings(
"latest_event",
{
"datatype": "AutomationEvent",
"settable": False,
},
)

self.set_duration(duration)

def on_init_to_ready(self):
self.start_passive_listeners()

def set_duration(self, duration: Optional[float]) -> None:
if duration:
self.duration = float(duration)
Expand Down Expand Up @@ -340,10 +329,6 @@ def run(self, timeout: float = 60.0) -> Optional[events.AutomationEvent]:
self._latest_run_at = current_utc_datetime()
return event

def execute(self) -> Optional[events.AutomationEvent]:
# should be defined in subclass
return events.NoEvent()

def block_until_not_sleeping(self) -> bool:
while self.state == self.SLEEPING:
brief_pause()
Expand Down
6 changes: 0 additions & 6 deletions pioreactor/automations/led/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ def __init__(

self.set_duration(duration)

def on_init_to_ready(self):
self.start_passive_listeners()

def set_duration(self, duration: float) -> None:
self.duration = float(duration)
if self._latest_run_at is not None:
Expand Down Expand Up @@ -159,9 +156,6 @@ def run(self, timeout: float = 60.0) -> Optional[events.AutomationEvent]:
self._latest_run_at = current_utc_datetime()
return event

def execute(self) -> Optional[events.AutomationEvent]:
pass

@property
def most_stale_time(self) -> datetime:
return min(self.latest_normalized_od_at, self.latest_growth_rate_at)
Expand Down
17 changes: 0 additions & 17 deletions pioreactor/automations/temperature/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,8 @@ def __init__(
self.latest_temperture_at: datetime = current_utc_datetime()
self._latest_settings_started_at = current_utc_datetime()

self.add_to_published_settings(
"latest_event",
{
"datatype": "AutomationEvent",
"settable": False,
},
)

self.temperature_control_parent = temperature_control_parent

def on_init_to_ready(self):
self.start_passive_listeners()

def update_heater(self, new_duty_cycle: float) -> bool:
"""
Update heater's duty cycle. This function checks for a lock on the PWM, and will not
Expand Down Expand Up @@ -116,12 +105,6 @@ def update_heater_with_delta(self, delta_duty_cycle: float) -> bool:
"""
return self.temperature_control_parent.update_heater_with_delta(delta_duty_cycle)

def execute(self):
"""
Overwrite in base class
"""
raise NotImplementedError

@property
def most_stale_time(self) -> datetime:
return min(self.latest_normalized_od_at, self.latest_growth_rate_at)
Expand Down

0 comments on commit cbe868b

Please sign in to comment.