Skip to content

fix: regenerate_notebook resolves the source by relative path, not filename - #263

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/smoke-copy-drift-ci-docs-ozntvv
Aug 24, 2026
Merged

fix: regenerate_notebook resolves the source by relative path, not filename#263
Jammy2211 merged 1 commit into
mainfrom
claude/smoke-copy-drift-ci-docs-ozntvv

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

#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.

The stale-notebook recovery was therefore dead on arrival for real
workspaces: FileNotFoundError, caught, the original FAIL left standing. No
false PASS — but a feature that silently did nothing.

Worse than not finding it, a 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.

The fix

execute_notebook gains notebook_rel; 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 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/ -q391 passed, 5 skipped, 0 failed
  • Both new tests negative-tested: they fail against the old resolution
    and pass against the fix (this repo's stated convention for guard tests)
  • Tenant-firewall gate → OK

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

…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
@Jammy2211
Jammy2211 merged commit e510de1 into main Aug 24, 2026
3 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.

2 participants