Skip to content

fix: fits_fit creates its output directory (crash under PYAUTO_FAST_PLOTS=1) #119

Closed

Description

@Jammy2211

Overview

With PYAUTO_FAST_PLOTS=1, autocti's fits_fit writes fit.fits into an image/fit_dataset/ folder that nothing has created yet, so every model fit with visualization on crashes with FileNotFoundError. Until this is fixed, the autocti_workspace release profile keeps FAST_PLOTS off. This is cti-upkeep phase 3.

Plan

  • Both autocti FITS writers create their output folder before writing fit.fits.
  • A unit test reproduces the crash first (it must fail on current main).
  • After the library PR merges, the autocti_workspace release profile goes back to PYAUTO_FAST_PLOTS: "1", and the 3 smoke scripts must pass that way (the Witness).
  • Tier: glance — merge mode: auto-merge on green if the Witness passes, post-merge summary (library first, then workspace)
Detailed implementation plan

Affected Repositories

  • PyAutoLabs/PyAutoCTI (primary)
  • PyAutoLabs/autocti_workspace

Branch Survey

Repository Current Branch Dirty?
./cti/PyAutoCTI main clean
./cti/autocti_workspace main clean

Suggested branch: feature/cti-fits-fit-output-dir

Implementation Steps

  1. Add Path(output_path).mkdir(parents=True, exist_ok=True) before hdu_list.writeto in autocti/dataset_1d/plot/fit_plots.py::fits_fit and autocti/charge_injection/plot/fit_ci_plots.py::fits_fit.
  2. One test per writer: call fits_fit with a nested folder that doesn't exist yet and assert fit.fits is written. Control: both fail on main. Then run the full test_autocti serially.
  3. autocti_workspace config/build/profile_release.yaml: PYAUTO_FAST_PLOTS: "1", drop the workaround comment. Witness: 3/3 smoke scripts pass through run_python.py with that profile.

Original Prompt

Click to expand starting prompt

autocti: fits_fit writes fit.fits into a directory nothing creates when PYAUTO_FAST_PLOTS=1

Type: bug
Target: autocti
Repos:

  • autocti
  • autocti_workspace
    Themes:
  • cti
  • visualization
    Difficulty: small
    Autonomy: supervised
    Priority: normal
    Status: formalised
    Consequence: glance
    Witness: with PYAUTO_TEST_MODE=1 PYAUTO_SKIP_VISUALIZATION=0 PYAUTO_FAST_PLOTS=1, scripts/dataset_1d/modeling/start_here.py and scripts/imaging_ci/modeling/start_here.py in autocti_workspace run to completion and write image/fit_dataset/fit.fits; autocti_workspace config/build/profile_release.yaml flips back to PYAUTO_FAST_PLOTS: "1".
    Review-minutes: 3
    Unattended: ready
    Epic: cti-upkeep
    Phase: 3

What happens

Found 2026-11-05 while adding autocti_workspace config/build/profile_release.yaml
for the release train (PyAutoHands#332). All 3 smoke_tests.txt scripts fail
under the release profile with FAST_PLOTS on:

FileNotFoundError: .../output/test_mode/dataset_1d/simple/species[x2]/<hash>/analyses/analysis_0/image/fit_dataset/fit.fits
  autocti/dataset_1d/model/plotter.py:202  fit_plots.fits_fit(fit=fit, output_path=output_path)
  autocti/dataset_1d/plot/fit_plots.py:216 hdu_list.writeto(Path(output_path) / "fit.fits", ...)

output_path is the image_path / "fit_dataset" subfolder. It only gets created as a
side effect of autoarray.plot.utils.subplot_save saving a figure. With
PYAUTO_FAST_PLOTS=1 that function returns before it creates the directory, so the
FITS write fails. PyAutoGalaxy avoids this because its base plotter image_path
calls os.makedirs, and its fits writers target that path directly.

Fix

Create the directory before the write in both FITS writers:
autocti/dataset_1d/plot/fit_plots.py::fits_fit and
autocti/charge_injection/plot/fit_ci_plots.py::fits_fit (or make the CTI plotters'
subfolder paths mkdir(parents=True, exist_ok=True)). Add a unit test that calls
fits_fit with a non-existent output directory. Then set the release profile's
FAST_PLOTS back to "1" (the temporary workaround comment points here).

Activity

  1. Jammy2211 commented on Nov 5, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped 2026-11-05

    Witness passed: 3/3 release smoke scripts with FAST_PLOTS on. Independent review: CLEAN. CI is green on both PRs. Glance-tier auto-merge (plan approved 2026-11-05).

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions