Skip to content

refactor: auto-simulate datasets with al.util.dataset.simulate_if_needed - #612

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/pyautoarray-simulate-helper-yuqd16
Nov 1, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
claude/pyautoarray-simulate-helper-yuqd16

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Part of PyAutoLabs/autogalaxy_workspace#268 (phase 3 of PyAutoLabs/PyAutoArray#669).

Merge only after the PyAutoArray release that carries PyAutoLabs/PyAutoArray#670. The scripts call al.util.dataset.simulate_if_needed, which released PyAutoArray doesn't have yet.

Overlap: the Mind task magnification-errors-source-science also claims this repo. Its branch isn't on GitHub, so overlap couldn't be checked. If it touches the same auto-simulate blocks, whichever merges second takes a small rebase.

Summary

Replaces the 8-line should_simulate + subprocess.run auto-simulate block with the one-line helper in 246 scripts (253 blocks):

al.util.dataset.simulate_if_needed(
    dataset_path, simulator="scripts/imaging/simulator.py"
)
  • The rewrite is mechanical and done with an AST matcher, so it only touches the exact standard block. Dataset and simulator paths are kept exactly. A redundant str(...) around the path is dropped because the helper calls str() itself. Behaviour is unchanged: the simulator still runs as a sys.executable subprocess with check=True.
  • The 246 matching notebooks were regenerated with PyAutoHands generate.py autolens --assistant-root <autolens_assistant>.
    • The generator also refreshed the Colab assistant context in 29 notebooks, because the assistant's text has changed since the last generation. I reverted that: 5 notebooks changed only in that context and are dropped from the PR, and the other 24 kept their existing context line.
    • Each remaining notebook diff is only this rewrite. The context refresh is left for the next normal regeneration.

Testing

  • Every inserted call is identical to black's output, all changed scripts compile, and scripts/check_sizes.sh reports no shrinkage.
  • check_dataset_allowlist: 256 guarded call sites before and 256 after; the leg-2 capped-deletion check passes over the 56 committed dataset files.
  • Smoke runs, using the smoke profile against released autolens with merged PyAutoArray main: imaging/fit.py and imaging/modeling.py passed, simulating their datasets through the helper.

Not changed

These are non-standard, so they were left as they are:

  • scripts/group/features/multi_gaussian_expansion/simulator.py:55
  • scripts/guides/mappings.py:145, which simulates inline.
  • scripts/cluster/likelihood_function.py, which only mentions should_simulate in text.

Merge mode: human /prm, after the release.


Generated by Claude Code

Replace the 8-line should_simulate + subprocess.run block with the
one-line util.dataset.simulate_if_needed(dataset_path, simulator=...)
helper (PyAutoArray#670): 253 blocks in 246 scripts. Mechanical rewrite:
dataset and simulator paths kept exactly; a redundant str(...) around
the path is dropped because the helper str()s it. Non-standard blocks
are untouched.

246 notebooks regenerated with PyAutoHands generate.py autolens
--assistant-root autolens_assistant; unrelated Colab-context refreshes and
unicode-escaping noise from the generator were reverted, so each
notebook diff is only this rewrite.

check_dataset_allowlist reports the same guarded call-site count before
and after. Requires the PyAutoArray release that carries #670.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016nhQ8NyQo2s3YUk8eUrrB3
@Jammy2211
Jammy2211 merged commit 2b01824 into main Nov 1, 2026
8 checks passed
@Jammy2211
Jammy2211 deleted the claude/pyautoarray-simulate-helper-yuqd16 branch November 1, 2026 20:50
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