rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
ycAlphi/dsh-labscript
DeepSeek Harness plugin for labscript-suite: runmanager panel read/write, engage + wait, YAML fixed-operation protocols with postprocess write-back, panel snapshots/restore, hard limits, and per-shot HDF5 analysis.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:ycAlphi/dsh-labscript
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Control a labscript-suite experiment from DeepSeek Harness (DSH).
The plugin exposes the stock labscript control surface only: the runmanager remote API (panel globals, n_shots, engage, abort, run_shots, error_in_globals) plus the shot HDF5 files. It does not require any custom BLACS/lyse patch. Everything lab-specific (analysis, protocols, hard limits) is supplied by configuration.
v0.3.5. The mock-labscript backend, the protocol/postprocess flow and the
snapshot/diagnosis behaviour are covered by node and python tests. A client
configuration page (Plugins page) and a read-only labs_doctor are included. The real
labscript backend is implemented against the stock runmanager remote API but has
not yet been validated on laboratory hardware. Start real-machine work with a
read-only status call, then a single-key write/restore, then a few shots.
Install the npm package dsh-labscript (add it to the DSH profile
dependencies and run pnpm install), or clone this repository and use a
link: dependency for local development. docs/INSTALL.zh.md walks through both. The backend defaults to
mock-labscript; real hardware is only used when the config sets
backend: labscript explicitly. Connection settings can be edited in
Plugins -> dsh-labscript after install (advanced keys stay in the profile
config). Run labs_doctor first if anything looks misconfigured.
| Tool | What it does |
|---|---|
| labs_doctor | Read-only configuration diagnostic: python, numpy/h5py, labscript/runmanager, paths, approval, versions. |
| labs_status | Read the panel: labscript, globals, n_shots, error_in_globals, run_shots, shuffle, pending run progress, snapshot directory |
| labs_set | Write panel globals (or raw expressions, or the repetition counter). Snapshots the panel first, then reports unchanged keys, the axes left in place and any axis it did not touch. Does not run. |
| labs_engage | Submit the current panel as one sequence (shot files to BLACS); returns immediately with n_shots_at_submit and expected_n_shots. Refuses over run_limits.maxTotalShots |
| labs_wait | Wait (blocking, with timeout) for the pending run; finalizes a pending protocol: postprocess, finish write-back, restore |
| labs_abort | Abort the current submission |
| labs_data | Read the run folder HDF5: first-shot globals, executed vs shot-file count, the real expansion structure (outer/zip axes) and, with scan, a per-shot table |
| labs_protocol | list / show / run YAML fixed-operation protocols; show prints the postprocess and finish write-back plan before the run |
| labs_restore | Restore the panel from the latest snapshot taken before a write |
A runtime skill named labscript carries the workflow rules (status first, fixed protocols for stable flows, submit then end the turn, one run at a time, never guess panel state).
name: demo_scan
labscript: /path/to/your/sequence.py # or: joint_script: registry_key
set:
do_acquire: true
amplitude: 0.5
scan:
duration_test_us: np.linspace(0.0, 8.0, 5) # expression, number or list
reps: 2
postprocess: demo.peaks # entry configured once
finish:
restore: true
panel:
duration_test_us: fit.center # written back to the panel
history:
demo.peaks.center_us: fit.center # appended to the calibration jsonl
labs_protocol show demo_scan # validates the plan and hard limits
labs_protocol run demo_scan # set + scan + reps + engage, returns immediately
labs_wait # waits, then postprocess -> finish -> restore
postprocess.entry is called as analyze(run_folder, scan_global, reps, name); when the
function accepts it, scan_globals=[...] (every axis, in order) is passed as well, so a 2D
scan is not limited to its first axis. A finish value that is missing or not a number is
reported as skipped and printed by labs_wait instead of being dropped silently.
Add one row to your DSH profile patch (see examples/config.example.yml):
- id: dsh-labscript
name: dsh-labscript
config:
python: /path/to/labscript-suite/python
backend: labscript
# runmanager: { host: 127.0.0.1, port: 42523, timeoutS: 10 } # optional; labconfig otherwise
protocolsDir: /path/to/protocols
scriptsFile: /path/to/scripts.json
hardLimitsFile: /path/to/hard_limits.json
calibrationLog: /path/to/calibration.jsonl
pathMap:
- { remotePrefix: "E:/Experiments", localPrefix: "//lab-pc/Experiments" }
reps: { global: dummy_iterator }
postprocess:
entry: my_lab.analysis:analyze
pythonPaths: [/path/to/my_lab]
approval: { engage: true, protocolRun: true }
pathMap rewrites paths reported by runmanager (remote drive letters such as
E:/Experiments) into paths this machine can open (UNC shares). Tool output is
already mapped: labs_status, labs_engage, labs_wait, labs_data and
labs_protocol show local paths, while run_folder keeps the raw runmanager
value next to mapped_run_folder.
runmanager may be omitted: host, port and timeout then come from labscript's labconfig
([servers] runmanager, [ports] runmanager — default 42523 — and
[timeouts] communication_timeout — default 60 s), the same way runmanager.remote.Client
resolves them. Configured values override labconfig. The Plugins page leaves host/port blank
for that reason; typing them pins them. The DSH-side bridge budget (requestTimeoutMs,
default 180 s) stays above that timeout, so a slow RPC is not cut short by the host.
engage controls how a submitted run is watched: timeoutS (default 900) is the
total wait budget of one labs_wait, noShotS (default 25) makes the wait return
early with a diagnosis when no shot appeared, staleS (default 180) drops a pending
submission that never produced a single shot, pollS, settleS and stallS tune the
polling and the compiled-not-executed detection.
engage: { timeoutS: 900, noShotS: 25, staleS: 180, stallS: 20 }
The python interpreter must be able to import numpy and h5py; the real backend also needs runmanager (labscript-suite). The plugin never stores credentials: zprocess authentication is read by labscript itself from labconfig.
backend: mock-labscript
runs a built-in simulator (fake panel, fake HDF5, persistent state under mock.stateDir). It exists for tests, examples and hardware-free development; it is not a physics simulation.
git clone <this repo> && cd dsh-labscript
npm install
# add "dsh-labscript": "link:/path/to/dsh-labscript" to the profile package.json
# add the bundle name and the cordis.patch.yml row; restart DSH
npm install # only runtime dependency: yaml
npm test # node --test, 55 tests (fake bridge, no python needed)
python python/tests/run_tests.py # 44 tests (needs numpy + h5py)
LABSCRIPT_PYTHON=/path/to/python3 node scripts/demo.mjs # end-to-end mock demo
A fresh clone must run npm install before npm test; the CI workflow does this.
The plugin uses short names; the labscript suite uses its own. Both describe the same objects, and the field names are unchanged:
| plugin | labscript suite |
|---|---|
run folder, run_folder |
shot output folder (one sequence's shot files) |
| run, engage | one sequence: one shot file per point in the parameter space |
shot h5, n_h5 |
shot file (.h5) |
| scan, scan axis | parameter space, axis, expansion (none/outer/zip group/auto) |
n_executed |
shots that acquired data (images/, results/) |
| postprocess | lyse single-shot / multi-shot routine |
n_shots is the authoritative shot count. The reported scan axes and
n_shots_from_arrays are a heuristic: runmanager expands list/array globals but passes
tuples through unwrapped, and an expansion setting of none turns an array back into a
non-axis; neither is visible through the remote API. When the two numbers disagree,
n_shots wins and the difference is reported as such.labs_status reports shuffle. With shuffle on, shot order is not axis order, so each
shot's parameters must be read from its own h5 globals.runmanager.remote has no interface for it and nothing is written to a log file. The plugin
therefore reports that no shot file appeared and asks for the tab to be pasted, instead of
guessing why compilation failed.images/ and results/ are written only
after execution, which is what n_executed counts. BLACS can keep a shot out of its queue
(its connection table must be a subset of the lab connection table) or put it back at the head
after a device programming timeout, and BLACS Repeat all / Repeat last re-runs completed shots
without creating new files; none of that is visible to the plugin.Development note: implemented with assistance from a DeepSeek Harness coding agent.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek。