Skip to content

fix(bh): write the minimum before its state_table row - #866

Merged
HaoZeke merged 2 commits into
TheochemUI:developfrom
HaoZeke:fix/bh-state-write-order
Oct 31, 2026
Merged

HaoZeke merged 2 commits into
TheochemUI:developfrom
HaoZeke:fix/bh-state-write-order

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

A driver killed after the state_table write and before minimum.con left a row with no geometry, and every later pass aborted on it.
The pool draw failed with FileNotFoundError and an energy match failed with OSError.
EON r2549 writes in this order too.

add_state now writes states/<n>/ first, each file through io.atomic_write, and then adds the row.
A kill now leaves at worst a directory with no row, and the next new minimum takes that number and overwrites its files.
Output of a pass that is not interrupted does not change, and no config key or default changes.

tests/test_basin_hop_states.py kills a pass right after the first table write and checks that the next pass can draw and match.
It also checks that a state directory left without a row is replaced by the next add_state.
The first two tests fail on develop and pass here.

add_state appends the new row to state_table before it writes
states/<n>/minimum.con. A driver killed between the two leaves a row
with no geometry. The next pass then fails on the pool draw with
FileNotFoundError and on an energy match with OSError, and so does
every pass after it.

Simulate the kill by raising right after the first table write, and
check that the following pass can draw and match. Also check that a
state directory left without a row is replaced by the next add_state.
A driver killed after the state_table write and before minimum.con
left a row with no geometry, and every later pass aborted on it.
EON r2549 writes in this order too.

Write states/<n>/ first, each file through io.atomic_write, then add
the row. A kill now leaves at worst a directory with no row, and the
next new minimum takes that number and overwrites its files. Output
of a pass that is not interrupted does not change.
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@HaoZeke
HaoZeke merged commit d5f9c53 into TheochemUI:develop Oct 31, 2026
28 checks passed
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.

1 participant