sparks-baird / self-driving-lab-demo

Software and instructions for setting up and running a self-driving lab (autonomous experimentation) demo using dimmable RGB LEDs, an 8-channel spectrophotometer, a microcontroller, and an adaptive design algorithm, as well as extensions to liquid- and solid-based color matching demos.
https://self-driving-lab-demo.readthedocs.io/
MIT License
69 stars 8 forks source link

pydantic minimal working example for experiment input validation (and some serverless options) #132

Open sgbaird opened 1 year ago

sgbaird commented 1 year ago

From https://github.com/sparks-baird/self-driving-lab-demo/discussions/127#discussioncomment-4199244 by @rekumar:

Have you looked at pydantic for this kind of thing? Its pretty nice, clear to work with, and stitches into API's very cleanly. Example for validating job submission to our API:

Defining our Data Model: https://github.com/CederGroupHub/alab_management/blob/94d02870623eb198e663e7789021e7f3596768c3/alab_management/experiment_view/experiment.py

Validating incoming jobs against the Data Model https://github.com/CederGroupHub/alab_management/blob/94d02870623eb198e663e7789021e7f3596768c3/alab_management/dashboard/routes/experiment.py#L14-L29

This would be at the application side (perhaps in the observation function).

Once pydantic is implemented in the codebase, I'd like to figure out a way to put a virtual- or hardware-based "firewall" in-between the user requesting the experiment and the device(s) carrying out the commands, in line with https://github.com/sparks-baird/self-driving-lab-demo/discussions/127#discussioncomment-4200086:

For SDLs with multiple steps (i.e. multiple pieces of hardware that require separate communication), I lean toward the idea of the user communicating with a central processor as a "firewall" of sorts (e.g., physical hardware or cloud-based server) rather than having the user directly communicate with the individual pieces of hardware. Something where the scope of users that can change code on the physical hardware, server, etc. is narrower than the scope of users that can send requests to it.

I.e., a way to expose a controlled instance of the API pinned to a specific package version via HTTP requests, for free.

Google search: host python package api for free

Vercel

sgbaird commented 1 year ago

On a related note, I'm interested in creating an example with the light-mixing demo and alab_management.

sgbaird commented 1 year ago

cc Matthias Albert Popp, re OPC-UA