Skip to content

Commit

Permalink
don't need to start stirring if od_statistics will do it anyways - ri…
Browse files Browse the repository at this point in the history
…ght?
  • Loading branch information
CamDavidsonPilon committed Dec 18, 2024
1 parent db28276 commit 11b9b4f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions pioreactor/actions/leader/export_experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions pioreactor/actions/od_blank.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 8 additions & 15 deletions pioreactor/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand All @@ -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)]
Expand Down Expand Up @@ -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 %"
Expand All @@ -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):
Expand Down

0 comments on commit 11b9b4f

Please sign in to comment.