From 47812138aedcf7c6ce1c420a5d0df9d2d7052cc6 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 8 Sep 2026 13:28:54 -0400 Subject: [PATCH] profiling/aggregator: stop stamping metadata; key mocks and queries on unique_tag PyAutoFit#1582 drops the per-search `metadata` file and keys aggregator discovery on `files/search.json`. The mock writer no longer appends `dataset_name=` to `metadata`; the harness queries and names outputs by `unique_tag`, which each stamped copy already carries in its search.json. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01GkELVxsdpNKyegTu4bFJTR --- scripts/profiling/aggregator/mock_results.py | 11 +++++------ scripts/profiling/aggregator/profile_aggregator.py | 10 +++++----- scripts/profiling/aggregator/profile_database.py | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/scripts/profiling/aggregator/mock_results.py b/scripts/profiling/aggregator/mock_results.py index 89de7a1..f590f1b 100644 --- a/scripts/profiling/aggregator/mock_results.py +++ b/scripts/profiling/aggregator/mock_results.py @@ -83,7 +83,8 @@ def write_template( ) -> Path: """ Write one full search-output directory via a test-mode bypass fit and return the - leaf directory (the one containing the `metadata` file). + leaf directory (the one containing the `files/search.json` that + `Aggregator.from_directory` discovers results by). """ template_prefix = f"_template/g{n_gaussians}_s{n_samples}" @@ -92,8 +93,8 @@ def write_template( model = model_from(n_gaussians) analysis = af.ex.Analysis(data=np.ones(10), noise_map=np.ones(10)) - # A stale template would append duplicate metadata lines (the file is opened in - # append mode), so remove any previous template for this config first. + # A stale template from an earlier configuration would be resumed rather than + # rewritten by the fit below, so remove any previous template for this config first. for candidate in ( root / "test_mode" / Path(template_prefix), root / Path(template_prefix), @@ -167,7 +168,7 @@ def stamp_results( ): """ Copy the template `n_results` times under `results_root`, giving each copy a unique - `dataset_name` metadata entry and a unique `unique_tag` in its search.json. + `unique_tag` in its `files/search.json`. The unique_tag matters for the sqlite database: fits are keyed by the identifier hashed from (search, model, unique_tag), so identical copies would collapse to a @@ -180,8 +181,6 @@ def stamp_results( dataset_name = f"dataset_{i:04d}" destination = results_root / dataset_name / "fit" shutil.copytree(template_leaf, destination) - with open(destination / "metadata", "a") as f: - f.write(f"\ndataset_name={dataset_name}") search_dict["arguments"]["unique_tag"] = dataset_name (destination / "files" / "search.json").write_text(json.dumps(search_dict)) if zip_results: diff --git a/scripts/profiling/aggregator/profile_aggregator.py b/scripts/profiling/aggregator/profile_aggregator.py index 50a4b89..fd3ae9f 100644 --- a/scripts/profiling/aggregator/profile_aggregator.py +++ b/scripts/profiling/aggregator/profile_aggregator.py @@ -14,7 +14,7 @@ - `values_samples_summary`: `values("samples_summary")` — the lightweight summary path. - `values_model`: `values("model")`. - `values_samples`: `values("samples")` — full `samples.csv` parse per result. -- `query_dataset_name`: a metadata predicate query. +- `query_unique_tag`: a `unique_tag` predicate query. - `aggregate_csv`: `af.AggregateCSV` catalogue build (the csv_make workflow pattern). Run from the `autofit_workspace_test` root, e.g.: @@ -155,8 +155,8 @@ def fresh_agg(): timings["values_samples"] = timed(lambda: deque(agg.values("samples"), maxlen=0)) agg = fresh_agg() - timings["query_dataset_name"] = timed( - lambda: agg.query(agg.dataset_name == "dataset_0000") + timings["query_unique_tag"] = timed( + lambda: agg.query(agg.unique_tag == "dataset_0000") ) agg = fresh_agg() @@ -175,7 +175,7 @@ def aggregate_images(): agg_images = af.AggregateImages(agg) agg_images.output_to_folder( results_root.parent / "png", - name="dataset_name", + name="unique_tag", subplots=[ SubplotFit.Data, SubplotFit.ModelData, @@ -192,7 +192,7 @@ def aggregate_fits(): agg_fits = af.AggregateFITS(agg) agg_fits.output_to_folder( results_root.parent / "fits", - name="dataset_name", + name="unique_tag", hdus=[FITSFit.ModelData, FITSFit.ResidualMap], ) diff --git a/scripts/profiling/aggregator/profile_database.py b/scripts/profiling/aggregator/profile_database.py index 42bc1f3..fda5f3d 100644 --- a/scripts/profiling/aggregator/profile_database.py +++ b/scripts/profiling/aggregator/profile_database.py @@ -11,7 +11,7 @@ - `generate`: building the mock results (context, not a database cost). - `database_build`: `from_database` + `add_directory` + commit on a fresh sqlite file. -- `database_query_unique_tag`: one indexed metadata query. +- `database_query_unique_tag`: one indexed `unique_tag` query. - `database_values_samples`: `values("samples")` on a capped slice. - `directory_from_directory` / `directory_values_samples`: the directory Aggregator on the same results, same cap, for side-by-side comparison.