Skip to content

Commit

Permalink
fix this mutable class var
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jan 16, 2025
1 parent 7522a2c commit 22b0e00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pioreactor/background_jobs/od_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,10 @@ def pop_reference_reading(self, batched_readings: PdChannelToVoltage) -> pt.Volt

class CalibrationTransformer(LoggerMixin):
_logger_name = "calibration_transformer"
models: dict[pt.PdChannel, Callable] = {}

def __init__(self) -> None:
super().__init__()
self.models: dict[pt.PdChannel, Callable] = {}

def __call__(self, batched_readings: PdChannelToVoltage) -> PdChannelToVoltage:
return batched_readings
Expand All @@ -629,6 +629,7 @@ def __call__(self, batched_readings: PdChannelToVoltage) -> PdChannelToVoltage:
class NullCalibrationTransformer(CalibrationTransformer):
def __init__(self) -> None:
super().__init__()
self.models: dict[pt.PdChannel, Callable] = {}

def hydate_models(self, calibration_data: structs.ODCalibration | None) -> None:
return
Expand All @@ -637,6 +638,7 @@ def hydate_models(self, calibration_data: structs.ODCalibration | None) -> None:
class CachedCalibrationTransformer(CalibrationTransformer):
def __init__(self) -> None:
super().__init__()
self.models: dict[pt.PdChannel, Callable] = {}
self.has_logged_warning = False

def hydate_models(self, calibration_data: structs.ODCalibration | None) -> None:
Expand Down
1 change: 1 addition & 0 deletions pioreactor/tests/test_od_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ def test_calibration_not_present() -> None:
c.pop("od")

cal = load_active_calibration("od")
assert cal is None

with start_od_reading("90", "REF", interval=None, fake_data=True, calibration=cal) as od:
assert isinstance(od.calibration_transformer, NullCalibrationTransformer)
Expand Down

0 comments on commit 22b0e00

Please sign in to comment.