Skip to content

fix: simulators call af.ex.util, and the chain-run resolves in a notebook (PENDING RELEASE) - #42

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/simulator-util-to-af-ex
Aug 3, 2026
Merged

fix: simulators call af.ex.util, and the chain-run resolves in a notebook (PENDING RELEASE)#42
Jammy2211 merged 1 commit into
mainfrom
feature/simulator-util-to-af-ex

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Workspace half of PyAutoLabs/PyAutoFit#1444. PENDING RELEASE — needs the af.ex.util helpers from PyAutoLabs/PyAutoFit#1445 to ship first.

Two failures in the same notebook, the second masked by the first.

1. ModuleNotFoundError: No module named 'util'

notebooks/simulators/simulators.ipynb and simulators_sample.ipynb failed workspace smoke (PyAutoHeart run 30790463134).

scripts/simulators/util.py could only ever be imported by the .py scripts: running one puts scripts/simulators/ on sys.path[0]. A notebook kernel has no script directory — sys.path[0] is the cwd — so the generated notebooks could never import it. Not a cwd bug: import util fails from the notebook's own directory and from the workspace root.

The four simulate helpers now live in af.ex.util, so the same call works from a script, a notebook and Colab alike. scripts/simulators/util.py is deleted along with the util.ipynb it generated.

2. The chain-run cell, found while fixing the first

scripts/simulators/simulators.py ends by chain-running simulators_sample.py so every tutorial's simulator subprocess also produces the chapter-3 sample folders. It resolved that path from the script's own file path — which a notebook kernel does not define, and which points into the notebooks tree where no .py exists in any case.

That cell survives into notebooks/simulators/simulators.ipynb, so it would have failed the instant the import above was fixed — it was simply never reached before. The path is now relative to the repository root, which the script run, the pinned notebook kernel and Colab all share.

Verification

  • Both simulator notebooks execute clean via the same runner smoke uses — including the chain-run cell, confirmed by the chapter-3 sample dataset folders it produces.
  • Both .py siblings pass.
  • run_smoke.py: 10/10 passed.
  • check_navigator.py --banners=fail: OK.
  • Notebooks regenerated with generate.py howtofit (15 scripts); the diff touches only the simulator files plus llms-full.txt / workspace_index.json.

🤖 Generated with Claude Code

…e__ (PyAutoFit#1444)

Two failures in the same notebook, the second masked by the first.

1. scripts/simulators/util.py could only ever be imported by the .py scripts:
   running one puts scripts/simulators/ on sys.path[0], but a notebook kernel
   has no script directory, so both simulator notebooks failed workspace smoke
   with `ModuleNotFoundError: No module named 'util'`. The four helpers now
   live in af.ex.util, so the same call works from a script, a notebook and
   Colab alike. util.py is deleted along with the util.ipynb it generated.

2. simulators.py chain-ran simulators_sample.py through a path derived from the
   script's own file path, which a notebook kernel does not define - and no .py
   exists in the notebooks tree in any case. That cell would have failed the
   instant the import above was fixed. It is now resolved relative to the
   repository root, which the script run, the pinned notebook kernel and Colab
   all share.

PENDING RELEASE: needs the af.ex.util helpers from PyAutoFit#1444.

Verified: both simulator notebooks execute clean (the chain-run cell included),
both .py siblings pass, smoke 10/10, navigator check OK.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 3, 2026
@Jammy2211
Jammy2211 merged commit c1a34c4 into main Aug 3, 2026
9 checks passed
@Jammy2211
Jammy2211 deleted the feature/simulator-util-to-af-ex branch August 3, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant