Skip to content

feat: results library phase 2 — completeness over a declared grid + enrich #1752

Closed

Description

@Jammy2211

Overview

Results-library phase 2 (epic ledger: PyAutoMind draft/feature/autofit/results_library_epic.md). Phase 1 gave PyAutoFit an index of every result and its state; phase 2 answers "what is missing?" against a declared expectation (datasets × searches × required products, optionally derived from an hpc-campaign campaign.yaml), and adds Aggregator.enrich to add a new product to thousands of existing zips atomically — replacing the force_pickle_overwrite + SLURM reload pass used for coolest.json / wcs.json in DR1.

Plan

  • Declare what you expect: library.yaml, af.ResultsLibrary(expected=...), or from_campaign: campaign.yaml (single source of truth — no second manifest).
  • Completeness report over the phase-1 index: every (dataset, search, product) is done / missing / incomplete / failed with a reason; <name>.missing.csv written atomically. A zip without a required product is incomplete, not done.
  • Aggregator.enrich(fn, name, overwrite=False, shard=(i, N)): atomic add-or-replace of a zip member, other members byte-identical, stable sharding for Slurm or a laptop pool.
  • CLI: python -m autofit.results check library.yaml and enrich module:function --name … --shard i/N.
  • autofit_workspace guide scripts/features/results_library.py (declare → index → check → enrich) on the gaussian example.
  • Witness W1b: read-only completeness check on the DR1 laptop mirror.

Tier: judge — merge mode: human /prm

Detailed implementation plan

Affected Repositories

  • PyAutoFit (primary)
  • autofit_workspace (after library)

Branch Survey

Repository Current Branch Dirty?
./fit/PyAutoFit main clean
./fit/autofit_workspace main clean

Suggested branch: feature/results-library-p2-completeness

Implementation Steps

  1. autofit/results/library.py — ExpectedResult(dataset, search, products, location), ResultsLibrary with from_yaml (datasets: / datasets_file:, searches: {name: {path_prefix, products}}) and from_campaign (loads autofit.campaign.Campaign; manifest index → dataset fields; stage success.zip_complete template → expected location; success.members → required products; mirrors collector.check_success). Matching: location first, else (unique_tag | object_id, name); superseded records ignored.
  2. autofit/results/completeness.py — CompletenessReport (rows, counts, write_missing_csv via open_atomic). Named products from record.products; path products via zip_names() (central directory only, no index schema bump). Reasons: no_result, not_completed:<state>, missing_product:<p>, location_mismatch, duplicate.
  3. autofit/results/enrich.py — generalise paths/abstract.py::_replace_zip_member to a shared add-or-replace helper (same-dir temp + os.replace); product → files/<name>.json (dict/list) or bytes / file path; overwrite=False skips results that have it; per-result error capture, never aborts the batch.
  4. autofit/results/shard.py — stable int(record.key, 16) % N selection (phase 3 reuses it).
  5. Aggregator.enrich thin method; force_pickle_overwrite docstring points at enrich (no removal this phase).
  6. CLI subcommands check, enrich in autofit/results/__main__.py.
  7. Tests: holes fixture (missing zip, no .completed, missing image/, missing named member, superseded duplicate) → every gap with right reason; enrich over 100 zips keeps sha256 of other members; killed enrich leaves original zip intact; shards disjoint + cover; from_campaign on a small campaign.yaml; CLI round-trip.

File ownership vs phase 3 (ruling F11)

Phase 2 owns results/{library,completeness,enrich,shard}.py, Aggregator.enrich, the zip-member helper. Phase 3 owns aggregator/summary/aggregate_csv/, aggregate_fits, search_output.plain, chunk/merge. Both add subcommands to results/__main__.py — second to merge rebases.

Key Files

  • autofit/results/ — new modules above
  • autofit/aggregator/aggregator.py — enrich
  • autofit/non_linear/paths/abstract.py — _replace_zip_member → shared helper
  • autofit/campaign/spec.py, collector.py — read-only reuse for from_campaign

Original Prompt

Click to expand starting prompt

See PyAutoMind active/results_library_p2_completeness.md. Human request (verbatim): "Continbue the HPC kit and results epic where we are making it so PyAutoFit can do auto run campaign things"; plan approved 2026-11-02 ("I approve").

Activity

  1. Jammy2211 commented on Nov 2, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR Created: #1753 (pending-release). Workspace guide: PyAutoLabs/autofit_workspace#180 (merge after #1753 + release). Full suite serial 4204 passed; independent review 8 findings fixed; W1b witness on the DR1 laptop mirror 226/226 done (wrong-tree and naming-drift both surfaced). Tier judge → human /prm.

  2. Jammy2211 commented on Nov 2, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped. PyAutoFit#1753 merged (pending-release) — ResultsLibrary + completeness check + Aggregator.enrich + CLI check/enrich; autofit_workspace#180 merged (features/results_library.py guide). Witness W1b on the DR1 laptop mirror: 226/226 done. Next: phase 3 (merged as #1755) → phase 4.

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