fix: regenerate_notebook resolves the source by relative path, not filename - #263
Merged
Merged
Conversation
…lename #261 looked the source script up as `scripts_dir / nb_path.name`, which drops the subdirectory. Every workspace notebook lives in one, so `notebooks/imaging/model_fit.ipynb` searched for `scripts/model_fit.py` instead of `scripts/imaging/model_fit.py` and never found it. The stale-notebook recovery was therefore dead on arrival for real workspaces: FileNotFoundError, caught, original FAIL left standing. No false PASS, but a feature that silently did nothing. Worse than not finding it, the bare filename can find the WRONG one — two `model_fit.ipynb` under different topic folders map to two different scripts, and a same-named script at the scripts root would be picked up for all of them. execute_notebook gains `notebook_rel` and execute_notebooks_in_folder computes it with `file.relative_to(Path.cwd() / directory)`, so the folder runner always passes it. A direct caller that omits it keeps the old bare-filename fallback, which is correct for a notebook at the root. Caught while preparing the phase-2 workspace delegators, not by the existing tests: those used a FLAT fixture (notebook and script both at the root), which is exactly the one layout where the bug is invisible. The two new tests use a nested notebook plus a decoy script at the scripts root, so resolving by filename picks the decoy and fails loudly. Both were negative-tested against the old resolution and fail there. Suite 391 passed, 5 skipped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UpSFum81Jeq9KZ9wdKtaeZ
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#261 looked the source script up as
scripts_dir / nb_path.name, which dropsthe subdirectory. Every workspace notebook lives in one, so
notebooks/imaging/model_fit.ipynbsearched forscripts/model_fit.pyinsteadof
scripts/imaging/model_fit.py.The stale-notebook recovery was therefore dead on arrival for real
workspaces:
FileNotFoundError, caught, the original FAIL left standing. Nofalse PASS — but a feature that silently did nothing.
Worse than not finding it, a bare filename can find the wrong one. Two
model_fit.ipynbunder different topic folders map to two different scripts,and a same-named script at the scripts root would be picked up for all of them.
The fix
execute_notebookgainsnotebook_rel;execute_notebooks_in_foldercomputesit with
file.relative_to(Path.cwd() / directory), so the folder runner alwayspasses it. A direct caller that omits it keeps the old bare-filename fallback,
which is correct for a notebook sitting at the root.
Why the existing tests missed it
They used a flat fixture — notebook and script both at the root — which is
exactly the one layout where this bug is invisible. That is the real lesson
here: the fixture was shaped like the happy path rather than like production.
The two new tests use a nested notebook plus a decoy script at the scripts
root, so resolving by filename picks the decoy and fails loudly rather than
merely not finding anything.
Test Plan
pytest tests/ -q→ 391 passed, 5 skipped, 0 failedand pass against the fix (this repo's stated convention for guard tests)
Found while preparing the phase-2 workspace delegators (PyAutoHands#260), before
any of the three notebook-capable workspaces was touched.
Generated by the PyAutoLabs agent workflow.
Generated by Claude Code