Repository navigation
maintenance: derive the demo dataset and canonical-output paths, never name them - #75
Merged
Merged
Conversation
…r name them `scripts/reduce_cosmos_web_ring.py` hardcoded /home/jammy/Code/PyAutoLabs/autolens_assistant/dataset/... — a cross-repo reference that breaks when autolens_assistant moves under lens/, and that was already machine-specific: nobody else's checkout is at /home/jammy. It deliberately does NOT reach for PyAutoBrain's resolver. PyAutoReduce is a released PyPI distribution: someone who `pip install pyautoreduce`s and clones this repo to run scripts/ has no Brain checkout, no .pyauto-root marker and no workspace at all, so an import-by-file-path of a developer-box organ would be dead code on every machine but one — the exact failure class that resolver's own docstring exists to kill. It would also invert the dependency direction, a science library reaching back into the orchestration layer, and it answers a question one level up from the one asked: the script needs one sibling's dataset subtree, not the workspace root. Instead: $AUTOREDUCE_DEMO_ROOT, then a bounded sibling probe, then an unverified guess. The probe checks one and two levels above the repo, each directly and one family subdirectory deeper — the full cross-product of "is THIS repo in a family folder" x "is autolens_assistant". No walk to /, no marker, stdlib only. It calls only is_dir()/glob() so it cannot raise at import, and the not-found branch returns the flat-layout path so the eventual failure names something plausible. A --demo-root flag completes the set: env var for a shell, flag for a one-off, probe for everyone else. The four prototypes' _CAND fallbacks guessed where the canonical checkout is, in order to read reduced outputs that are gitignored and so absent from a worktree. Git already knows: a worktree's .git is a FILE reading `gitdir: <canonical>/...`. The guess is replaced by that fact — stdlib, no subprocess at import, .parent chaining rather than parents[2] so a short gitdir degrades instead of raising. In an ordinary clone .git is a directory, MAIN == ROOT and the candidates collapse harmlessly; verified the resulting lists are byte-identical to the originals. Resolution demonstrated across six layouts including the actual phase-3 one (lens/autolens_assistant). 299 passed, 3 skipped. Part of PyAutoBrain#393 (phase 2). No directory layout changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0161NLKVzbBMzhaBfjpGogor
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.
Part of PyAutoLabs/PyAutoBrain#393 (phase 2). Changes no directory layout. Companions: PyAutoLabs/PyAutoMind#415, PyAutoArray (same branch name).
What was wrong
scripts/reduce_cosmos_web_ring.py:34hardcoded:A cross-repo reference that breaks when
autolens_assistantmoves underlens/— and already machine-specific: nobody else's checkout is at/home/jammy.Four
prototypes/starred_*.pyfiles carriedPath.home()/"Code/PyAutoLabs/PyAutoReduce/scripts/output"as a fallback candidate.Why this does not use PyAutoBrain's resolver
Phase 1a shipped a workspace-root resolver, and reaching for it here would be wrong:
pip install pyautoreduces and clones this repo to runscripts/has no Brain checkout, no.pyauto-rootmarker, and no workspace at all. An import-by-file-path of a developer-box organ would be dead code on every machine but one — precisely the failure class that resolver's own docstring exists to kill.autolens_assistantvslens/autolens_assistant.What it does instead
$AUTOREDUCE_DEMO_ROOT→ a bounded sibling probe → an unverified guess.The probe checks one and two levels above the repo, each directly and one family subdirectory deeper — the full cross-product of "is this repo in a family folder" × "is autolens_assistant". No walk to
/, no marker needed, stdlib only.It calls only
is_dir()/glob(), so it cannot raise at import; the not-found branch returns the flat-layout path so the eventualfits.getdatafailure names something plausible. The pre-existing code was already import-safe andDEMO_ROOTis read only insidecompare()— that property is preserved.A
--demo-rootflag completes the set: env var for a shell, flag for a one-off, probe for everyone else.The
_CANDfallbacks: replace the guess with the factTheir job is real — reduced outputs are gitignored, so a worktree has none and must read the canonical checkout's — but they guessed where canonical is. Git already knows: a worktree's
.gitis a file containinggitdir: <canonical>/.git/worktrees/<name>.Stdlib only (no subprocess at import),
.parentchaining rather thanparents[2]so a short or odd gitdir degrades instead of raisingIndexError. In an ordinary clone.gitis a directory,MAIN == ROOT, and the two candidates collapse harmlessly. Verified the resulting candidate lists are byte-identical to the pre-edit ones.Not factored into a shared
prototypes/_paths.py: these run per-stage under different venvs with noPYTHONPATH=., where a package import would not resolve.Verification
git grep -n "Code/PyAutoLabs" -- '*.py'→ empty. Same for/home/jammyandPath.home().runpy.run_path(numpy imports,MAIN/_CAND/FIELDall resolve);reduce_cosmos_web_ring.py --helpruns end to end and prints the resolved default.<root>/autolens_assistant/…lens/<root>/lens/autolens_assistant/…reduce/PyAutoReduce)<root>/lens/autolens_assistant/…<root>/autolens_assistant/…$AUTOREDUCE_DEMO_ROOTset🤖 Generated with Claude Code
https://claude.ai/code/session_0161NLKVzbBMzhaBfjpGogor