Skip to content

Accept an open h5py.File in ConnectionTable - #142

Merged
chrisjbillington merged 1 commit into
masterfrom
connection-table-open-file
Oct 25, 2026
Merged

chrisjbillington merged 1 commit into
masterfrom
connection-table-open-file

Conversation

@chrisjbillington

Copy link
Copy Markdown
Member

Written by Claude. This pull request and the commit it describes were produced by
Claude, the AI model, in a Claude Code session that @chrisjbillington is running
for labscript suite maintenance. It is posted from his account; the commit is
authored as Claude.

ConnectionTable() now accepts an open h5py.File as well as a path. When BLACS receives a shot, it opens the shot file once to read the connection table and again to read the rest of what it needs. Each open costs a zlock round trip. With this change, BLACS can do both with one open (a blacs pull request that uses this follows).

A ConnectionTable made from the open file of a shot has the same file path, table and master pseudoclock as one made from the path, and the two compare equal. The file is still open afterwards. An end-to-end test that installs the suite, compiles the example experiment, loads the shot in lyse and runviewer, and starts BLACS, runmanager, runviewer and lyse passed on Ubuntu and Windows for Python 3.11 to 3.14 with PySide6, PyQt6 and PyQt5 (run 40129941950).

馃 Generated with Claude Code

https://claude.ai/code/session_01LrFdivpj4fx9MNAuXvB7Y9

ConnectionTable(h5file) takes either the path of an HDF5 file, as before,
or an open h5py.File, which it reads and leaves open. BLACS can then
check a submitted shot's connection table and read the rest of what it
needs from the shot file with one open, instead of two, each of which
costs a zlock round trip.

A ConnectionTable made from an open file of a shot has the same
filepath, table and master pseudoclock as one made from its path, and
the two compare equal; the file is still open afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LrFdivpj4fx9MNAuXvB7Y9
@chrisjbillington
chrisjbillington merged commit e740ded into master Oct 25, 2026
1 check passed
chrisjbillington pushed a commit that referenced this pull request Oct 25, 2026
ConnectionTable treated its argument as a path if it was a str, bytes or
os.PathLike, and as an open file otherwise. get_shot_globals makes the
opposite test: an h5py.File is used as it is, and anything else is opened
as a path. ConnectionTable now makes the same test as get_shot_globals,
reads the file in one `with` block over either the open file or a newly
opened one, and uses the stored file path in its log and error messages.
The os import is no longer used and is removed.

Verified on a compiled example shot: ConnectionTables made from the path
as a string, from the path as a pathlib.Path and from an open h5py.File
have equal raw tables, equal connections, the same file path and master
pseudoclock, and compare_to reports no differences between them. The open
file is still open afterwards, including when it has no connection table
and the constructor raises, and the log messages name the file.

Follows up #142.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RikqmNDkEBd3S1NrmVw9LU
Claude-Session: https://claude.ai/code/session_01BM9Q7PRz2tohMTMZZkMsKe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants