labrat-lab 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- labrat_lab-0.1.0/LICENSE +177 -0
- labrat_lab-0.1.0/NOTICE +4 -0
- labrat_lab-0.1.0/PKG-INFO +238 -0
- labrat_lab-0.1.0/README.md +192 -0
- labrat_lab-0.1.0/pyproject.toml +67 -0
- labrat_lab-0.1.0/setup.cfg +4 -0
- labrat_lab-0.1.0/src/labrat/__init__.py +2 -0
- labrat_lab-0.1.0/src/labrat/cli.py +665 -0
- labrat_lab-0.1.0/src/labrat/client.py +236 -0
- labrat_lab-0.1.0/src/labrat/config.py +110 -0
- labrat_lab-0.1.0/src/labrat/detect.py +43 -0
- labrat_lab-0.1.0/src/labrat/device.py +312 -0
- labrat_lab-0.1.0/src/labrat/discovery.py +135 -0
- labrat_lab-0.1.0/src/labrat/drivers/__init__.py +59 -0
- labrat_lab-0.1.0/src/labrat/drivers/camera.py +140 -0
- labrat_lab-0.1.0/src/labrat/drivers/display.py +152 -0
- labrat_lab-0.1.0/src/labrat/drivers/genicam.py +120 -0
- labrat_lab-0.1.0/src/labrat/drivers/gpio.py +52 -0
- labrat_lab-0.1.0/src/labrat/drivers/http.py +131 -0
- labrat_lab-0.1.0/src/labrat/drivers/i2c.py +153 -0
- labrat_lab-0.1.0/src/labrat/drivers/mapped.py +105 -0
- labrat_lab-0.1.0/src/labrat/drivers/mqtt.py +135 -0
- labrat_lab-0.1.0/src/labrat/drivers/nut.py +133 -0
- labrat_lab-0.1.0/src/labrat/drivers/scpi.py +415 -0
- labrat_lab-0.1.0/src/labrat/drivers/serialport.py +60 -0
- labrat_lab-0.1.0/src/labrat/drivers/sim.py +87 -0
- labrat_lab-0.1.0/src/labrat/experiment.py +295 -0
- labrat_lab-0.1.0/src/labrat/http.py +189 -0
- labrat_lab-0.1.0/src/labrat/hub.py +446 -0
- labrat_lab-0.1.0/src/labrat/ident.py +180 -0
- labrat_lab-0.1.0/src/labrat/mcp.py +169 -0
- labrat_lab-0.1.0/src/labrat/message.py +160 -0
- labrat_lab-0.1.0/src/labrat/nest.py +327 -0
- labrat_lab-0.1.0/src/labrat/py.typed +0 -0
- labrat_lab-0.1.0/src/labrat/rat.py +115 -0
- labrat_lab-0.1.0/src/labrat/record.py +306 -0
- labrat_lab-0.1.0/src/labrat/store.py +176 -0
- labrat_lab-0.1.0/src/labrat/term.py +177 -0
- labrat_lab-0.1.0/src/labrat/users.py +101 -0
- labrat_lab-0.1.0/src/labrat_lab.egg-info/PKG-INFO +238 -0
- labrat_lab-0.1.0/src/labrat_lab.egg-info/SOURCES.txt +56 -0
- labrat_lab-0.1.0/src/labrat_lab.egg-info/dependency_links.txt +1 -0
- labrat_lab-0.1.0/src/labrat_lab.egg-info/entry_points.txt +2 -0
- labrat_lab-0.1.0/src/labrat_lab.egg-info/requires.txt +23 -0
- labrat_lab-0.1.0/src/labrat_lab.egg-info/top_level.txt +1 -0
- labrat_lab-0.1.0/tests/test_bus_drivers.py +346 -0
- labrat_lab-0.1.0/tests/test_display.py +43 -0
- labrat_lab-0.1.0/tests/test_experiments.py +210 -0
- labrat_lab-0.1.0/tests/test_god_mode.py +91 -0
- labrat_lab-0.1.0/tests/test_identity.py +121 -0
- labrat_lab-0.1.0/tests/test_mcp_and_cli.py +79 -0
- labrat_lab-0.1.0/tests/test_message_and_device.py +57 -0
- labrat_lab-0.1.0/tests/test_nest.py +70 -0
- labrat_lab-0.1.0/tests/test_rats.py +105 -0
- labrat_lab-0.1.0/tests/test_recordings.py +93 -0
- labrat_lab-0.1.0/tests/test_review_fixes.py +193 -0
- labrat_lab-0.1.0/tests/test_scpi.py +133 -0
- labrat_lab-0.1.0/tests/test_users_and_who.py +100 -0
labrat_lab-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
labrat_lab-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: labrat-lab
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A universal interface for lab automation: a nest server, rats at the bench, one message API over HTTP and MCP
|
|
5
|
+
Author: Reinhard Jansen van Vuuren
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/reinhardjvv/labrat
|
|
8
|
+
Project-URL: Documentation, https://github.com/reinhardjvv/labrat/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/reinhardjvv/labrat/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/reinhardjvv/labrat/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: laboratory automation,instrument control,SCPI,GPIO,MCP,Raspberry Pi,test and measurement
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Topic :: System :: Hardware
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
License-File: NOTICE
|
|
28
|
+
Requires-Dist: zeroconf>=0.131
|
|
29
|
+
Provides-Extra: serial
|
|
30
|
+
Requires-Dist: pyserial>=3.5; extra == "serial"
|
|
31
|
+
Provides-Extra: gpio
|
|
32
|
+
Requires-Dist: gpiod>=2.1; extra == "gpio"
|
|
33
|
+
Provides-Extra: i2c
|
|
34
|
+
Requires-Dist: smbus2>=0.4; extra == "i2c"
|
|
35
|
+
Provides-Extra: mqtt
|
|
36
|
+
Requires-Dist: paho-mqtt>=2.0; extra == "mqtt"
|
|
37
|
+
Provides-Extra: rat
|
|
38
|
+
Requires-Dist: labrat-lab[gpio,i2c,serial]; extra == "rat"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
41
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
42
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
43
|
+
Requires-Dist: pyserial>=3.5; extra == "dev"
|
|
44
|
+
Requires-Dist: pre-commit>=3; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<picture>
|
|
49
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/labrat-dark.svg">
|
|
50
|
+
<img alt="LABRAT, Remote Automated Testing" src="docs/assets/labrat-light.svg" width="600">
|
|
51
|
+
</picture>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<h3 align="center">A universal interface for lab automation</h3>
|
|
55
|
+
|
|
56
|
+
<p align="center"><i>Let the rat run the maze.</i></p>
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
Control oscilloscopes, signal generators, VNAs, spectrum analysers, power supplies, cameras and more through one API.
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
<p align="center">
|
|
63
|
+
<a href="https://github.com/reinhardjvv/labrat/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/reinhardjvv/labrat/actions/workflows/ci.yml/badge.svg"></a>
|
|
64
|
+
<a href="LICENSE"><img alt="Licence" src="https://img.shields.io/badge/licence-Apache--2.0-blue"></a>
|
|
65
|
+
</p>
|
|
66
|
+
|
|
67
|
+
> [!NOTE]
|
|
68
|
+
> LABRAT is in early development. The message API and the configuration may still change before 1.0, and
|
|
69
|
+
> each change is listed in the [changelog](CHANGELOG.md).
|
|
70
|
+
|
|
71
|
+
<p align="center">
|
|
72
|
+
<a href="#quick-start"><b>Quick start</b></a> ·
|
|
73
|
+
<a href="docs/install.md"><b>Install</b></a> ·
|
|
74
|
+
<a href="docs/api.md"><b>API</b></a> ·
|
|
75
|
+
<a href="docs/mcp.md"><b>MCP</b></a> ·
|
|
76
|
+
<a href="docs/drivers.md"><b>Drivers</b></a> ·
|
|
77
|
+
<a href="CONTRIBUTING.md"><b>Contributing</b></a>
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
<p align="center">
|
|
81
|
+
<picture>
|
|
82
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/terminal-dark.svg">
|
|
83
|
+
<img alt="labrat in a terminal: the devices, a voltage set, a supply described with its live values and limits, a refused value, and stop" src="docs/assets/terminal-light.svg" width="100%">
|
|
84
|
+
</picture>
|
|
85
|
+
</p>
|
|
86
|
+
|
|
87
|
+
## Quick start
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pipx install git+https://github.com/reinhardjvv/labrat.git
|
|
91
|
+
labrat demo # start a demo lab with simulated instruments
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
In a second terminal, with the token the demo prints:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
export LABRAT_URL=http://127.0.0.1:8780 LABRAT_TOKEN=<token>
|
|
98
|
+
labrat describe psu
|
|
99
|
+
labrat shell # an interactive prompt with tab completion
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Connect Claude, or any MCP client, to the same lab:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
claude mcp add labrat -e LABRAT_URL=$LABRAT_URL -e LABRAT_TOKEN=$LABRAT_TOKEN -- labrat mcp
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Every client sends the same message, so curl works too:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
curl -s $LABRAT_URL/api/v1/message -H "Authorization: Bearer $LABRAT_TOKEN" \
|
|
112
|
+
-d '{"op": "set", "device": "psu", "name": "VoltageLevel", "channel": "1", "value": 5}'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Ask your agent
|
|
116
|
+
|
|
117
|
+
With LABRAT connected over MCP, Claude or another agent works the bench the way a person would:
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
Start an experiment called filter-check. Sweep the generator from 1 to 20 MHz in 1 MHz steps, take a scope
|
|
121
|
+
trace at each step, and tell me where the response is 3 dB down.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The agent finds the instruments, locks them, opens an experiment in your folder, runs the sweep and reads its
|
|
125
|
+
own data back. The lab's limits, locks and approvals apply to every request, and every command is logged
|
|
126
|
+
under the agent's token. Give it as much freedom as you want ([MCP](docs/mcp.md)).
|
|
127
|
+
|
|
128
|
+
## The nest and the rats
|
|
129
|
+
|
|
130
|
+
<img alt="" src="docs/assets/rat-dark.svg#gh-dark-mode-only" width="110" align="right">
|
|
131
|
+
<img alt="" src="docs/assets/rat-light.svg#gh-light-mode-only" width="110" align="right">
|
|
132
|
+
|
|
133
|
+
A lab has one **nest** and any number of **rats**. The nest is the server everyone talks to. It holds the
|
|
134
|
+
tokens, the limits, the locks and the audit log. The rats sit at the benches next to the equipment, and each
|
|
135
|
+
one serves whatever is plugged into it. A rat can be any Linux computer, from a single-board computer to the
|
|
136
|
+
PC already beside an instrument, or a microcontroller that speaks the [rat protocol](docs/rat-protocol.md).
|
|
137
|
+
A small lab can run the nest alone, with its devices plugged straight in.
|
|
138
|
+
|
|
139
|
+
```mermaid
|
|
140
|
+
flowchart TB
|
|
141
|
+
clients["<b>clients</b><br/>Python · MATLAB · curl"] -- HTTP --> nest
|
|
142
|
+
agents["<b>AI agents</b><br/>Claude and others"] -- MCP --> nest
|
|
143
|
+
nest["<b>nest</b><br/>central server"]
|
|
144
|
+
nest --> rat1["<b>rat</b> · bench PC<br/>scopes · supplies"]
|
|
145
|
+
nest --> rat2["<b>rat</b> · Raspberry Pi<br/>cameras · SLMs"]
|
|
146
|
+
nest --> rat3["<b>rat</b> · ESP32<br/>relays · sensors"]
|
|
147
|
+
nest --> store[("<b>storage</b><br/>NAS or disk")]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## What it works with
|
|
151
|
+
|
|
152
|
+
| Equipment | Connected by |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| Oscilloscopes, signal and function generators, VNAs, spectrum analysers, power supplies, multimeters, source meters and other bench instruments | Ethernet, USB or RS-232, through their standard SCPI commands |
|
|
155
|
+
| Cameras: USB webcams, PoE and network cameras, machine-vision cameras such as Allied Vision, Basler and FLIR | USB, RTSP, MJPEG, GigE Vision or USB3 Vision |
|
|
156
|
+
| Spatial light modulators, DMDs and projectors | HDMI |
|
|
157
|
+
| Relays, shutters, interlocks, switches and sensors | GPIO pins on a rat |
|
|
158
|
+
| Sensors, ADCs, DACs and port expanders | I2C on a rat |
|
|
159
|
+
| Pumps, stages, controllers and Arduino boards with their own commands | serial, or a serial server on the network |
|
|
160
|
+
| Smart lights and plugs, ESP32 boards and anything on a broker or a web API | MQTT or HTTP |
|
|
161
|
+
| Uninterruptible power supplies | Network UPS Tools |
|
|
162
|
+
| Anything else with a programming interface | a driver of a few dozen lines of Python |
|
|
163
|
+
|
|
164
|
+
A bench instrument needs no code. Its commands go in a few lines of configuration
|
|
165
|
+
([drivers](docs/drivers.md)), and simulated devices let you try everything without hardware.
|
|
166
|
+
|
|
167
|
+
## Use it from
|
|
168
|
+
|
|
169
|
+
| | |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| **Python** | `Client().set("bench-rat/psu", "VoltageLevel", 3.3, channel="1")` ([clients](docs/clients.md#python)) |
|
|
172
|
+
| **MATLAB** | `webwrite` with a bearer token, or [`examples/matlab/labrat.m`](examples/matlab/labrat.m) ([clients](docs/clients.md#matlab)) |
|
|
173
|
+
| **AI agents** | `claude mcp add labrat -- labrat mcp` ([MCP](docs/mcp.md)) |
|
|
174
|
+
| **Anything else** | one HTTP endpoint and JSON ([message API](docs/api.md)) |
|
|
175
|
+
|
|
176
|
+
## Set up a lab
|
|
177
|
+
|
|
178
|
+
| Step | Where | Command |
|
|
179
|
+
| --- | --- | --- |
|
|
180
|
+
| 1 | the server | `sudo ./packaging/install.sh nest` ([install](docs/install.md#the-nest)) |
|
|
181
|
+
| 2 | each bench computer | `sudo ./packaging/install.sh rat` ([install](docs/install.md#a-rat)) |
|
|
182
|
+
| 3 | anywhere | `labrat find` lists the rats on the network |
|
|
183
|
+
| 4 | anywhere | `labrat adopt <rat>` adds one to the nest, with the key the rat shows |
|
|
184
|
+
|
|
185
|
+
Any 64-bit Linux runs a nest or a rat. Good defaults are Ubuntu Server LTS or Debian for the nest, and
|
|
186
|
+
Raspberry Pi OS Lite (64-bit), DietPi or Armbian for rats on single-board computers
|
|
187
|
+
([which computer and which OS](docs/install.md#choosing-hardware-and-an-operating-system)).
|
|
188
|
+
|
|
189
|
+
## Questions
|
|
190
|
+
|
|
191
|
+
**Does it replace PyVISA, LabVIEW or my scripts?** No. LABRAT sits between them and the equipment, so every
|
|
192
|
+
script, notebook and agent sees the same instruments through the same limits and locks. LabVIEW and MATLAB
|
|
193
|
+
talk to it over HTTP.
|
|
194
|
+
|
|
195
|
+
**Do I need a Raspberry Pi?** No. A small lab runs the nest alone on one computer, with its instruments on the
|
|
196
|
+
network or plugged in. Rats are for equipment that is spread over benches or needs local USB, GPIO or I2C.
|
|
197
|
+
|
|
198
|
+
**Is it safe to let an agent drive real equipment?** The guardrails are yours to set: limits on every
|
|
199
|
+
setting, locks, requests that wait for a person, and one stop that puts the whole lab in its safe state. A
|
|
200
|
+
rat that loses the nest does the same by itself.
|
|
201
|
+
|
|
202
|
+
**Is there a web dashboard?** Not yet. The terminal, the Python client and MCP cover everything today, and a
|
|
203
|
+
dashboard will use the same API.
|
|
204
|
+
|
|
205
|
+
**Can two people use the same instrument?** Not at the same time, if they lock it. `labrat lock` makes a
|
|
206
|
+
device yours until you let go, `labrat who` shows who holds what, and `require_lock` makes a lock necessary
|
|
207
|
+
before any change. People are added with `labrat user add`, with no restart.
|
|
208
|
+
|
|
209
|
+
**Where does my data go?** Wherever you point it: a local disk or a NAS, in a folder per person and
|
|
210
|
+
experiment ([experiments](docs/experiments.md)).
|
|
211
|
+
|
|
212
|
+
## Documentation
|
|
213
|
+
|
|
214
|
+
| | |
|
|
215
|
+
| --- | --- |
|
|
216
|
+
| [Architecture](docs/architecture.md) | the nest, rats, messages and how they find each other |
|
|
217
|
+
| [Install](docs/install.md) | hardware, operating systems, the nest and the rats |
|
|
218
|
+
| [Configuration](docs/configuration.md) | `nest.toml`, `rat.toml`, devices, limits and tokens |
|
|
219
|
+
| [Message API](docs/api.md) | every operation, error code and route |
|
|
220
|
+
| [Rat protocol](docs/rat-protocol.md) | what firmware must do to be a rat, for ESP32 and other boards |
|
|
221
|
+
| [Clients](docs/clients.md) | Python, MATLAB, curl, JavaScript and LabVIEW |
|
|
222
|
+
| [MCP](docs/mcp.md) | AI agents through the Model Context Protocol |
|
|
223
|
+
| [Drivers](docs/drivers.md) | the built-in drivers and how to write one |
|
|
224
|
+
| [Recordings](docs/recordings.md) | readings, waveforms and streams written to storage on a schedule |
|
|
225
|
+
| [Experiments](docs/experiments.md) | each person's work in their own folder, with its commands, settings, notes and recordings |
|
|
226
|
+
| [Names and selectors](docs/naming.md) | ids, identities, the standard kinds, and finding devices by type, maker or serial |
|
|
227
|
+
| [Safety and security](docs/safety.md) | limits, safe states, the watchdog, tokens and the network |
|
|
228
|
+
| [Roadmap](docs/roadmap.md) | what comes next |
|
|
229
|
+
|
|
230
|
+
## Contributing
|
|
231
|
+
|
|
232
|
+
Drivers, client libraries, documentation and bug reports are all welcome. [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
233
|
+
explains the workflow and the house rules. A maintainer reviews every pull request, with an automated review
|
|
234
|
+
as advice on branches of this repository. Report security issues privately, as [SECURITY.md](SECURITY.md) describes.
|
|
235
|
+
|
|
236
|
+
## Licence
|
|
237
|
+
|
|
238
|
+
LABRAT is released under the [Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/labrat-dark.svg">
|
|
4
|
+
<img alt="LABRAT, Remote Automated Testing" src="docs/assets/labrat-light.svg" width="600">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<h3 align="center">A universal interface for lab automation</h3>
|
|
9
|
+
|
|
10
|
+
<p align="center"><i>Let the rat run the maze.</i></p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
Control oscilloscopes, signal generators, VNAs, spectrum analysers, power supplies, cameras and more through one API.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://github.com/reinhardjvv/labrat/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/reinhardjvv/labrat/actions/workflows/ci.yml/badge.svg"></a>
|
|
18
|
+
<a href="LICENSE"><img alt="Licence" src="https://img.shields.io/badge/licence-Apache--2.0-blue"></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
> [!NOTE]
|
|
22
|
+
> LABRAT is in early development. The message API and the configuration may still change before 1.0, and
|
|
23
|
+
> each change is listed in the [changelog](CHANGELOG.md).
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="#quick-start"><b>Quick start</b></a> ·
|
|
27
|
+
<a href="docs/install.md"><b>Install</b></a> ·
|
|
28
|
+
<a href="docs/api.md"><b>API</b></a> ·
|
|
29
|
+
<a href="docs/mcp.md"><b>MCP</b></a> ·
|
|
30
|
+
<a href="docs/drivers.md"><b>Drivers</b></a> ·
|
|
31
|
+
<a href="CONTRIBUTING.md"><b>Contributing</b></a>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<picture>
|
|
36
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/terminal-dark.svg">
|
|
37
|
+
<img alt="labrat in a terminal: the devices, a voltage set, a supply described with its live values and limits, a refused value, and stop" src="docs/assets/terminal-light.svg" width="100%">
|
|
38
|
+
</picture>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pipx install git+https://github.com/reinhardjvv/labrat.git
|
|
45
|
+
labrat demo # start a demo lab with simulated instruments
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
In a second terminal, with the token the demo prints:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
export LABRAT_URL=http://127.0.0.1:8780 LABRAT_TOKEN=<token>
|
|
52
|
+
labrat describe psu
|
|
53
|
+
labrat shell # an interactive prompt with tab completion
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Connect Claude, or any MCP client, to the same lab:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
claude mcp add labrat -e LABRAT_URL=$LABRAT_URL -e LABRAT_TOKEN=$LABRAT_TOKEN -- labrat mcp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Every client sends the same message, so curl works too:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
curl -s $LABRAT_URL/api/v1/message -H "Authorization: Bearer $LABRAT_TOKEN" \
|
|
66
|
+
-d '{"op": "set", "device": "psu", "name": "VoltageLevel", "channel": "1", "value": 5}'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Ask your agent
|
|
70
|
+
|
|
71
|
+
With LABRAT connected over MCP, Claude or another agent works the bench the way a person would:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
Start an experiment called filter-check. Sweep the generator from 1 to 20 MHz in 1 MHz steps, take a scope
|
|
75
|
+
trace at each step, and tell me where the response is 3 dB down.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The agent finds the instruments, locks them, opens an experiment in your folder, runs the sweep and reads its
|
|
79
|
+
own data back. The lab's limits, locks and approvals apply to every request, and every command is logged
|
|
80
|
+
under the agent's token. Give it as much freedom as you want ([MCP](docs/mcp.md)).
|
|
81
|
+
|
|
82
|
+
## The nest and the rats
|
|
83
|
+
|
|
84
|
+
<img alt="" src="docs/assets/rat-dark.svg#gh-dark-mode-only" width="110" align="right">
|
|
85
|
+
<img alt="" src="docs/assets/rat-light.svg#gh-light-mode-only" width="110" align="right">
|
|
86
|
+
|
|
87
|
+
A lab has one **nest** and any number of **rats**. The nest is the server everyone talks to. It holds the
|
|
88
|
+
tokens, the limits, the locks and the audit log. The rats sit at the benches next to the equipment, and each
|
|
89
|
+
one serves whatever is plugged into it. A rat can be any Linux computer, from a single-board computer to the
|
|
90
|
+
PC already beside an instrument, or a microcontroller that speaks the [rat protocol](docs/rat-protocol.md).
|
|
91
|
+
A small lab can run the nest alone, with its devices plugged straight in.
|
|
92
|
+
|
|
93
|
+
```mermaid
|
|
94
|
+
flowchart TB
|
|
95
|
+
clients["<b>clients</b><br/>Python · MATLAB · curl"] -- HTTP --> nest
|
|
96
|
+
agents["<b>AI agents</b><br/>Claude and others"] -- MCP --> nest
|
|
97
|
+
nest["<b>nest</b><br/>central server"]
|
|
98
|
+
nest --> rat1["<b>rat</b> · bench PC<br/>scopes · supplies"]
|
|
99
|
+
nest --> rat2["<b>rat</b> · Raspberry Pi<br/>cameras · SLMs"]
|
|
100
|
+
nest --> rat3["<b>rat</b> · ESP32<br/>relays · sensors"]
|
|
101
|
+
nest --> store[("<b>storage</b><br/>NAS or disk")]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## What it works with
|
|
105
|
+
|
|
106
|
+
| Equipment | Connected by |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| Oscilloscopes, signal and function generators, VNAs, spectrum analysers, power supplies, multimeters, source meters and other bench instruments | Ethernet, USB or RS-232, through their standard SCPI commands |
|
|
109
|
+
| Cameras: USB webcams, PoE and network cameras, machine-vision cameras such as Allied Vision, Basler and FLIR | USB, RTSP, MJPEG, GigE Vision or USB3 Vision |
|
|
110
|
+
| Spatial light modulators, DMDs and projectors | HDMI |
|
|
111
|
+
| Relays, shutters, interlocks, switches and sensors | GPIO pins on a rat |
|
|
112
|
+
| Sensors, ADCs, DACs and port expanders | I2C on a rat |
|
|
113
|
+
| Pumps, stages, controllers and Arduino boards with their own commands | serial, or a serial server on the network |
|
|
114
|
+
| Smart lights and plugs, ESP32 boards and anything on a broker or a web API | MQTT or HTTP |
|
|
115
|
+
| Uninterruptible power supplies | Network UPS Tools |
|
|
116
|
+
| Anything else with a programming interface | a driver of a few dozen lines of Python |
|
|
117
|
+
|
|
118
|
+
A bench instrument needs no code. Its commands go in a few lines of configuration
|
|
119
|
+
([drivers](docs/drivers.md)), and simulated devices let you try everything without hardware.
|
|
120
|
+
|
|
121
|
+
## Use it from
|
|
122
|
+
|
|
123
|
+
| | |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| **Python** | `Client().set("bench-rat/psu", "VoltageLevel", 3.3, channel="1")` ([clients](docs/clients.md#python)) |
|
|
126
|
+
| **MATLAB** | `webwrite` with a bearer token, or [`examples/matlab/labrat.m`](examples/matlab/labrat.m) ([clients](docs/clients.md#matlab)) |
|
|
127
|
+
| **AI agents** | `claude mcp add labrat -- labrat mcp` ([MCP](docs/mcp.md)) |
|
|
128
|
+
| **Anything else** | one HTTP endpoint and JSON ([message API](docs/api.md)) |
|
|
129
|
+
|
|
130
|
+
## Set up a lab
|
|
131
|
+
|
|
132
|
+
| Step | Where | Command |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| 1 | the server | `sudo ./packaging/install.sh nest` ([install](docs/install.md#the-nest)) |
|
|
135
|
+
| 2 | each bench computer | `sudo ./packaging/install.sh rat` ([install](docs/install.md#a-rat)) |
|
|
136
|
+
| 3 | anywhere | `labrat find` lists the rats on the network |
|
|
137
|
+
| 4 | anywhere | `labrat adopt <rat>` adds one to the nest, with the key the rat shows |
|
|
138
|
+
|
|
139
|
+
Any 64-bit Linux runs a nest or a rat. Good defaults are Ubuntu Server LTS or Debian for the nest, and
|
|
140
|
+
Raspberry Pi OS Lite (64-bit), DietPi or Armbian for rats on single-board computers
|
|
141
|
+
([which computer and which OS](docs/install.md#choosing-hardware-and-an-operating-system)).
|
|
142
|
+
|
|
143
|
+
## Questions
|
|
144
|
+
|
|
145
|
+
**Does it replace PyVISA, LabVIEW or my scripts?** No. LABRAT sits between them and the equipment, so every
|
|
146
|
+
script, notebook and agent sees the same instruments through the same limits and locks. LabVIEW and MATLAB
|
|
147
|
+
talk to it over HTTP.
|
|
148
|
+
|
|
149
|
+
**Do I need a Raspberry Pi?** No. A small lab runs the nest alone on one computer, with its instruments on the
|
|
150
|
+
network or plugged in. Rats are for equipment that is spread over benches or needs local USB, GPIO or I2C.
|
|
151
|
+
|
|
152
|
+
**Is it safe to let an agent drive real equipment?** The guardrails are yours to set: limits on every
|
|
153
|
+
setting, locks, requests that wait for a person, and one stop that puts the whole lab in its safe state. A
|
|
154
|
+
rat that loses the nest does the same by itself.
|
|
155
|
+
|
|
156
|
+
**Is there a web dashboard?** Not yet. The terminal, the Python client and MCP cover everything today, and a
|
|
157
|
+
dashboard will use the same API.
|
|
158
|
+
|
|
159
|
+
**Can two people use the same instrument?** Not at the same time, if they lock it. `labrat lock` makes a
|
|
160
|
+
device yours until you let go, `labrat who` shows who holds what, and `require_lock` makes a lock necessary
|
|
161
|
+
before any change. People are added with `labrat user add`, with no restart.
|
|
162
|
+
|
|
163
|
+
**Where does my data go?** Wherever you point it: a local disk or a NAS, in a folder per person and
|
|
164
|
+
experiment ([experiments](docs/experiments.md)).
|
|
165
|
+
|
|
166
|
+
## Documentation
|
|
167
|
+
|
|
168
|
+
| | |
|
|
169
|
+
| --- | --- |
|
|
170
|
+
| [Architecture](docs/architecture.md) | the nest, rats, messages and how they find each other |
|
|
171
|
+
| [Install](docs/install.md) | hardware, operating systems, the nest and the rats |
|
|
172
|
+
| [Configuration](docs/configuration.md) | `nest.toml`, `rat.toml`, devices, limits and tokens |
|
|
173
|
+
| [Message API](docs/api.md) | every operation, error code and route |
|
|
174
|
+
| [Rat protocol](docs/rat-protocol.md) | what firmware must do to be a rat, for ESP32 and other boards |
|
|
175
|
+
| [Clients](docs/clients.md) | Python, MATLAB, curl, JavaScript and LabVIEW |
|
|
176
|
+
| [MCP](docs/mcp.md) | AI agents through the Model Context Protocol |
|
|
177
|
+
| [Drivers](docs/drivers.md) | the built-in drivers and how to write one |
|
|
178
|
+
| [Recordings](docs/recordings.md) | readings, waveforms and streams written to storage on a schedule |
|
|
179
|
+
| [Experiments](docs/experiments.md) | each person's work in their own folder, with its commands, settings, notes and recordings |
|
|
180
|
+
| [Names and selectors](docs/naming.md) | ids, identities, the standard kinds, and finding devices by type, maker or serial |
|
|
181
|
+
| [Safety and security](docs/safety.md) | limits, safe states, the watchdog, tokens and the network |
|
|
182
|
+
| [Roadmap](docs/roadmap.md) | what comes next |
|
|
183
|
+
|
|
184
|
+
## Contributing
|
|
185
|
+
|
|
186
|
+
Drivers, client libraries, documentation and bug reports are all welcome. [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
187
|
+
explains the workflow and the house rules. A maintainer reviews every pull request, with an automated review
|
|
188
|
+
as advice on branches of this repository. Report security issues privately, as [SECURITY.md](SECURITY.md) describes.
|
|
189
|
+
|
|
190
|
+
## Licence
|
|
191
|
+
|
|
192
|
+
LABRAT is released under the [Apache License 2.0](LICENSE).
|