fix: Aggregator.from_directory test-mode-aware (interpolate tutorial IndexError)#1402
Merged
Merged
Conversation
…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>
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
autofit_workspace'sfeatures/interpolate.pycrashed withIndexError: Cannot interpolate: no instances have been added to the interpolatorunder test mode (and full-script sweeps). Root cause: underPYAUTO_TEST_MODEsearches write results beneath an insertedtest_modesegment (output/test_mode/<prefix>, via_test_mode_segment()innon_linear/paths/abstract.py), butAggregator.from_directorywalked 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_modesibling the way searches namespace their output.Fixes #1401.
API Changes
None affecting real runs — internal test-mode recovery only. The
from_directorysignature is unchanged and non-test-mode behaviour is byte-for-byte identical. In test mode only, an empty first scan now retries once against thetest_modesibling directory.See full details below.
Test Plan
pytest test_autofit/aggregator/— 58 pass (incl. 2 newfrom_directorytest-mode tests)pytest test_autofit/aggregator/ test_autofit/interpolator/— 93 pass, no regressionsautofit_workspace/scripts/features/interpolate.pyunderPYAUTO_TEST_MODE=1with this branch — exit 0, aggregator loads 3 outputs, interpolation succeedsFull API Changes (for automation & release notes)
Changed Behaviour
autofit.aggregator.Aggregator.from_directory(directory, ...)— whenis_test_mode()is active and the first scan ofdirectoryyields zero search-outputs, it now retries once againstPath(directory).parent / "test_mode" / Path(directory).nameif 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)
PyAutoLens/paper_jax/paper.mdWIP), not this change; all YELLOW reasons pre-existing/unrelated.Generated by the PyAutoLabs agent workflow.