Skip to content

fix: Fix stale SQLite databases on repeated CTI smoke runs #49

Closed

Description

@Jammy2211

Overview

Use the resolved database path for cleanup in the six scripts. Check repeated execution against the same smoke output.

Approved plan

Reproduce on main and fix on feature/cti-database-reruns. Run the regression checks below. Leave PRs open for maintainer review.

Original prompt

Development details and acceptance criteria

autocti_workspace: database scripts delete the wrong .sqlite under test mode, so a second run fails

Type: bug
Target: autocti_workspace
Repos:

  • autocti_workspace
    Themes:
  • cti
  • smoke
    Difficulty: easy
    Autonomy: supervised
    Priority: low
    Status: formalised
    Consequence: glance
    Witness: running dataset_1d/advanced/temporal/plot.py twice in a row under config/build/profile_smoke.yaml succeeds both times, and the same holds for every script that builds a database with af.Aggregator.from_database(filename=...) + add_directory.
    Review-minutes: 3
    Unattended: ready
    Lane: any
    Epic: cti-upkeep
    Phase: 3
    Filed: 2026-11-06

Found during cti-five-failing-scripts (autocti_workspace#45), 2026-11-06. Six scripts start with

try:
    os.remove(path.join("output", f"{database_name}.sqlite"))
except FileNotFoundError:
    pass
agg = af.Aggregator.from_database(filename=f"{database_name}.sqlite", completed_only=False)
agg.add_directory(...)

Under PYAUTO_TEST_MODE the database is written to output/test_mode/<name>.sqlite, but the
script removes output/<name>.sqlite. So the old database survives, and the second run re-inserts
the same fits: sqlite3.IntegrityError: UNIQUE constraint failed: fit.id (this is the
"SQLAlchemy error" the 2026-11-05 triage saw on temporal/plot.py). CI always runs from a fresh
clone, so smoke stays green; it bites local re-runs only.

Scripts: dataset_1d/advanced/temporal/{database,plot}.py, plot/ccd/{dataset_1d,imaging_ci}/database.py,
plot/fpa/{dataset_1d,imaging_ci}/database.py.

Fix options: remove the file at the path the aggregator actually uses (check whether PyAutoFit
exposes the resolved output root, e.g. via autoconf/test-mode path helpers), or have the
library's from_database accept an overwrite flag. Check autolens_workspace for the existing
pattern first and mirror it.

Activity

  1. Jammy2211 commented on Nov 22, 2026

    @Jammy2211
    CollaboratorAuthor

    The fix is open for review in #50. All six examples passed twice against the same smoke outputs on Python 3.13 (after nine prerequisite runs). The old CCD Dataset1D script failed on rerun with UNIQUE constraint failed: fit.id. The full isolated Python 3.12 Heart run passed all 44 workspace smoke scripts. Corresponding notebooks were regenerated and the catalogue check was clean.

  2. Jammy2211 commented on Nov 22, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Five SQLite examples clean the resolved smoke output path and the temporal directory reader uses the same namespace. All six regenerated notebooks match the scripts. Each example passed twice with existing output, and all 44 curated smoke scripts passed.

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