Use runtime to select the hardware variant#583
Conversation
| "id": "dffeaf1bc89fcb11", | ||
| "type": "exec", | ||
| "z": "1eaf21c8.f7a21e", | ||
| "command": "sudo systemctl enable planktoscope-org.device-backend.controller-planktoscopehat.service", |
There was a problem hiding this comment.
This will be sudo systemctl enable planktoscope-org.device-backend.controller-adafruithat.service on the adafruithat flow
But otherwise it should be the same thing
| { | ||
| "id": "be888117.5cd67", | ||
| "type": "ui_template", | ||
| "z": "1eaf21c8.f7a21e", | ||
| "group": "6be36295.0ab324", | ||
| "name": "Stepper controller type header", | ||
| "order": 3, | ||
| "width": "5", | ||
| "height": 1, | ||
| "format": "<div>Stepper controller type</div>", | ||
| "storeOutMessages": true, | ||
| "fwdInMessages": true, | ||
| "resendOnRefresh": true, | ||
| "templateScope": "local", | ||
| "className": "", | ||
| "x": 550, | ||
| "y": 80, | ||
| "wires": [ | ||
| [] | ||
| ] | ||
| }, |
There was a problem hiding this comment.
unrelated but I forgot to remove it in #577
it can also be removed in the adafruithat - it's the label for the "stepper type" hardware setting
|
The last blocker is the selection of the node-red flow which happens in https://github.com/PlanktoScope/PlanktoScope/blob/43289d154eada28b74364a0c65c646f123ca8443/software/node-red-dashboard/settings.js and reads I see 2 options A. Merge the adafruithat and planktoscopehat flows Risky, possibly requires merging adafruithat and planktoscopehat backend B. Move hardware selection to device-portal This is actually the landing page of the PlanktoScope so I think it's a natural move. There is also a proposal for first boot wizard PlanktoScope/device-portal#54 device-backend and node-red would remain disabled/stopped until flows would become significantly simpler That's my favorite but I'm a bit uncomfortable with device-portal being written in Go as only @ethanjli seems to be familiar with it and may have much less time for PlanktoScope soon. device-portal seems fairly simple, perhaps a quick rewrite before adding more to it would make sense? Happy to volunteer. We can consider merging that with backend in the future. @ethanjli WDYT? |
I'd be happy to assist with any rewrite you want to do of device-portal, because I'd like to eventually transition out of maintaining the PlanktoScope OS's landing page. Assuming we don't add a first-boot wizard (or other interactive functionality) to device-portal, the migration will be fairly simple: right now we're just getting a bit of information from various sources (e.g. HTTP request headers, so we can detect the hostname being used to access the landing page) and then passing that to a single web page template. So if you want to do a rewrite of device-portal in the future, I'd prefer to find some lower-effort way (outside of device-portal) to (at least temporarily) provide the minimal subset of "first-boot wizard" functionality which we'd need for this current PR.
To put into writing something I had previously only mentioned verbally (and in much less detail), I'd like to focus on lower-level/reusable OS subsystems, such as maintenance of the CI workflows for OS builds, working on the software update system, improving networking-related behaviors, etc. Much of that work is already being directly reused in a downstream project (e.g. by importing packages from pallet-standard, and by maintaining a slightly-diverged copy of CI workflow definitions and OS setup scripts I had written for the PlanktoScope repo) which I will be taking active (employed) responsibility for as part of the openUC2 project. Wherever there continues to be sufficient alignment between the RPi-based OSes for openUC2 and PlanktoScope, I can work by upstream-first contributions (e.g. fixing problems in PlanktoScope OS and then propagating them to openUC2's OS by bumping package imports wherever possible, or by manual edits of copied files otherwise) and/or by eventual upstreaming of improvements from downstream. So I think there may be certain subsystems of PlanktoScope OS that I will be able to sustain (employed) time to help maintain. Of course, plans may continue to evolve over the next several months, so nothing is guaranteed on my end for any planning on your end - but I can keep you updated as any changes become clear.
My long-term hope would be to merge the adafruithat and planktoscopehat flows, but I agree with you that it's too big/risky of a change to do it all in this PR. I think we'd first want to integrate a separate PR which unifies the entrypoint to the Python backend. Now that I think about it, perhaps the backend merger could be done incrementally by the following steps:
I just thought of a third option, inspired by your work in #573, and I wonder if it might be reasonable as a temporary solution for a more incremental process of change (or maybe even a longer-term solution): make the base OS image default to a separate Node-RED flow file which is just a first-boot wizard (e.g. in Possible consequences/impacts:
If we want to be ambitious with the UX, maybe it's even feasible to modify the Node-RED |
|
One more option for replacing device-portal; use the new dashboard https://github.com/PlanktoScope/dashboard node-RED dashboard 2 uses Vue templates so it might be a good candidate - I'll prototype |
As part of #182, this PR enables the user to switch between the adafruithat vs. planktoscopehat program variants by editing the SD card's `~/PlanktoScope/config.json` file and then rebooting (or restarting `nodered.service` and then restarting `planktoscope-org.device-backend.controller.service` after Node-RED becomes ready to receive MQTT messages, without a full system reboot). A minor caveat here is that GPS functionality is not available on planktoscopehat-based images running the adafruithat program variants (because of #591); but in the [2025-05-14 software meeting](https://docs.google.com/document/d/1AN1jaIdfKChKjMnzSd3ecjRTZGOnoglBfV9LCpevMgk/edit?tab=t.geukyqpm9ntj#heading=h.ziivhaa9au6q) I plan to propose deprecating GPS functionality from the adafruithat variants too. Specifically, this PR: - unifies the systemd services for the Python device controller into a single service, and this PR provides a single top-level entrypoint script which selects the adafruithat vs. planktoscopehat `main.py` script based on the ~configuration in `/usr/share/planktoscope/installer-config.yml`, in the same way that #573 selects adafruithat vs. planktoscopehat for the Node-RED dashboard~ `~/PlanktoScope/config.json` file's `acq_instrument` field (whose values are like `PlanktoScope v2.6`). See #583 (comment) and the [2025-05-07 software meeting](https://docs.google.com/document/d/1AN1jaIdfKChKjMnzSd3ecjRTZGOnoglBfV9LCpevMgk/edit?tab=t.geukyqpm9ntj#heading=h.81oklfxjwmel) for additional context on this step towards a piecemeal incremental unification of the adafruithat vs. planktoscopehat variants of the Python device controller. - updates the Node-RED dashboard's `settings.js` file to choose between the adafruithat vs. planktoscopehat variants of the dashboard based on the `~/PlanktoScope/config.json` file's `acq_instrument` field. - fixes a regression in the `fairscope-latest` image caused by #573, where the `fairscope-latest` image was unable to select the `planktoscopehat` Node-RED dashboard (because it was looking for a `fairscope-latest` variant of the dashboard). This PR also removes OS setup script support for "segmenter-only" images, since those images were never officially supported (and never documented in https://docs.planktoscope.community/reference/software/subsystems/installation/) and we stopped building them with #573. TODOs: - [x] Move the `if __name__ == "__main__"` code blocks in the adafruithat/planktoscopehat `main.py` files into a main function, so that we can invoke those scripts more cleanly, and so that we can make loguru-based logging work properly. This task is blocked by #600 due to the risk of messy merge conflicts with that PR. - [x] Move the loguru-based logger from the adafruithat/planktoscopehat `main.py` files to the hardware controller's top-level `main.py` file, so that log messages will be saved to file. - [x] Ensure that uncaught exceptions in the code are are logged to file by a top-level exception catcher via loguru. For future PRs (since this PR already touches a lot of files): - [ ] Move the `.../control/planktoscopehat/planktoscope/identity.py` & `.../control/planktoscopehat/planktoscope/mqtt.py` & `.../control/planktoscopehat/planktoscope/camera` & `.../control/planktoscopehat/planktoscope/imaging` driver modules to a shared, unified location (perhaps `../control/drivers`) which is used by both `.../planktoscopehat/main.py` and `.../adafruithat/main.py`, instead of having two (supposedly) identical of each module. - [ ] Move everything in `.../control/{variant}/planktoscope` to `.../control/{variant}`, to reduce redundancies the path names --------- Co-authored-by: Sonny Piers <sonny@fairscope.com>
As part of #182, this is a WIP/attempt to stop building multiple images and use runtime config to select adafruithat or planktoscopehat
On the base image:
PlanktoScope/hardware.jsonis not present anymore by defaultPlanktoScope/config.jsonis not present anymore by defaultAfter setting the hardware version in the dashboard
PlanktoScope/hardware.jsonis created (that was already the case)PlanktoScope/config.jsonis created (already the case)Flow
What's new:
set msg.payload(to JSONnull) are newTodo
hardware.jsonconfig.jsonTest
Use the image of this PR or