Repository navigation
feat: import autocti without arcticpy - #118
Merged
Merged
Conversation
arcticpy is now imported lazily, so `import autocti` works on machines without it: datasets, layouts, masks, plotting and loading results all keep working. - autocti/_arcticpy.py: an arcticpy() accessor that raises an ImportError naming the install recipe, plus optional_import(), which returns the real arcticpy objects or, without arcticpy, placeholders that raise that error when called. The placeholders are real classes, so PyAutoFit can still evaluate constructor type hints. - autocti/__init__.py: the nine arcticpy re-exports (ac.TrapInstantCapture, ac.CCDPhase, ac.ROE, ...) resolve on first use through a PEP 562 __getattr__. - clocker/, model/ and ou_sim_ci.py use optional_import instead of a module-level `from arcticpy import`. With arcticpy installed, every name is the same arcticpy object as before. Co-Authored-By: Claude Opus 5.5 <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
import autoctinow works on a machine without arcticpy installed. arcticpy has no PyPI wheel; building it needs GSL and a C++ compiler, so docs builds, PyAutoEyes, the assistant and new users all used to fail at the import, even when they never clock any charge. Datasets, layouts, masks, plotting and loading results now work without it. Only clocking, and the arcticpy classes autocti re-exports, need it, and they say so with an error that names the install recipe.Closes #117 (cti-upkeep phase 2c, ruling R2).
autocti/_arcticpy.py(new):arcticpy()imports the module, or raisesImportErrorwith the recipe (PyAutoHeartinstall_arcticpy.sh).optional_import(*names)returns the real objects, or, without arcticpy, placeholders that raise that error when called.Optional[List[TrapInstantCapture]]. ATYPE_CHECKINGapproach brokeaf.Modeland was dropped.autocti/__init__.py: the nine re-exports resolve on first use through a PEP 562__getattr__/__dir__.clocker/,model/model_util.py,model/settings.py,charge_injection/ou_sim_ci.py: useoptional_importinstead offrom arcticpy import ....API Changes
No change for anyone with arcticpy installed: every name (
ac.TrapInstantCapture,from autocti import CCDPhase,ac.ROE, ...) is the identical arcticpy object, and a test asserts this.Without arcticpy:
import autoctisucceeds. Using a re-exported arcticpy name, building a clocker, or clocking raisesImportErrorwith the install recipe. Before this change,import autoctiitself failed withModuleNotFoundError: arcticpy.Tests
test_autocti/test_lazy_arcticpy.pyhides arcticpy in a subprocess (sys.modules['arcticpy'] = None). It checks thatimport autoctiworks, that a re-exported name andClocker1Draise the recipe error, and that with arcticpy installed the re-exports are the same objects. Control: all 4 fail on unchanged main.test_autocti: 275 passed when run serially. Under-n 8, the 5instruments/acs/test_image.pytests collide on shared FITS output files; they pass serially, both here and on main.scripts/{dataset_1d,imaging_ci}/likelihood/pins.py: OK. All 10 likelihood literals still match at rtol 1e-8.profile_smoke): 3/3 pass.Heart readiness at ship time: STALE (85). The one reason is that release validation is out of date after PyAutoNerves#210 merged, which concerns the next release only, not this feature.
Tier: judge, merge mode: human /prm.
🤖 Generated with Claude Code