Document OT-2 / Hugging Face / MongoDB data flow for LCM demo#553
Document OT-2 / Hugging Face / MongoDB data flow for LCM demo#553Copilot wants to merge 1 commit into
Conversation
|
@copilot more so I mean provide an explanation to @kbuchel about how each of these pieces work together, without assuming familiarity with MongoDB, Prefect, Hugging Face, or OT-2 firmware / workflows. Include hyperlinks to specific files to provide additional context. Note also that you'll want to access the hugging face space for the OT-2 LCM, looking at the files there, too. |
@kbuchel here's a from-scratch walkthrough of how the liquid colour-matching (LCM) demo works, assuming no prior exposure to MongoDB, Prefect, Hugging Face, MQTT, or the OT-2. I've linked the specific files for each piece. First, a note: I wasn't able to open the Hugging Face Space files from my sandbox (the The 5 pieces, in plain termsThink of it like a tiny restaurant:
One experiment, step by step
So the data path is always: Website ⇄ HiveMQ ⇄ Robot/Sensor, with the Website ⇄ MongoDB on the side for remembering state. The robot and sensor never touch MongoDB or the website directly — only HiveMQ. "Prefect" — what that word means hereYou'll see Prefect mentioned. Prefect is just a tool for scheduling and re-running Python jobs automatically (like a smart cron / task runner). In this demo it was used to fire off the manual "refill the vials / reset the plate" reminders and to wrap the robot steps as restartable "flows" — see What you need credentials for (and where)
Handy maintenance commandTo start a fresh plate, instead of editing MongoDB by hand, run Happy to go deeper on any single piece (e.g. exactly how the website subscribes to the sensor's results) once I can see the HF Space's |
|
@copilot should be unblocked on firewall now |
|
@kbuchel does the above make sense? #553 (comment) To what extent does this answer your question? Noting again that I no longer have access to the MongoDB that was being used. |
Firewall's working now — I read the actual Space, The HF Space's files (the "manager")
What I can now confirm (and correct)1. The website is the one that triggers the sensor read. Earlier I had to guess this. It's confirmed in
(This is why the sensor-command lines are commented out in the repo's 2. Env-var names on HF are 3. MongoDB collection names (db 4. The "wrong student's result" bug Neil mentioned: 5. The livestream / playlist issue Neil flagged is addressed in 6. Plate reset = Prefect maintenance flow. One thing still hard-coded in No code changes here — this is the documentation answer requested. Happy to diff the Space's |
Hi Dr. Baird, This fully answers my question--thank you! Do you have any update on the router yet? |
|
@kbuchel I sent a message to Gurpaul but haven't heard back. You might consider reaching out. A stop gap would be to pair it to a phone hotspot (needs to be in "compatibility mode" to switch to it 2.4 GHz instead of 5G), which would at least unblock you from testing. |
Hi Dr. Baird, I tried this, but the sensor was having a lot of trouble connecting to my hotspot, and so was the robot. Also side note—is the SFTP subsystem broken? Cyberducks is throwing an EOF error when I try to connect to the Opentrons. |
|
@kbuchel what phone do you have? It might also help to canonicalize the SSID and password (no spaces for example)
What is Cyberducks? How are you using it? Have you been able to SSH into the OT-2? I believe this is the primary way we interfaced with the OT-2 in terms of initial setup. |
Hi Dr. Baird,
|
Ah.. I'm not sure why that would be. I haven't heard back about the router. I have a vague memory that of the three routers we had, some of the plans might have been cancelled. I'll cc you on another email |
Responds to the request in issue #552 to clarify how the OT-2, Hugging Face Space, MongoDB, HiveMQ broker, and Pico W colour sensor interact for the Winter 2026 MSE403H1 liquid colour-matching demo, plus the role of the NOKIA router.
No code changes. A plain-language, file-linked explanation (no assumed familiarity with MongoDB, Prefect, Hugging Face, MQTT, or OT-2 workflows) was posted as a reply to the comment (tagging @kbuchel), per repo convention of keeping documentation in comment replies rather than new files. After the firewall was opened, the answer was verified and completed against the actual HF Space,
AccelerationConsortium/OT-2-LCM(a Gradioapp.py, not the olderlight-mixingNeoPixel demo).Findings posted
OT-2-LCM, Gradio) = orchestrator (state + hardware + livestream), HiveMQ = MQTT bus, MongoDB (LCM-OT-2-SLD) = well/quota/result/maintenance store, OT-2 + Pico W = hardware that only talk to HiveMQ.app.py): student submit → HF quota/well lookup in MongoDB → mix command tocommand/ot2/{serial}/pipette→ OT-2 dispenses + positions sensor, reportsin_place→ HF publishes the read command tocommand/picow/{id}/as7341/read→ Pico W publishes AS7341 data tocolor-mixing/picow/{id}/as7341→ HF tells OT-2 to return the sensor (sensor_status: read) → OT-2 reportscharging→ HF persists result viasave_resultand the well is marked used. (HF, not the OT-2, triggers the sensor read; the corresponding lines are commented out inOT2mqtt.py.)MQTT_BROKER/MQTT_PORT/MQTT_USERNAME/MQTT_PASSWORD(the HiveMQ creds, namedMQTT_*on HF), plusMONGODB_PASSWORD,blinded_connection_string, andYT_API_KEY(livestream); HiveMQ creds must match across HF / OT-2 / Pico W; WiFi creds live on the OT-2 and Pico W.wells,student,result(the live results collection),HITL_status,maintenance_logs.experiment_idexperiment_storerouting addresses the "wrong student's result" bug;yt_utils.get_latest_video_idwalking the whole playlist bypublishedAtaddresses the livestream-ordering issue.maintenance_flow.py(Slack notify → pause →generate_empty_well()→ log), not a manual MongoDB edit.my_secrets.py); HiveMQ is cloud-hosted and not in the data path. Hotspot swap recommended to isolate WiFi vs. broker/sensor faults.Flagged (not changed, out of scope)
OT2mqtt.pyand the orchestrator notebooks;OT2_SERIAL/PICO_IDare hard-coded in the Space'sapp.py— device swaps or credential rotation require updating all relevant locations (OT-2, HF, Pico W).DB_utils.pyhas diverged from the repo'sDB_utls.py(e.g. live collectionresultvs.MSE403_result, added maintenance helpers); may be worth syncing.mqtt_as.pyvariant, notmqtt.simple(wireless-color-sensor#13).