Skip to content

fix(env_config): substring-match patterns against full path - #91

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/fast-plots-env-coverage
May 20, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/fast-plots-env-coverage

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

env_config._pattern_matches (and the matching build_util.should_skip / _find_skip_reason) was substring-matching the YAML pattern against the file path with its .py extension stripped. Any env_vars.yaml or no_run.yaml pattern that ended in .py therefore never fired — silently.

In the *_workspace_test repos this dead-pattern bug left PYAUTO_FAST_PLOTS=1 set on 7 visualization.py scripts. PYAUTO_FAST_PLOTS=1 short-circuits subplot_save / save_figure in PyAutoArray (no PNG ever written), producing the dataset.png missing / fit.png was not produced failures triaged as Cluster A (plus a parked 40d-old autolens imaging/visualization NEEDS_FIX entry).

This change substring-matches against the full path (including extension) so patterns can anchor with .py to target a specific script form without inadvertently catching _jax / _jit siblings. Updates env_config.build_env_for_script and repro_command.canonical_env_for_script (both in-module call sites of _pattern_matches).

The matching env_vars.yaml override updates ship separately in autogalaxy_workspace_test and autolens_workspace_test PRs. Next triage cluster regen should clear Cluster A and the parked NEEDS_FIX entry.

API Changes

None — internal changes only.

The signature of the private _pattern_matches helper changes; its two in-module callers (build_env_for_script, canonical_env_for_script) are updated in the same commit. Public functions (should_skip, build_env_for_script, load_env_config, repro_command) are unchanged. See full details below.

Test Plan

  • python -m pytest tests/ — 72/72 pass, including 8 new regression tests in tests/test_pattern_matches.py.
  • Static env-resolution check: 13 affected visualization*.py scripts across both *_workspace_test repos resolve with PYAUTO_FAST_PLOTS=<unset>; 3 control scripts (aggregator/, imaging/convolution, imaging/model_fit) still resolve PYAUTO_FAST_PLOTS=1 as expected.
  • End-to-end smoke: 9 affected scripts run under the autobuild-resolved env (full build_env_for_script pipeline). All pass:
Script Status Time
autogalaxy/ellipse/visualization.py PASS 50.6s
autogalaxy/imaging/visualization.py PASS 95.2s
autogalaxy/interferometer/visualization.py PASS 30.9s
autogalaxy/quantity/visualization.py PASS 11.8s
autolens/imaging/visualization.py PASS 64.1s
autolens/interferometer/visualization.py PASS 69.5s
autolens/point_source/visualization.py PASS 20.0s
autolens/point_source/visualization_jax.py PASS 41.6s
autolens/imaging/visualization_jax.py PASS 123.8s
Full API Changes (for automation & release notes)

Changed Signature (internal only)

  • autobuild.env_config._pattern_matches(file, file_path_no_ext, pattern) → _pattern_matches(file, pattern) — two in-module call sites (env_config.build_env_for_script, repro_command.canonical_env_for_script) updated.

Changed Behaviour

  • autobuild.env_config._pattern_matches — substring matches against str(file) (including .py) instead of str(file.with_suffix("")).
  • autobuild.build_util.should_skip — same change.
  • autobuild.build_util._find_skip_reason — same change.

Previously-dead patterns ending in .py (3 entries across the *_workspace_test repos) now fire correctly. Patterns without .py still match as before — they remain substrings of the now-extension-included path.

Added

  • tests/test_pattern_matches.py — 8 tests locking in the convention: .py-anchored patterns match only the script (not siblings); prefix-only patterns substring-match all siblings; stem patterns match exactly.

Migration

None required. The fix changes behaviour only for previously-dead patterns.

🤖 Generated with Claude Code

env_config._pattern_matches and build_util.should_skip stripped the
.py suffix before substring-matching, silently nullifying any
env_vars.yaml or no_run.yaml pattern that ended in `.py`. Three
patterns in *_workspace_test env_vars.yaml (e.g.
imaging/visualization.py) were therefore dead, leaving
PYAUTO_FAST_PLOTS=1 set on visualization scripts and causing 7 of
them to fail with "fit.png was not produced" / "dataset.png missing"
(triage Cluster A).

Substring-match against str(file) instead so `.py`-anchored patterns
work as intended (imaging/visualization.py matches only the script,
not _jax / _jit siblings). Updates the in-module call sites in
env_config.build_env_for_script and repro_command.canonical_env_for_script.

Add 8 regression tests in tests/test_pattern_matches.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release Merged PR awaiting inclusion in the next release build label May 20, 2026
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autogalaxy_workspace_test#52

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace_test#107

@Jammy2211
Jammy2211 merged commit 761736e into main May 20, 2026
@Jammy2211
Jammy2211 deleted the feature/fast-plots-env-coverage branch May 20, 2026 18:15
@Jammy2211 Jammy2211 removed the pending-release Merged PR awaiting inclusion in the next release build label Oct 7, 2026
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.

1 participant