Skip to content

Commit 675e2c4

Browse files
better proto flow
1 parent a0c85d3 commit 675e2c4

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

core/pioreactor/calibrations/protocols/od_fusion_standards.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ def render(self, ctx: SessionContext) -> CalibrationStep:
213213
"You will need:\n"
214214
"1. A Pioreactor XR.\n"
215215
"2. A set of OD600 standards in Pioreactor vials (at least 10 mL each), with stir bars.\n"
216-
"3. Multiple readings per standard."
217216
),
218217
)
219218

@@ -231,7 +230,7 @@ def render(self, ctx: SessionContext) -> CalibrationStep:
231230
ctx.data["default_name"] = default_name
232231
return steps.form(
233232
"Name this estimator",
234-
"Choose a unique name for this fused OD estimator.",
233+
"Choose a name for this fused OD estimator.",
235234
[fields.str("estimator_name", label="Estimator name", default=default_name)],
236235
)
237236

@@ -334,7 +333,7 @@ def render(self, ctx: SessionContext) -> CalibrationStep:
334333
standard_index = int(ctx.data.get("standard_index", 1))
335334
step = steps.form(
336335
f"Record standard vial {standard_index}",
337-
f"Enter the OD600 measurement for the vial {standard_index}.",
336+
f"Enter the OD600 measurement for the standard vial {standard_index}.",
338337
[fields.float("od_value", label="OD600", minimum=0.0001)],
339338
)
340339
chart = _build_chart_metadata(ctx.data.get("records", []))
@@ -363,7 +362,7 @@ def render(self, ctx: SessionContext) -> CalibrationStep:
363362
standard_index = int(ctx.data.get("standard_index", 1))
364363
step = steps.action(
365364
f"Insert standard vial {standard_index} ({current}/{total})",
366-
f"Place the standard vial {standard_index} with a stir bar into the Pioreactor.",
365+
f"Place standard vial {standard_index} with a stir bar into the Pioreactor.",
367366
)
368367
step.metadata = {
369368
"image": {
@@ -388,7 +387,7 @@ def render(self, ctx: SessionContext) -> CalibrationStep:
388387
standard_index = int(ctx.data.get("standard_index", 1))
389388
step = steps.action(
390389
f"Recording standard vial {standard_index} ({current}/{total} complete)",
391-
"We'll take an OD reading for this observation.",
390+
"We'll next take an OD reading for this standard.",
392391
)
393392
chart = _build_chart_metadata(ctx.data.get("records", []))
394393
if chart is not None:

frontend/src/Pioreactors.jsx

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,45 @@ function AssignPioreactors({ experiment, variant="text" }) {
414414
return differences;
415415
}
416416

417+
function getAssignmentDeltaCounts(delta) {
418+
let assignedCount = 0;
419+
let unassignedCount = 0;
420+
421+
for (const worker in delta) {
422+
if (delta[worker].current && !delta[worker].initial) {
423+
assignedCount += 1;
424+
} else {
425+
unassignedCount += 1;
426+
}
427+
}
428+
429+
return { assignedCount, unassignedCount };
430+
}
431+
432+
function getAssignmentDeltaLabel(delta) {
433+
const { assignedCount, unassignedCount } = getAssignmentDeltaCounts(delta);
434+
const labelParts = [];
435+
const totalCount = assignedCount + unassignedCount;
436+
437+
if (unassignedCount > 0) {
438+
labelParts.push(`Unassign ${unassignedCount}`);
439+
}
440+
441+
if (assignedCount > 0) {
442+
labelParts.push(`Assign ${assignedCount}`);
443+
}
444+
445+
if (labelParts.length === 0) {
446+
return "No changes";
447+
}
448+
449+
if (assignedCount > 0 && unassignedCount > 0) {
450+
return `Update ${totalCount}`;
451+
}
452+
453+
return labelParts.join(", ");
454+
}
455+
417456
const updateAssignments = async () => {
418457
const delta = compareObjects(assigned, initialAssigned);
419458
const promises = [];
@@ -480,6 +519,10 @@ function AssignPioreactors({ experiment, variant="text" }) {
480519
setSelectAll(allSelected ? true : (noneSelected ? false : null));
481520
}, [assigned, workers, experiment]);
482521

522+
const assignmentDelta = compareObjects(assigned, initialAssigned);
523+
const assignmentDeltaCount = Object.keys(assignmentDelta).length;
524+
const assignmentDeltaLabel = getAssignmentDeltaLabel(assignmentDelta);
525+
483526
return (
484527
<React.Fragment>
485528
<Button variant={variant} style={{ textTransform: "none" }} onClick={handleClickOpen}>
@@ -514,7 +557,7 @@ function AssignPioreactors({ experiment, variant="text" }) {
514557
<DialogContent>
515558
<p>
516559
Assign and unassign Pioreactors to experiment{" "}
517-
<Chip icon={<PlayCircleOutlinedIcon/>} size="small" label={experiment} clickable component={Link} onClick={() => selectExperiment(experiment)} data-experiment-name={experiment} />.
560+
<Chip icon={<PlayCircleOutlinedIcon/>} size="small" label={experiment} />.
518561
</p>
519562
<FormControl sx={{ m: "auto" }} component="fieldset" variant="standard">
520563
<FormLabel component="legend">Pioreactors</FormLabel>
@@ -574,10 +617,10 @@ function AssignPioreactors({ experiment, variant="text" }) {
574617
<Button
575618
variant="contained"
576619
onClick={updateAssignments}
577-
disabled={Object.keys(compareObjects(assigned, initialAssigned)).length === 0}
620+
disabled={true && assignmentDeltaCount === 0}
578621
style={{ textTransform: "none" }}
579622
>
580-
Update {Object.keys(compareObjects(assigned, initialAssigned)).length}
623+
{assignmentDeltaLabel}
581624
</Button>
582625
</DialogActions>
583626
</Dialog>

0 commit comments

Comments
 (0)