Skip to content

fix: exercise + assess the sqlite results database (scrape + direct-write) — aggregator Phase D #1377

Description

@Jammy2211

Overview

Phase D follow-up of the aggregator profiling task (#1375, phases A+B merged as #1376 + autofit_workspace_test#48). The sqlite results database (autofit/database/) has two paths: build-from-directory (scrape) and direct-write during a fit (session). Neither has been used in a long time and the direct-write path is suspected buggy. Goal: exercise both with the merged mock-results harness, fix the cheap bugs, and produce a written where-it's-at assessment for whatever isn't cheap — explicitly per the original prompt: "If its hard to fix dont bother, but its good to work out where its at."

Plan

  • Run the existing autofit_workspace_test/scripts/database/{directory,scrape,session} scripts against current main — record which still pass, triage what fails.
  • Exercise the scrape/build path at scale using the merged mock-results generator (scripts/profiling/aggregator/mock_results.py); fix bugs where cheap.
  • Extend the profiling grid with database stages (build time, query time) so sqlite loading can be compared against the directory Aggregator — answering "when is building the database worth it?".
  • Assess the session/direct-write path: fix if cheap, otherwise a written assessment (what works, what's broken, what a fix would take) posted to this issue.
  • Assessment-first: source edits happen only after the failure survey, with the fix plan checkpointed.
Detailed implementation plan

Work Classification

Both (library + workspace) — bug workflow.

Worktree root

~/Code/PyAutoLabs-wt/aggregator-sqlite/

Affected Repositories

  • PyAutoFit (primary — autofit/database/: aggregator/scrape.py, aggregator/aggregator.py, model/, sqlalchemy_.py, migration/)
  • autofit_workspace_test (scripts/database/, scripts/profiling/aggregator/)

Branch Survey

Repository Current Branch Dirty?
./PyAutoFit main clean
./autofit_workspace_test main clean

Suggested branch: feature/aggregator-sqlite

Implementation Steps

  1. Survey: run scripts/database/directory/*.py, scripts/database/scrape/*.py, scripts/database/session/*.py under PYAUTO_TEST_MODE; tabulate pass/fail + tracebacks.
  2. Scale exercise: mock N=100/1000 result sets → af.Aggregator(database file) scrape/add_directory; catalogue failures.
  3. Cheap fixes in autofit/database/ with unit tests (numpy-only).
  4. Profiling stage: add database_build + database_query stages to profile_aggregator.py (or a sibling profile_database.py).
  5. Session/direct-write assessment; cheap fixes or written verdict on this issue.

Key Files

  • PyAutoFit/autofit/database/aggregator/scrape.py — build-from-directory path
  • PyAutoFit/autofit/database/aggregator/aggregator.py — sqlite Aggregator + queries
  • PyAutoFit/autofit/non_linear/paths/database.py — direct-write (session) paths
  • autofit_workspace_test/scripts/database/ — existing coverage
  • autofit_workspace_test/scripts/profiling/aggregator/ — merged harness to reuse

Verification

  • Existing database scripts pass (or failures documented with tracebacks and triage).
  • pytest test_autofit/database/ (plus aggregator subtree) green.
  • Profiling table showing database build/query vs directory-aggregator loading on the same mock sets.

Original Prompt

Click to expand starting prompt

Phase D follow-up of the aggregator profiling task (PyAutoFit#1375; phases A+B merged as PyAutoFit#1376 + autofit_workspace_test#48). Original goal 3 of that prompt, verbatim:

"dont work on sqlite database builds on 1 or 2, but then do a follow up where you use this functionality, inevitably encounter and fix bugs for its use, and assess the code which writes directly to the sqlite database, which has not been used in a long time and I'm sure is buggy. If its hard to fix dont bother, but its good to work out where its at."

Concretely, in PyAutoFit (autofit/database/) driven from autofit_workspace_test:

  1. Use the merged mock-results harness (scripts/profiling/aggregator/mock_results.py) to exercise the sqlite build-from-directory path (autofit/database/aggregator/scrape.py, af.Aggregator(database file) + add_directory) at scale; fix the bugs encountered where they are cheap; extend the profiling grid with a database-build + database-query stage so sqlite loading can be compared against the directory Aggregator.

  2. Assess the direct-write path (session-based writing during a fit, database.py paths) — long unused and suspected buggy. Fix if cheap; otherwise produce a written where-it's-at assessment (what works, what is broken, what it would take) rather than sinking time.

  3. The existing scripts/database/{directory,scrape,session}/ scripts in autofit_workspace_test are the current coverage — run them, note which still pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions