Repository navigation
Description
Overview
Every DirectoryPaths.save_all writes a two-line metadata file (name=…, non_linear_search=…) into each search output folder. A 2026-09-08 survey found it has one load-bearing consumer: Aggregator.from_directory uses "metadata" in filenames as the sentinel that a directory is a search output. files/search.json is already written unconditionally by the same save_all, so the sentinel can move there at no run-time or aggregation cost. Resume keys entirely on .completed, so in-flight runs are unaffected. This task stops writing metadata, keys discovery on files/search.json (still accepting legacy metadata folders), and derives the non_linear_search filter attribute from search.json.
Plan
- Aggregator discovers a search output when
<root>/files/search.jsonexists; legacy folders carrying onlymetadatastill aggregate. SearchOutputstops parsingmetadata;non_linear_searchbecomes a property read fromsearch.json'sclass_path.- Delete
_save_metadataand its call; fix the skip-fit-output comment that references the file. - Remove the four
metadatatest fixtures; update the zip round-trip assertion; add discovery and filter tests. - Update the two mock-result writers and the profiling harness (autofit_workspace_test, autolens_workspace_developer) to stop appending
metadataand to key onunique_taginstead of the injecteddataset_name.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary)
- autofit_workspace_test
- autolens_workspace_developer
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main | clean |
| ./autofit_workspace_test | main | clean |
| ./autolens_workspace_developer | main | clean |
worktree_check_conflict fires: PyAutoFit and autofit_workspace_test are claimed by traced-assertions-on-jax-path (#1581). Its file set (autofit/mapper/prior/arithmetic/assertion.py, autofit/mapper/prior_model/{abstract,constraint}.py, autofit/non_linear/fitness.py + tests) is disjoint from this task, so this task runs in its own parallel worktree (recorded as parallel-claim: in active.md).
Suggested branch: feature/aggregator-search-json-sentinel
Implementation Steps
PyAutoFit:
autofit/aggregator/aggregator.py(from_directory→scan, ~L195): replaceif "metadata" in filenames:with a helper_is_search_output(root, dirs, filenames)=("files" in dirs and (Path(root)/"files"/"search.json").exists()) or "metadata" in filenames. The"files" in dirsguard keeps the check at the search root soos.walknever hands thefiles/directory itself toSearchOutput..is_grid_searchhandling unchanged.autofit/aggregator/search_output.py(SearchOutput.__init__~L216–225,__str__/__repr__~L430): remove themetadataread into__dict__/self.text. Add@property non_linear_searchreturningclass_path.rsplit(".", 1)[-1].lower()fromfiles/search.json(no search instantiation), matching what_save_metadatawrote so existing filters keep their values. Replace__str__/__repr__with a description built fromself.directory.autofit/non_linear/paths/directory.py: delete_save_metadata(~L472–481) and its call at the end ofsave_all(~L384). Verify no override insub_directory_paths.py/database.py/null.py.autofit/non_linear/search/abstract_search.py(~L573–576): rewrite the skip-fit-output comment to namefiles/search.json+ identifier files as what aggregator discovery needs.- Tests:
git rmtest_autofit/aggregator/{search_output,search_output_derived,summary_files/aggregate_summary/fit_1,summary_files/aggregate_summary/fit_2}/metadata;test_from_directory.py:37assertsfiles/search.jsonsurvives the zip round-trip; new tests: folder with onlyfiles/search.jsonis discovered, folder withfiles/but nosearch.jsonis not,files/itself is never returned, legacymetadata-only folder is discovered,agg.query(agg.non_linear_search == "dynestystatic")matches thesearch_outputfixture and"emcee"matchessearch_output_derived. Greptest_autofitfor_save_metadata,"metadata",.textand fix remaining hits. Check the 70-bytesearch_output_derived/metadatafor keys a test relies on via__dict__injection.
Workspace side (after the library PR is open):
6. autofit_workspace_test/scripts/profiling/aggregator/mock_results.py: drop the metadata append in stamp_results (~L183–184); unique_tag already carries the dataset name in search.json. Update docstrings (L86, L95–96, L170).
7. autofit_workspace_test/scripts/profiling/aggregator/profile_aggregator.py: agg.dataset_name == … → agg.unique_tag == …; output_to_folder(name="dataset_name") → name="unique_tag" for AggregateImages and AggregateFITS. Keep the query_dataset_name timing key if any results README/dashboard parses it (grep first).
8. autolens_workspace_developer/aggregator_profiling/mock_lens_results.py: same as step 6 (~L126–127; docstrings L14–15, L82, L94–95); apply the unique_tag substitution to any sibling profiling script that queries dataset_name.
Key Files
PyAutoFit/autofit/aggregator/aggregator.py— directory-walk sentinelPyAutoFit/autofit/aggregator/search_output.py—SearchOutputmetadata parse,non_linear_search,__str__PyAutoFit/autofit/non_linear/paths/directory.py—_save_metadatawriterPyAutoFit/autofit/non_linear/search/abstract_search.py— skip-fit-output commentPyAutoFit/test_autofit/aggregator/— fixtures and from-directory testsautofit_workspace_test/scripts/profiling/aggregator/{mock_results,profile_aggregator}.pyautolens_workspace_developer/aggregator_profiling/mock_lens_results.py
Verification
pytest test_autofit -qgreen in the worktree.- Tiny test-mode fit from the worktree: output folder has no
metadata;af.Aggregator.from_directory(output)returns it;agg.query(agg.non_linear_search == "<search>")matches. - Legacy:
from_directoryon an existing pre-change output folder returns the same count. - Resume: delete
metadatafrom an incomplete output folder and re-run; the fit resumes.
Original Prompt
Click to expand starting prompt
Remove the output-folder metadata file; aggregator discovers searches via files/search.json
Type: refactor
Target: PyAutoFit
Repos:
- PyAutoFit
- autofit_workspace_test
- autolens_workspace_developer
Difficulty: small
Autonomy: supervised
Priority: medium
Status: formalised
Witness: no search output folder written byDirectoryPaths.save_allcontains ametadatafile;Aggregator.from_directoryon a fresh run (and on a legacy folder that still carriesmetadata) returns the same search outputs as before;agg.filter(agg.non_linear_search == ...)still works, sourced fromsearch.json; resume of a run whosemetadatafile has been deleted is unaffected; full PyAutoFit test suite green.
Unattended: ready
Filed: 2026-09-08
Original request (verbatim):
Is the "metadata" file that is output to the output folder of all autofit /
autolens runs still required? Is there any way we could remove it or would
this disrupt on going runsWould using search.json impact run time in a meaningful way? If not then
that is the solutionlets go, use search.json and remove metadata
Findings (2026-09-08 survey):
- Sole writer:
DirectoryPaths._save_metadata(autofit/non_linear/paths/directory.py),
called last insave_all. Twokey=valuelines:name=,non_linear_search=.
Appends, so resumed runs duplicate the block. - Sole sentinel:
Aggregator.from_directory(autofit/aggregator/aggregator.py)
treats a directory as a search output iff"metadata" in filenames. The
database scrape and MCP tools inherit this by iterating the aggregator. SearchOutput.__init__(autofit/aggregator/search_output.py) parses it
intoself.__dict__;nameis shadowed by the property reading
search.json, so onlynon_linear_searchsurvives as a filter attribute.
Absence is already swallowed (FileNotFoundErrorpassed).- Resume keys entirely on
.completed; nothing on that path readsmetadata. files/search.jsonis written unconditionally by the samesave_all
(including the skip-fit-output branch), so switching costs no I/O.- Trap:
search.jsonlives one level down infiles/; the sentinel must be
checked from the search root ("files" in dirs+ exists), not by name match
infilenames, oros.walkwould handSearchOutputthefiles/dir. - Mock writers to update:
autofit_workspace_test/scripts/profiling/aggregator/mock_results.py,
autolens_workspace_developer/aggregator_profiling/mock_lens_results.py. - Test fixtures under
test_autofit/aggregator/carrymetadatafiles;
test_from_directory.pyasserts one survives a zip round-trip.
Activity
Jammy2211 commentedon Sep 8, 2026
Library PR created: #1585 (2477 passed, 2 skipped; end-to-end fit writes no
metadata, aggregator discovers viafiles/search.json).Workspace follow-ups, behind the library-first gate:
unique_tag;profile_aggregator.py --quickandprofile_database.py --quickpass)profile_lens_aggregator.py --quickdiscovers 10/50/50 stamped results)Resume is unaffected: nothing on the
.completedpath reads the file, so in-flight runs carry on and legacy output folders still aggregate.Jammy2211 commentedon Sep 8, 2026
Shipped
DirectoryPaths.save_allno longer writes themetadatafile;Aggregator.from_directorydiscovers search outputs viafiles/search.json(legacymetadata-only folders still accepted);SearchOutput.non_linear_searchis a property read fromsearch.json;.text/.file_pathremoved.metadata, harness keys onunique_tag.metadata.Resume is unaffected (keyed on
.completed); in-flight runs and existing output folders keep aggregating. The library change is pending release.