Select hardware based on config.json file#602
Conversation
adafruithat vs. planktoscopehat program variants based on config.json file
|
@sonnyp This PR's design choices may have some minor conflicts with certain design choices you made in #583. Here are some potentially-relevant assumptions I've made for this PR - they may be worth revisiting in subsequent work in #583:
If you want to merge #583 by having that PR rely on the planktoscopehat Node-RED dashboard's home page's version-selection menu for selecting the hardware variant, then I believe you'll need to make one of the following sets of changes to the planktoscopehat Node-RED dashboard in #583:
|
sonnyp
left a comment
There was a problem hiding this comment.
Please undo formatting changes to facilitate review
adafruithat vs. planktoscopehat program variants based on config.json fileconfig.json file
|
Regarding
I'm not convinced. I'd much prefer the 2 codebases to remain separate unless someone has a plan on doing all the work for the merge. Otherwise, |
|
You can review my changes with |
|
Sorry about the delay on my end / thanks for finishing this! Your changes look good to me, so I'll press the "Squash and merge" button. I'll follow up in another comment reply regarding the future-PR TODOs I had proposed. |
Having two identical copies of variant-independent code (i.e. the camera/imaging subsystem, generic-ish MQTT adapter, and machine-name support modules) makes their source code prone to drifting from each other unless we maintain a discipline of replicating changes to those modules from one variant's codebase to the other variant's codebase (e.g. when I reviewed #600, I totally missed the fact that you changed code files for the camera/imaging subsystem only for the planktoscopehat variant and not for the adafruithat variant). This reasoning is also part of why I had split the segmenter's codebase from the hardware controller's codebase, because it makes no sense for the segmenter to behave differently between adafruithat vs. planktoscopehat. In those cases (i.e. for the segmenter, the camera/imaging subsystem, the generic-ish MQTT adapter, and machine-name support), I think variant drift should be treated as maintainer error, because it increases the complexity of mental models needed for helping users troubleshoot their problems. To me, the benefit of having a single copy of those variant-independent modules is that it removes the root cause of such variant drift. With that said, I'm not opposed to leaving two copies of those variant-independent modules if we have some other way of mitigating the problems caused by that. For example, how would you feel about a potential alternative where I just implement a |
|
If
If we want to keep supporting Let's discuss this at the weekly meeting today? |
|
There is a regression which I don't understand starting or restarting Any idea @ethanjli ? |
|
Yesterday I also noticed it during shutdown. Maybe we'll also need to lift interrupt signal handling to the top level, or something? That doesn't explain the slow startup times, though. |
|
No logs before 45 seconds either in journalctl or |
For anyone looking at this PR in the future, we've resolved this discussion in the 2025-05-21 core team meeting, and the decision is recorded there |

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.jsonfile and then rebooting (or restartingnodered.serviceand then restartingplanktoscope-org.device-backend.controller.serviceafter 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 I plan to propose deprecating GPS functionality from the adafruithat variants too.Specifically, this PR:
main.pyscript based on theconfiguration in/usr/share/planktoscope/installer-config.yml, in the same way that software: Gitify node-red-dashboard #573 selects adafruithat vs. planktoscopehat for the Node-RED dashboard~/PlanktoScope/config.jsonfile'sacq_instrumentfield (whose values are likePlanktoScope v2.6). See Use runtime to select the hardware variant #583 (comment) and the 2025-05-07 software meeting for additional context on this step towards a piecemeal incremental unification of the adafruithat vs. planktoscopehat variants of the Python device controller.settings.jsfile to choose between the adafruithat vs. planktoscopehat variants of the dashboard based on the~/PlanktoScope/config.jsonfile'sacq_instrumentfield.fairscope-latestimage caused by software: Gitify node-red-dashboard #573, where thefairscope-latestimage was unable to select theplanktoscopehatNode-RED dashboard (because it was looking for afairscope-latestvariant 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:
if __name__ == "__main__"code blocks in the adafruithat/planktoscopehatmain.pyfiles 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 backend: Read hardware config once #600 due to the risk of messy merge conflicts with that PR.main.pyfiles to the hardware controller's top-levelmain.pyfile, so that log messages will be saved to file.For future PRs (since this PR already touches a lot of files):
.../control/planktoscopehat/planktoscope/identity.py&.../control/planktoscopehat/planktoscope/mqtt.py&.../control/planktoscopehat/planktoscope/camera&.../control/planktoscopehat/planktoscope/imagingdriver modules to a shared, unified location (perhaps../control/drivers) which is used by both.../planktoscopehat/main.pyand.../adafruithat/main.py, instead of having two (supposedly) identical of each module..../control/{variant}/planktoscopeto.../control/{variant}, to reduce redundancies the path names