Skip to content

fix(app): fix accumulating offsets on run record#17969

Merged
mjhuff merged 1 commit into
chore_release-8.4.0from
app_filter-redundant-offsets-clone-run
Apr 2, 2025
Merged

fix(app): fix accumulating offsets on run record#17969
mjhuff merged 1 commit into
chore_release-8.4.0from
app_filter-redundant-offsets-clone-run

Conversation

@mjhuff
Copy link
Copy Markdown
Contributor

@mjhuff mjhuff commented Apr 2, 2025

Closes EXEC-1411

Overview

When "cloning" a run on the app, the app quite literally creates a run with some predefined values gleaned from the historical run record of the run being cloned, and the new run reflects those old values. One of those values is labwareOffsets.

In the new LPC, a user clicks the "apply offsets" button, and this applies all the offsets utilized in the run to the run record. If a run is cloned, this mean that all the old offset values are present on the run record, and now the list increases by all the offsets utilized in this run. By cloning the run repeatedly, this list can grow unbounded.

This PR adds a filter when cloning a run so that only the most recent and unique labware offsets are preserved. In other words, the labware offsets field on the run record now can only ever be 2x the amount of unique offests possible for a run: the cloned run list of offsets + the offsets that are applied when clicking applied offsets.

Test Plan and Hands on Testing

  • Tested this on a robot, cloning a run 4 times and applying offsets each time. Here is an example of the before behavior (before.json) and here is an example of the fixed behavior (after.json). Grep for slotName: D1. You'll notice in the before case, it occurs 4 times. With the fix, after cloning a run 4 times, you only ever the same offset apply twice (for the reasons explained above).

Changelog

  • Fixed a potential performance issue in which the run record grows unbounded.

Review requests

  • This logic assumes that for any given unique offset, the most recent offsets are appended to end of the list. That's right, yeah?

Risk assessment

low, assuming the logic is correct

@mjhuff mjhuff requested review from a team, SyntaxColoring and sfoster1 April 2, 2025 19:19
@mjhuff mjhuff requested a review from a team as a code owner April 2, 2025 19:19
@mjhuff mjhuff requested review from shlokamin and removed request for a team and shlokamin April 2, 2025 19:19
@mjhuff mjhuff force-pushed the app_filter-redundant-offsets-clone-run branch from e7ec6c3 to 5ee0812 Compare April 2, 2025 19:33
Copy link
Copy Markdown
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think this makes sense, thank you!

Comment on lines +93 to +97
array.findLastIndex(
firstOffset =>
isEqual(firstOffset.locationSequence, offset.locationSequence) &&
isEqual(firstOffset.definitionUri, offset.definitionUri)
) === index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you're only comparing locationSequence, until #17946 is merged, I think this will return wrong results when used on old runs. (Offsets will be dropped erroneously because the old offsets, without the new locationSequence field, will erroneously compare equal to each other.)

I'm fine solving this with #17946 if you are, but if you wanted to solve it here, I guess you'd replace

isEqual(firstOffset.locationSequence, offset.locationSequence)

with

isEqual(firstOffset.locationSequence ?? firstOffset.location, offset.locationSequence ?? offset.location)

Copy link
Copy Markdown
Contributor Author

@mjhuff mjhuff Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for noting, I meant to mention this in the PR description. Yes, this will load the wrong offsets on runs containing legacy offset data. I'm fine with #17946 solving this entirely.

@mjhuff mjhuff merged commit 4482fbe into chore_release-8.4.0 Apr 2, 2025
30 checks passed
@mjhuff mjhuff deleted the app_filter-redundant-offsets-clone-run branch April 2, 2025 23:42
y3rsh added a commit that referenced this pull request Apr 9, 2025
…y-path

* chore_release-8.4.0: (30 commits)
  fix(api): make error message clearer for lld issues (#18005)
  chore(locize): sync for translations needed (#18009)
  chore(locize): sync translations (#18009)
  docs(api): API reference entries for liquid class methods (#17887)
  refactor(api): change the names of liquid classes based transfers (#18006)
  feat(app, labware-library): add evotip definition assets (#18007)
  fix(api, shared-data): Flex Stacker engine command optional fields (#17989)
  fix(shared-data): ethanol aspirate position reference (#17991)
  fix(app): Labware setup UI fixes (#17987)
  refactor(app): adjust protocol setup offsets table header (#17985)
  fix(app): do not show post run drop tip prompt if just handled in Error Recovery (#17981)
  fix(app): fix LPC disabled reasons not including fixture mismatch (#17979)
  refactor(app): adjust width on "calibrate now" button (#17978)
  fix(app): fix applying offsets implicitly when navigating on the desktop app (#17967)
  feat(robot-server): Populate `locationSequence` on old runs and make it faster to filter out deleted offsets (#17946)
  feat(app): add inline notification when setting default offsets with a 96ch (#17977)
  fix(app): ER tip selection crashes when trying to get labware def (#17975)
  feat(robot-server,system-server): Return server timing metrics in HTTP responses (#17970)
  fix(app): fix accumulating offsets on run record (#17969)
  fix(app): Fix local state issues when "resetting to default" in LPC (#17965)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants