Skip to content

fix: Aggregator.from_directory test-mode-aware (interpolate tutorial IndexError)#1402

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/interpolator-aggregator-test-mode
Jul 21, 2026
Merged

fix: Aggregator.from_directory test-mode-aware (interpolate tutorial IndexError)#1402
Jammy2211 merged 1 commit into
mainfrom
feature/interpolator-aggregator-test-mode

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

autofit_workspace's features/interpolate.py crashed with IndexError: Cannot interpolate: no instances have been added to the interpolator under test mode (and full-script sweeps). Root cause: under PYAUTO_TEST_MODE searches write results beneath an inserted test_mode segment (output/test_mode/<prefix>, via _test_mode_segment() in non_linear/paths/abstract.py), but Aggregator.from_directory walked only the real-run path the caller points at (output/<prefix>), found nothing, and returned an empty aggregator — the tutorial's database section then interpolated over zero instances.

The in-memory interpolation section already worked; only the aggregator/database section failed, and only under test mode (real user runs are unaffected). This restores the missing symmetry: the aggregator now resolves the test_mode sibling the way searches namespace their output.

Fixes #1401.

API Changes

None affecting real runs — internal test-mode recovery only. The from_directory signature is unchanged and non-test-mode behaviour is byte-for-byte identical. In test mode only, an empty first scan now retries once against the test_mode sibling directory.
See full details below.

Test Plan

  • pytest test_autofit/aggregator/ — 58 pass (incl. 2 new from_directory test-mode tests)
  • pytest test_autofit/aggregator/ test_autofit/interpolator/ — 93 pass, no regressions
  • autofit_workspace/scripts/features/interpolate.py under PYAUTO_TEST_MODE=1 with this branch — exit 0, aggregator loads 3 outputs, interpolation succeeds
Full API Changes (for automation & release notes)

Changed Behaviour

  • autofit.aggregator.Aggregator.from_directory(directory, ...) — when is_test_mode() is active and the first scan of directory yields zero search-outputs, it now retries once against Path(directory).parent / "test_mode" / Path(directory).name if that path exists. Outside test mode, and when the first scan is non-empty, behaviour is unchanged. No signature change; no migration required.

Validation checklist (--auto run — plan was human-approved)

  • Effective level: supervised; the two-level plan (incl. Option A) was human-approved before implementation, not merely written to the issue.
  • Plan: on issue fix: Aggregator.from_directory is not test-mode-aware (interpolate tutorial IndexError) #1401, unmodified since.
  • Gate: tests 58/58 aggregator (93 with interpolator) · smoke n/a (interpolate.py not in the smoke set; validated directly under PYAUTO_TEST_MODE=1) · review CLEAN · Heart RED human-waived — sole RED reason was an unrelated dirty file (PyAutoLens/paper_jax/paper.md WIP), not this change; all YELLOW reasons pre-existing/unrelated.
  • Human: plan sound in hindsight?
  • Human: diff matches plan (no scope creep)?
  • Human: merge, amend, or reject — then log the outcome

Generated by the PyAutoLabs agent workflow.

…rial IndexError)

Under PYAUTO_TEST_MODE searches write their results beneath an inserted
`test_mode` segment (`output/test_mode/<prefix>`) rather than the real-run
location a caller points at (`output/<prefix>`). `Aggregator.from_directory`
walked only the literal directory, found nothing, and returned an empty
aggregator, so the `features/interpolate` tutorial's database section raised
`IndexError: Cannot interpolate: no instances`.

Refactor the directory walk into a nested `scan()` helper and, when the first
scan yields no search-outputs and `is_test_mode()` is active, retry once
against the `test_mode` sibling (`<dir>.parent / "test_mode" / <dir>.name`).
The fallback is a no-op outside test mode and for custom-directory aggregator
scripts (no `test_mode` sibling exists), so real-run behaviour is unchanged.

Fixes #1401.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 21, 2026
@Jammy2211
Jammy2211 merged commit 929b21c into main Jul 21, 2026
5 checks passed
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.

fix: Aggregator.from_directory is not test-mode-aware (interpolate tutorial IndexError)

1 participant