Soften Python version check with general.yaml bypass#96
Merged
Conversation
The hard 3.12+ check was preventing stable-but-older Python environments (e.g. the PyAutoGPU venv still on 3.10) from importing autoconf at all. The library actually runs fine on 3.9/3.10/3.11 — the 3.12 requirement was a support statement, not a functional dependency. The check now: - Reads `<cwd>/config/general.yaml` for `version.python_version_check`. - If that key is `False`, import proceeds silently. - Otherwise raises with a clearer message that names the three Pythons that technically work and shows the YAML snippet to add to bypass. Any failure reading the config (missing file, bad YAML, missing key, missing `yaml` module) falls through to the raise, so the default behaviour on an unconfigured workspace is unchanged. Co-Authored-By: Claude Opus 4.7 <[email protected]>
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
RuntimeErrorfor Python < 3.12 with a softer check that can be bypassed viaversion.python_version_check: Falsein a workspace'sconfig/general.yaml.Why
The PyAutoGPU venv is still on Python 3.10 and was being blocked from importing
autoconfentirely, even though nothing in the library actually needs 3.12. The 3.12 cap was a support statement, not a functional dependency. Hard-failing at import is too aggressive — users with known-good older-Python environments should be able to opt in per-workspace.API Changes
autoconf/__init__.py: new private_python_version_check_bypassed()helper that does a minimalyaml.safe_load(Path.cwd() / "config" / "general.yaml")and returnsTrueiff theversion.python_version_checkkey is explicitlyFalse. Any read/parse failure (missing file, missing yaml module, missing key, bad YAML) falls through to the raise, so the default fails safely.Paired PR
autolens_workspace: feature/soften-python-version-check adds the newversion:block to the shippedconfig/general.yamlwithpython_version_check: Trueas the default.Test plan
pytest test_autoconf/on Python 3.12 (87 passed)python -c "import autoconf"with the defaultTruesetting → raises with the new multi-line message referencing 3.9/3.10/3.11 and the bypass snippetpython_version_check: False→ import succeeds,scripts/imaging/modeling.py(withPYAUTO_TEST_MODE=2) runs past the version gate into model-fittingcd /tmp && python -c "import autoconf"on 3.10 (no workspace config) → still raises, message unchanged🤖 Generated with Claude Code