Skip to content

feat: import autocti without arcticpy - #118

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/arcticpy-lazy-import
Nov 5, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/arcticpy-lazy-import

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

import autocti now 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 raises ImportError with the recipe (PyAutoHeart install_arcticpy.sh).
    • optional_import(*names) returns the real objects, or, without arcticpy, placeholders that raise that error when called.
    • The placeholders are real classes, so PyAutoFit can still evaluate constructor type hints such as Optional[List[TrapInstantCapture]]. A TYPE_CHECKING approach broke af.Model and 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: use optional_import instead of from 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 autocti succeeds. Using a re-exported arcticpy name, building a clocker, or clocking raises ImportError with the install recipe. Before this change, import autocti itself failed with ModuleNotFoundError: arcticpy.

Tests

  • New test_autocti/test_lazy_arcticpy.py hides arcticpy in a subprocess (sys.modules['arcticpy'] = None). It checks that import autocti works, that a re-exported name and Clocker1D raise the recipe error, and that with arcticpy installed the re-exports are the same objects. Control: all 4 fail on unchanged main.
  • Full test_autocti: 275 passed when run serially. Under -n 8, the 5 instruments/acs/test_image.py tests collide on shared FITS output files; they pass serially, both here and on main.
  • autocti_workspace_test scripts/{dataset_1d,imaging_ci}/likelihood/pins.py: OK. All 10 likelihood literals still match at rtol 1e-8.
  • autocti_workspace smoke (3 scripts, profile_smoke): 3/3 pass.
  • Downstream: no code in autocti_visualization or autocti_assistant imports arcticpy names.

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

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>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Nov 5, 2026
@Jammy2211
Jammy2211 merged commit d36f307 into main Nov 5, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/arcticpy-lazy-import branch November 5, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: import autocti without arcticpy (lazy arcticpy import)

1 participant