dsh-labscript 0.2.0 → 0.2.1

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.
package/CHANGELOG.md CHANGED
@@ -1,19 +1,30 @@
1
- # Changelog
2
-
3
- ## 0.2.0
4
-
5
- - Safe default: backend is mock-labscript unless the config explicitly sets labscript.
6
- - labs_abort bypasses the serial queue, so it is never blocked behind labs_wait.
7
- - Pending/last-run state is persisted under DSH_HOME and reloaded after a restart.
8
- - labs_doctor: read-only diagnostic for python, numpy/h5py, labscript/runmanager, paths and versions.
9
- - Minimal Plugins-page configuration page (backend, python, runmanager, protocolsDir) + doctor results.
10
- - Python environment requirements documented per backend.
11
-
12
- ## 0.1.0
13
-
14
- - Eight labs_* tools: status, set, engage, wait, abort, data, protocol, restore.
15
- - Fixed-operation YAML protocols with postprocess write-back and panel restore.
16
- - Panel snapshots before writes plus an events.jsonl action log.
17
- - Built-in mock-labscript backend for tests, examples and hardware-free development.
18
- - Runmanager (labscript) backend built on the stock remote API and shot HDF5.
19
- - Stalled-queue diagnosis, selective panel restore and accurate abort semantics.
1
+ # Changelog
2
+
3
+ ## 0.2.1
4
+
5
+ - Hard limits support a lower bound: limits entries can now use min as well as max
6
+ (panel writes and scan expressions are checked on both sides).
7
+ - Boolean globals can be limited too: true/false count as 1/0, so max: 0 forbids "on"
8
+ and min: 1 requires it.
9
+ - labs_protocol show reports keys that are missing from the currently loaded labscript;
10
+ protocol runs ask for an explicit confirmation on real hardware before proceeding.
11
+ - labs_abort now also stops an in-flight labs_wait, so a running batch can be cancelled
12
+ without waiting for the wait timeout.
13
+
14
+ ## 0.2.0
15
+
16
+ - Safe default: backend is mock-labscript unless the config explicitly sets labscript.
17
+ - labs_abort bypasses the serial queue, so it is never blocked behind labs_wait.
18
+ - Pending/last-run state is persisted under DSH_HOME and reloaded after a restart.
19
+ - labs_doctor: read-only diagnostic for python, numpy/h5py, labscript/runmanager, paths and versions.
20
+ - Minimal Plugins-page configuration page (backend, python, runmanager, protocolsDir) + doctor results.
21
+ - Python environment requirements documented per backend.
22
+
23
+ ## 0.1.0
24
+
25
+ - Eight labs_* tools: status, set, engage, wait, abort, data, protocol, restore.
26
+ - Fixed-operation YAML protocols with postprocess write-back and panel restore.
27
+ - Panel snapshots before writes plus an events.jsonl action log.
28
+ - Built-in mock-labscript backend for tests, examples and hardware-free development.
29
+ - Runmanager (labscript) backend built on the stock remote API and shot HDF5.
30
+ - Stalled-queue diagnosis, selective panel restore and accurate abort semantics.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 dsh-labscript contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-labscript contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,154 +1,161 @@
1
- # dsh-labscript
2
-
3
- Control a [labscript-suite](https://labscriptsuite.org/) experiment from DeepSeek Harness (DSH).
4
-
5
- The plugin exposes the stock labscript control surface only: the runmanager remote API
6
- (panel globals, n_shots, engage, abort, run_shots, error_in_globals) plus the shot HDF5
7
- files. It does not require any custom BLACS/lyse patch. Everything lab-specific
8
- (analysis, protocols, hard limits) is supplied by configuration.
9
-
10
- ## Status
11
-
12
- v0.2.0. The mock-labscript backend, the protocol/postprocess flow and the
13
- snapshot/diagnosis behaviour are covered by node and python tests. A client
14
- configuration page (Plugins page) and a read-only `labs_doctor` are included. The real
15
- labscript backend is implemented against the stock runmanager remote API but has
16
- not yet been validated on laboratory hardware. Start real-machine work with a
17
- read-only status call, then a single-key write/restore, then a few shots.
18
-
19
- ## Requirements
20
-
21
- - DSH >= 0.2 and Node.js ^22.19 or >= 24.
22
- - Python >= 3.9. Mock mode needs only numpy >= 1.23 and h5py >= 3.8; real
23
- hardware needs the labscript-suite Python environment (labscript, runmanager,
24
- labscript_utils, zprocess importable). Tested with Python 3.11.0,
25
- numpy 2.2.5, h5py 3.13.0. The plugin never stores credentials; zprocess
26
- authentication is read by labscript from labconfig.
27
-
28
- ## Install
29
-
30
- Clone this repository, add it as a `link:` dependency in your DSH profile and
31
- `pnpm install`; docs/INSTALL.zh.md walks through it. The backend defaults to
32
- `mock-labscript`; real hardware is only used when the config sets
33
- `backend: labscript` explicitly. Connection settings can be edited in
34
- Plugins -> dsh-labscript after install (advanced keys stay in the profile
35
- config). Run `labs_doctor` first if anything looks misconfigured.
36
-
37
- ## Tools
38
-
39
- | Tool | What it does |
40
- |---|---|
41
- | labs_doctor | Read-only configuration diagnostic: python, numpy/h5py, labscript/runmanager, paths, approval, versions. |
42
- | labs_status | Read the panel: labscript, globals, n_shots, error_in_globals, run_shots, pending run progress, snapshot directory |
43
- | labs_set | Write panel globals (or raw expressions, or the repetition counter). Snapshots the panel first. Does not run. |
44
- | labs_engage | Submit the current panel for a run; returns immediately with n_shots_at_submit and expected_n_shots |
45
- | labs_wait | Wait (blocking, with timeout) for the pending run; finalizes a pending protocol: postprocess, finish write-back, restore |
46
- | labs_abort | Abort the current submission |
47
- | labs_data | Read the run folder HDF5: first-shot globals and, with scan, a per-shot table |
48
- | labs_protocol | list / show / run YAML fixed-operation protocols |
49
- | labs_restore | Restore the panel from the latest snapshot taken before a write |
50
-
51
- A runtime skill named labscript carries the workflow rules (status first, fixed
52
- protocols for stable flows, submit then end the turn, one run at a time, never
53
- guess panel state).
54
-
55
- ## Fixed-operation protocols
56
-
57
- name: demo_scan
58
- labscript: /path/to/your/sequence.py # or: joint_script: registry_key
59
- set:
60
- do_acquire: true
61
- amplitude: 0.5
62
- scan:
63
- duration_test_us: np.linspace(0.0, 8.0, 5) # expression, number or list
64
- reps: 2
65
- postprocess: demo.peaks # entry configured once
66
- finish:
67
- restore: true
68
- panel:
69
- duration_test_us: fit.center # written back to the panel
70
- history:
71
- demo.peaks.center_us: fit.center # appended to the calibration jsonl
72
-
73
- labs_protocol show demo_scan # validates the plan and hard limits
74
- labs_protocol run demo_scan # set + scan + reps + engage, returns immediately
75
- labs_wait # waits, then postprocess -> finish -> restore
76
-
77
- ## Configuration
78
-
79
- Add one row to your DSH profile patch (see examples/config.example.yml):
80
-
81
- - id: dsh-labscript
82
- name: dsh-labscript
83
- config:
84
- python: /path/to/labscript-suite/python
85
- backend: labscript
86
- runmanager: { host: 127.0.0.1, port: 42523, timeoutS: 10 }
87
- protocolsDir: /path/to/protocols
88
- scriptsFile: /path/to/scripts.json
89
- hardLimitsFile: /path/to/hard_limits.json
90
- calibrationLog: /path/to/calibration.jsonl
91
- pathMap:
92
- - { remotePrefix: "E:/Experiments", localPrefix: "//lab-pc/Experiments" }
93
- reps: { global: dummy_iterator }
94
- postprocess:
95
- entry: my_lab.analysis:analyze
96
- pythonPaths: [/path/to/my_lab]
97
- approval: { engage: true, protocolRun: true }
98
-
99
- The python interpreter must be able to import numpy and h5py; the real backend
100
- also needs runmanager (labscript-suite). The plugin never stores credentials:
101
- zprocess authentication is read by labscript itself from labconfig.
102
-
103
- ### Mock backend
104
-
105
- backend: mock-labscript
106
-
107
- runs a built-in simulator (fake panel, fake HDF5, persistent state under
108
- mock.stateDir). It exists for tests, examples and hardware-free development; it
109
- is not a physics simulation.
110
-
111
- ## Install (local)
112
-
113
- git clone <this repo> && cd dsh-labscript
114
- npm install
115
- # add "dsh-labscript": "link:/path/to/dsh-labscript" to the profile package.json
116
- # add the bundle name and the cordis.patch.yml row; restart DSH
117
-
118
- ## Development
119
-
120
- npm install # only runtime dependency: yaml
121
- npm test # node --test, 18 tests (fake bridge, no python needed)
122
- python python/tests/run_tests.py # 8 tests (needs numpy + h5py)
123
- LABSCRIPT_PYTHON=/path/to/python3 node scripts/demo.mjs # end-to-end mock demo
124
-
125
- A fresh clone must run `npm install` before `npm test`; the CI workflow does this.
126
-
127
- ## Docs
128
-
129
- - docs/README.zh.md - Chinese guide
130
- - docs/INSTALL.zh.md - local DSH profile install
131
-
132
- ## Boundaries
133
-
134
- - Real hardware: engage/protocol run ask for a DSH approval (one-shot) when the
135
- backend is labscript; abort and panel writes do not. The plugin is not a
136
- hardware interlock.
137
- - Completion is detected from the run folder on the filesystem (HDF5 count,
138
- stable file sizes, and a readable last shot); stock labscript has no
139
- run-state query.
140
- - Cancelling labs_wait only stops waiting: the run keeps going. Call labs_abort
141
- explicitly when something must stop. labscript abort stops compiling/submitting new
142
- shots; shots already queued in BLACS or running are not stopped.
143
- - labs_wait reports a diagnosis (complete, no_shots, compiling, compiled_not_executed,
144
- partial). compiled_not_executed means shots exist but show no acquisition data yet;
145
- BLACS may be paused or not executing the queue.
146
- - Real runmanager engage does not return a run folder; the bridge captures the
147
- output folder before engage and reports it as the run folder.
148
- - The panel is snapshotted before every write; labs_restore restores only the keys the
149
- write touched (full=true restores the whole panel), so unrelated concurrent edits survive.
150
- - Actions are logged to events.jsonl next to the snapshots.
151
-
152
- ---
153
-
154
- Development note: implemented with assistance from a DeepSeek Harness coding agent.
1
+ # dsh-labscript
2
+
3
+ Control a [labscript-suite](https://labscriptsuite.org/) experiment from DeepSeek Harness (DSH).
4
+
5
+ The plugin exposes the stock labscript control surface only: the runmanager remote API
6
+ (panel globals, n_shots, engage, abort, run_shots, error_in_globals) plus the shot HDF5
7
+ files. It does not require any custom BLACS/lyse patch. Everything lab-specific
8
+ (analysis, protocols, hard limits) is supplied by configuration.
9
+
10
+ ## Status
11
+
12
+ v0.2.0. The mock-labscript backend, the protocol/postprocess flow and the
13
+ snapshot/diagnosis behaviour are covered by node and python tests. A client
14
+ configuration page (Plugins page) and a read-only `labs_doctor` are included. The real
15
+ labscript backend is implemented against the stock runmanager remote API but has
16
+ not yet been validated on laboratory hardware. Start real-machine work with a
17
+ read-only status call, then a single-key write/restore, then a few shots.
18
+
19
+ ## Requirements
20
+
21
+ - DSH >= 0.2 and Node.js ^22.19 or >= 24.
22
+ - Python >= 3.9. Mock mode needs only numpy >= 1.23 and h5py >= 3.8; real
23
+ hardware needs the labscript-suite Python environment (labscript, runmanager,
24
+ labscript_utils, zprocess importable). Tested with Python 3.11.0,
25
+ numpy 2.2.5, h5py 3.13.0. The plugin never stores credentials; zprocess
26
+ authentication is read by labscript from labconfig.
27
+
28
+ ## Install
29
+
30
+ Install the npm package `dsh-labscript` (add it to the DSH profile
31
+ dependencies and run `pnpm install`), or clone this repository and use a
32
+ `link:` dependency for local development. docs/INSTALL.zh.md walks through both. The backend defaults to
33
+ `mock-labscript`; real hardware is only used when the config sets
34
+ `backend: labscript` explicitly. Connection settings can be edited in
35
+ Plugins -> dsh-labscript after install (advanced keys stay in the profile
36
+ config). Run `labs_doctor` first if anything looks misconfigured.
37
+
38
+ ## Tools
39
+
40
+ | Tool | What it does |
41
+ |---|---|
42
+ | labs_doctor | Read-only configuration diagnostic: python, numpy/h5py, labscript/runmanager, paths, approval, versions. |
43
+ | labs_status | Read the panel: labscript, globals, n_shots, error_in_globals, run_shots, pending run progress, snapshot directory |
44
+ | labs_set | Write panel globals (or raw expressions, or the repetition counter). Snapshots the panel first. Does not run. |
45
+ | labs_engage | Submit the current panel for a run; returns immediately with n_shots_at_submit and expected_n_shots |
46
+ | labs_wait | Wait (blocking, with timeout) for the pending run; finalizes a pending protocol: postprocess, finish write-back, restore |
47
+ | labs_abort | Abort the current submission |
48
+ | labs_data | Read the run folder HDF5: first-shot globals and, with scan, a per-shot table |
49
+ | labs_protocol | list / show / run YAML fixed-operation protocols |
50
+ | labs_restore | Restore the panel from the latest snapshot taken before a write |
51
+
52
+ A runtime skill named labscript carries the workflow rules (status first, fixed
53
+ protocols for stable flows, submit then end the turn, one run at a time, never
54
+ guess panel state).
55
+
56
+ ## Fixed-operation protocols
57
+
58
+ name: demo_scan
59
+ labscript: /path/to/your/sequence.py # or: joint_script: registry_key
60
+ set:
61
+ do_acquire: true
62
+ amplitude: 0.5
63
+ scan:
64
+ duration_test_us: np.linspace(0.0, 8.0, 5) # expression, number or list
65
+ reps: 2
66
+ postprocess: demo.peaks # entry configured once
67
+ finish:
68
+ restore: true
69
+ panel:
70
+ duration_test_us: fit.center # written back to the panel
71
+ history:
72
+ demo.peaks.center_us: fit.center # appended to the calibration jsonl
73
+
74
+ labs_protocol show demo_scan # validates the plan and hard limits
75
+ labs_protocol run demo_scan # set + scan + reps + engage, returns immediately
76
+ labs_wait # waits, then postprocess -> finish -> restore
77
+
78
+ ## Configuration
79
+
80
+ Add one row to your DSH profile patch (see examples/config.example.yml):
81
+
82
+ - id: dsh-labscript
83
+ name: dsh-labscript
84
+ config:
85
+ python: /path/to/labscript-suite/python
86
+ backend: labscript
87
+ runmanager: { host: 127.0.0.1, port: 42523, timeoutS: 10 }
88
+ protocolsDir: /path/to/protocols
89
+ scriptsFile: /path/to/scripts.json
90
+ hardLimitsFile: /path/to/hard_limits.json
91
+ calibrationLog: /path/to/calibration.jsonl
92
+ pathMap:
93
+ - { remotePrefix: "E:/Experiments", localPrefix: "//lab-pc/Experiments" }
94
+ reps: { global: dummy_iterator }
95
+ postprocess:
96
+ entry: my_lab.analysis:analyze
97
+ pythonPaths: [/path/to/my_lab]
98
+ approval: { engage: true, protocolRun: true }
99
+
100
+ The python interpreter must be able to import numpy and h5py; the real backend
101
+ also needs runmanager (labscript-suite). The plugin never stores credentials:
102
+ zprocess authentication is read by labscript itself from labconfig.
103
+
104
+ ### Mock backend
105
+
106
+ backend: mock-labscript
107
+
108
+ runs a built-in simulator (fake panel, fake HDF5, persistent state under
109
+ mock.stateDir). It exists for tests, examples and hardware-free development; it
110
+ is not a physics simulation.
111
+
112
+ ## Install (local)
113
+
114
+ git clone <this repo> && cd dsh-labscript
115
+ npm install
116
+ # add "dsh-labscript": "link:/path/to/dsh-labscript" to the profile package.json
117
+ # add the bundle name and the cordis.patch.yml row; restart DSH
118
+
119
+ ## Development
120
+
121
+ npm install # only runtime dependency: yaml
122
+ npm test # node --test, 18 tests (fake bridge, no python needed)
123
+ python python/tests/run_tests.py # 8 tests (needs numpy + h5py)
124
+ LABSCRIPT_PYTHON=/path/to/python3 node scripts/demo.mjs # end-to-end mock demo
125
+
126
+ A fresh clone must run `npm install` before `npm test`; the CI workflow does this.
127
+
128
+ ## Docs
129
+
130
+ - docs/README.zh.md - Chinese guide
131
+ - docs/INSTALL.zh.md - local DSH profile install
132
+
133
+ ## Boundaries
134
+
135
+ - Real hardware: engage/protocol run ask for a DSH approval (one-shot) when the
136
+ backend is labscript; abort and panel writes do not. The plugin is not a
137
+ hardware interlock.
138
+ - Optional hard limits (limits/channels entries with min and/or max, plus
139
+ run_limits) are checked on panel writes and protocol planning; boolean values
140
+ count as 0/1. They are advisory configuration, not a safety interlock.
141
+ - labs_protocol show warns when a set/scan key is missing from the currently loaded
142
+ labscript; protocol runs ask for confirmation before proceeding on real hardware.
143
+ - Completion is detected from the run folder on the filesystem (HDF5 count,
144
+ stable file sizes, and a readable last shot); stock labscript has no
145
+ run-state query.
146
+ - Cancelling labs_wait only stops waiting: the run keeps going. Call labs_abort
147
+ explicitly when something must stop; labs_abort also cancels an in-flight labs_wait.
148
+ labscript abort stops compiling/submitting new shots; shots already queued in BLACS
149
+ or running are not stopped.
150
+ - labs_wait reports a diagnosis (complete, no_shots, compiling, compiled_not_executed,
151
+ partial). compiled_not_executed means shots exist but show no acquisition data yet;
152
+ BLACS may be paused or not executing the queue.
153
+ - Real runmanager engage does not return a run folder; the bridge captures the
154
+ output folder before engage and reports it as the run folder.
155
+ - The panel is snapshotted before every write; labs_restore restores only the keys the
156
+ write touched (full=true restores the whole panel), so unrelated concurrent edits survive.
157
+ - Actions are logged to events.jsonl next to the snapshots.
158
+
159
+ ---
160
+
161
+ Development note: implemented with assistance from a DeepSeek Harness coding agent.
package/cordis.patch.yml CHANGED
@@ -1,6 +1,6 @@
1
- # dsh-labscript -- DSH bundle patch
2
- #
3
- # Declares the plugin row. The "name" must match the installed package name.
4
- - insert:
5
- - id: dsh-labscript
6
- name: dsh-labscript
1
+ # dsh-labscript -- DSH bundle patch
2
+ #
3
+ # Declares the plugin row. The "name" must match the installed package name.
4
+ - insert:
5
+ - id: dsh-labscript
6
+ name: dsh-labscript
@@ -1,54 +1,64 @@
1
- # 安装(DSH desktop profile)
2
-
3
- ## 0. 环境要求
4
-
5
- - DSH >= 0.2,Node.js ^22.19 或 >= 24。
6
- - Python >= 3.9。
7
- - mock 模式:只需 numpy >= 1.23、h5py >= 3.8;
8
- - 真机模式:用 labscript-suite 的 Python 环境(labscript、runmanager、
9
- labscript_utils、zprocess 可导入)。
10
- - 开发时实测:Python 3.11.0、numpy 2.2.5、h5py 3.13.0。
11
-
12
- ## 1. 安装插件
13
-
14
- 把仓库放到本机任意目录(下称 `<repo>`),在 DSH desktop profile 里 link 安装:
15
-
16
- 1. 编辑 `%USERPROFILE%\.dsh\profiles\desktop\package.json`:
17
-
18
- "dependencies": {
19
- ...,
20
- "dsh-labscript": "link:<repo>"
21
- }
22
-
23
- 并在 `dsh.profile.bundles` 里加入 `"dsh-labscript"`。
24
-
25
- 2. 在 profile 目录执行 `pnpm install`,重启 DSH。
26
- 3. 新会话里应出现 9 个 `labs_*` 工具和 `labscript` skill。
27
-
28
- 实验机建议固定 tag:`git checkout v0.2.0` 后再安装,避免 main 变动影响硬件行为。
29
-
30
- ## 2. 配置
31
-
32
- 优先在 DSH 里配置:侧边栏 → 插件 → dsh-labscript,填 backend、python、
33
- runmanager host/port、protocolsDir,保存后下一次工具调用生效(不用重启)。
34
-
35
- 高级配置(scriptsFile、hard limits、postprocess、approval、pathMap、超时等)
36
- 仍写在 profile 的 `cordis.patch.yml`:
37
-
38
- - id: dsh-labscript
39
- name: dsh-labscript
40
- config:
41
- scriptsFile: <path>/scripts.json
42
- hardLimitsFile: <path>/hard_limits.json
43
- postprocess:
44
- entry: my_lab.analysis:analyze
45
- pythonPaths: [<path>/my_lab]
46
- approval: { engage: true, protocolRun: true }
47
-
48
- ## 3. 冒烟顺序
49
-
50
- 1. `labs_doctor`:确认 python/依赖/路径/版本身份;
51
- 2. mock:`labs_status` → `labs_protocol list` → `labs_protocol run demo_scan` → `labs_wait`;
52
- 3. 真机:只读 `labs_status` → 单键 `labs_set` + `labs_restore` → ≤10 shots →
53
- `labs_data` → 一条协议。
54
-
1
+ # 安装(DSH desktop profile)
2
+
3
+ ## 0. 环境要求
4
+
5
+ - DSH >= 0.2,Node.js ^22.19 或 >= 24。
6
+ - Python >= 3.9。
7
+ - mock 模式:只需 numpy >= 1.23、h5py >= 3.8;
8
+ - 真机模式:用 labscript-suite 的 Python 环境(labscript、runmanager、
9
+ labscript_utils、zprocess 可导入)。
10
+ - 开发时实测:Python 3.11.0、numpy 2.2.5、h5py 3.13.0。
11
+
12
+ ## 1. 安装插件
13
+
14
+ ### 方式 A:从 npm 安装(推荐)
15
+
16
+ 在 DSH desktop profile 的 `package.json` 依赖里加:
17
+
18
+ "dsh-labscript": "^0.2.0"
19
+
20
+ 在 profile 目录执行 `pnpm install`,重启 DSH。升级时改版本号再 `pnpm install`。
21
+
22
+ ### 方式 B:本地 link(开发用)
23
+
24
+ 把仓库放到本机任意目录(下称 `<repo>`),在 DSH desktop profile 里 link 安装:
25
+
26
+ 1. 编辑 `%USERPROFILE%\.dsh\profiles\desktop\package.json`:
27
+
28
+ "dependencies": {
29
+ ...,
30
+ "dsh-labscript": "link:<repo>"
31
+ }
32
+
33
+ 并在 `dsh.profile.bundles` 里加入 `"dsh-labscript"`。
34
+
35
+ 2. 在 profile 目录执行 `pnpm install`,重启 DSH。
36
+ 3. 新会话里应出现 9 个 `labs_*` 工具和 `labscript` skill。
37
+
38
+ 实验机建议固定 tag:`git checkout v0.2.0` 后再安装,避免 main 变动影响硬件行为。
39
+
40
+ ## 2. 配置
41
+
42
+ 优先在 DSH 里配置:侧边栏 → 插件 → dsh-labscript,填 backend、python、
43
+ runmanager host/port、protocolsDir,保存后下一次工具调用生效(不用重启)。
44
+
45
+ 高级配置(scriptsFile、hard limits、postprocess、approval、pathMap、超时等)
46
+ 仍写在 profile 的 `cordis.patch.yml`:
47
+
48
+ - id: dsh-labscript
49
+ name: dsh-labscript
50
+ config:
51
+ scriptsFile: <path>/scripts.json
52
+ hardLimitsFile: <path>/hard_limits.json
53
+ postprocess:
54
+ entry: my_lab.analysis:analyze
55
+ pythonPaths: [<path>/my_lab]
56
+ approval: { engage: true, protocolRun: true }
57
+
58
+ ## 3. 冒烟顺序
59
+
60
+ 1. `labs_doctor`:确认 python/依赖/路径/版本身份;
61
+ 2. mock:`labs_status` → `labs_protocol list` → `labs_protocol run demo_scan` → `labs_wait`;
62
+ 3. 真机:只读 `labs_status` → 单键 `labs_set` + `labs_restore` → ≤10 shots →
63
+ `labs_data` → 一条协议。
64
+