Repository navigation
fix(theory): overwrite stale symlinks and fix eko loop in inherit_ekos (#264) - #265
ashishsoni-ai wants to merge 3 commits into
Conversation
felixhekhorn
left a comment
There was a problem hiding this comment.
LGTM - let's wait for a second review
| return | ||
| eko_filename.unlink() | ||
| if not self.prepare_path(eko_filename, "operator"): | ||
| return |
There was a problem hiding this comment.
I think this needs to be a continue just like in inherit_eko.
Let's say there are two EKO's needed and one already exists, it will silently skip recomputing the second one.
There was a problem hiding this comment.
Good catch, thank you @jekoorn! Updated line 432 to continue so subsequent EKOs in
ames are not skipped when an earlier one already exists. Added est_eko_multiple_names_continue in ests/test_theory.py to verify this.
| mock_new.symlink_to.assert_called_once_with(grid) | ||
|
|
||
|
|
||
| def test_inherit_grid_stale_symlink(builder, tmp_path): |
There was a problem hiding this comment.
are we ok in general with doing mock tests?
Also, it assers now unlink.assert_called_once(). But the bug wasn't "unlink wasn't called", it was symlink_to() raising an error. the mock just passes over the actual symptom and checks a proxy for it.
I think we should od it the same way in other tests, where a fake grid is called rather than a unittest.mock
There was a problem hiding this comment.
Completely agree @jekoorn. Checking unlink.assert_called_once() was indeed only testing a proxy rather than the actual failure mode (symlink_to() raising FileExistsError).
In 2a7a288:
- Replaced
unittest.mock.MagicMockwithFakeSymlinkPath: itssymlink_to()directly reproduces OS behavior by raisingFileExistsErrorif called while the destination still exists or is a stale symlink (unlessunlink()was called first). - Added end-to-end filesystem tests on
tmp_path(test_inherit_grid_real_filesystemandtest_inherit_eko_real_filesystem) that create actual stale symlinks on disk and verify thatprepare_path()cleanly clears them sosymlink_to()succeeds without error (guarded by a runtime symlink capability probe so they execute fully in Linux CI). - Added
test_eko_multiple_names_continueto test loop continuation inTheoryBuilder.eko().
|
Thanks @felixhekhorn! Sounds good, standing by for the second review. |
|
note that a second review has appeared |
…vior - In TheoryBuilder.eko, change return to continue when prepare_path returns False, ensuring subsequent EKOs for the grid are not skipped if an earlier EKO already exists. - In tests/test_theory.py, replace MagicMock with FakeSymlinkPath simulating actual FileExistsError on unhandled symlink_to, and add real filesystem tests on tmp_path. - Add test_eko_multiple_names_continue verifying the continue behavior in eko().
|
Updated in 2a7a288:
Ready for review! @felixhekhorn @jekoorn |
Closes #264
Summary
In
TheoryBuilder.inherit_ekosandTheoryBuilder.inherit_grids,new.exists()returnsFalsewhen pointing to a stale/broken symlink. This causesnew.unlink()to be bypassed andnew.symlink_to(...)to fail withFileExistsError.Changes
src/pineko/theory.py:if new.is_symlink() and not new.exists():) ininherit_grid,inherit_eko, andekobefore linking.inherit_eko, changereturntocontinuewhen skipping an existing EKO so subsequent EKOs for the grid are not skipped.tests/test_theory.py:inherit_gridandinherit_ekocovering new links, existing links (with and without--overwrite), stale symlinks, and multi-EKO loop continuation.Verification
black --check src/pineko/theory.py tests/test_theory.py: cleanflake8 tests/test_theory.py: clean (0 issues)pytest tests/test_theory.py: 9 passed (100%)AI Usage