diff --git a/CHANGELOG.md b/CHANGELOG.md index db9362e4..9d904f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ - API to set clock time - new calibrations CLI - persistent storage is now on single sqlite3 database + - new "add log entry" dialog - deprecated `default` in background_jobs yaml fields. - [ ] test self-test - [ ] check back edits to stirring calibration + - [ ] cahnges to settings api ### 24.12.10 - Hotfix for UI settings bug diff --git a/pioreactor/actions/leader/export_experiment_data.py b/pioreactor/actions/leader/export_experiment_data.py index 896fe8c1..6e509200 100644 --- a/pioreactor/actions/leader/export_experiment_data.py +++ b/pioreactor/actions/leader/export_experiment_data.py @@ -225,9 +225,10 @@ def export_experiment_data( iloc_unit = None parition_to_writer_map: dict[tuple, Any] = {} - + count = 0 with ExitStack() as stack: - for i, row in enumerate(cursor, start=1): + for row in cursor: + count += 1 rows_partition = ( row[iloc_experiment] if iloc_experiment is not None else "all_experiments", row[iloc_unit] if iloc_unit is not None else "all_units", @@ -245,10 +246,12 @@ def export_experiment_data( parition_to_writer_map[rows_partition].writerow(row) - if i % 1000 == 0: - logger.debug(f"Exported {i} rows...") + if count % 1000 == 0: + logger.debug(f"Exported {count} rows...") - logger.debug(f"Exported {i} rows from {dataset_name}.") + logger.debug(f"Exported {count} rows from {dataset_name}.") + if count == 0: + logger.warning(f"No data present in {dataset_name}. Check database?") for filename in filenames: path_to_file = Path(Path(output).parent / filename) diff --git a/pioreactor/actions/od_blank.py b/pioreactor/actions/od_blank.py index 8668a0ba..28c375e0 100644 --- a/pioreactor/actions/od_blank.py +++ b/pioreactor/actions/od_blank.py @@ -174,17 +174,12 @@ def od_blank( 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: + ) as od_stream: # 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, diff --git a/pioreactor/structs.py b/pioreactor/structs.py index c0252123..936e2603 100644 --- a/pioreactor/structs.py +++ b/pioreactor/structs.py @@ -134,11 +134,7 @@ class Voltage(JSONPrintedStruct): voltage: pt.Voltage -def to_calibration_tag(s: str) -> str: - return s.lower().removesuffix("calibration") - - -class CalibrationBase(Struct, tag_field="calibration_type", tag=to_calibration_tag, kw_only=True): +class CalibrationBase(Struct, tag_field="calibration_type", kw_only=True): calibration_name: str pioreactor_unit: str created_at: t.Annotated[datetime, Meta(tz=True)] @@ -150,10 +146,10 @@ class CalibrationBase(Struct, tag_field="calibration_type", tag=to_calibration_t @property def calibration_type(self): - return to_calibration_tag(self.__class__.__name__) + return self.__struct_config__.tag -class ODCalibration(CalibrationBase, kw_only=True): +class ODCalibration(CalibrationBase, kw_only=True, tag="od"): ir_led_intensity: float angle: str pd_channel: str @@ -163,7 +159,6 @@ class ODCalibration(CalibrationBase, kw_only=True): maximum_voltage: float - class _PumpCalibration(CalibrationBase, kw_only=True): hz: t.Annotated[float, Meta(ge=0)] dc: t.Annotated[float, Meta(ge=0)] @@ -192,19 +187,19 @@ def duration_to_ml(self, duration: pt.Seconds) -> pt.mL: return t.cast(pt.mL, duration * duration_ + bias_) -class MediaPumpCalibration(_PumpCalibration, kw_only=True): +class MediaPumpCalibration(_PumpCalibration, kw_only=True, tag="media_pump"): pass -class AltMediaPumpCalibration(_PumpCalibration, kw_only=True): +class AltMediaPumpCalibration(_PumpCalibration, kw_only=True, tag="alt_media_pump"): pass -class WastePumpCalibration(_PumpCalibration, kw_only=True): +class WastePumpCalibration(_PumpCalibration, kw_only=True, tag="waste_pump"): pass -class StirringCalibration(CalibrationBase, kw_only=True): +class StirringCalibration(CalibrationBase, kw_only=True, tag="stirring_pump"): pwm_hz: t.Annotated[float, Meta(ge=0)] voltage: float x: str = "DC %" @@ -216,9 +211,7 @@ class StirringCalibration(CalibrationBase, kw_only=True): ] -AnyPumpCalibration = t.Union[ - MediaPumpCalibration, WastePumpCalibration, AltMediaPumpCalibration -] +AnyPumpCalibration = t.Union[MediaPumpCalibration, WastePumpCalibration, AltMediaPumpCalibration] class Log(JSONPrintedStruct):