Repository navigation
controller: add Planktoscope unit number to metadata - #942
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <[email protected]>
2 tasks
sonnyp
pushed a commit
that referenced
this pull request
Apr 27, 2026
## Summary `build-controller.yml` runs `sudo apt install -y libcap-dev` without first refreshing the apt index. When Ubuntu rotates a security update for `libcap2`/`libcap-dev` (as happened with `2.66-5ubuntu2.2`), the runner's cached index points to a `.deb` that's no longer on the mirror and the install fails with `404 Not Found` → `exit code 100`. Hit on PR #942 (run 24971308570) twice in a row. ## Change Prepend `sudo apt-get update` to the install step so the runner pulls the current package version every time. ## Test plan - [ ] CI passes on this PR - [ ] Re-trigger CI on PR #942 once this lands; the libcap-dev step succeeds
sonnyp
approved these changes
Apr 27, 2026
sonnyp
left a comment
Collaborator
There was a problem hiding this comment.
👍 for doing this in backend instead of frontend
sonnyp
reviewed
Apr 27, 2026
sonnyp
left a comment
Collaborator
There was a problem hiding this comment.
Can be improved by
- read the serial number once at startup
- differentiate between no serial number (
Nonee.g. 2.6) and an unexpected error happened
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the FairScope HAT serial number (e.g.
U383) to every acquisition's metadata so the produced data can be traced back to thespecific physical instrument that produced it.
The serial number is already stored in the HAT EEPROM (read from
/proc/device-tree/hat/custom_0, base64-decoded JSON) and previouslysurfaced only in the JS layer via
lib/hardware.js. Until now, EcoTaxa exports identified the instrument only by software model(
acq_instrument) and machine name (acq_instrument_id), so two different physical units sharing the same machine name (or a unitlater renamed) couldn't be distinguished in the archive.
What changed
controller/imager/main.py_read_hat_serial_number()helper — reads/proc/device-tree/hat/custom_0, strips the trailing NUL, base64-decodes,JSON-parses, returns the
serial_numbervalue, orNoneon any failure._start_acquisition, when the read succeeds, setmetadata["acq_instrument_serial_number"] = serial. The key is omittedentirely on read failure so non-FairScope HATs do not get a misleading column.
No segmenter changes are needed — the existing
acq_*prefix filter insegmenter/planktoscope/segmenter/__init__.pyalreadyforwards every
acq_key frommetadata.jsonstraight to the EcoTaxa TSV.Why this injection point
Reading at acquisition start (rather than at segmentation time) binds the serial to the data at capture, not at processing. If someone
later segments on a different machine or swaps HATs between capture and segmentation, the serial in the TSV still reflects the
instrument that produced the images. The value also lands in
metadata.jsonnext to the images, so it travels with the acquisitionfolder regardless of EcoTaxa export.
Field naming
acq_instrument_serial_numberacq_*prefix convention for instrument-related metadataacq_instrument_id(which is the human-friendly machine name likesponge-care-xxx)[t](text) automaticallyTest plan
U383) andNonefor missing/garbage/empty EEPROM blobs"acq_instrument_serial_number": "U383"intometadata.jsonecotaxa_testerunit_1_A_1.zip) contains the column in the TSV header (col 47), type marker[t], valueU383consistent across all 68 object rowsacq_*/sample_*columns still populate correctly (acq_uuid,sample_uuid,acq_id,etc.)
custom_0(should silently omit the column — verified via local helper,not on hardware)